TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ligatures in programming fonts

108 pointsby matiaszalmost 8 years ago

25 comments

panicalmost 8 years ago
The first problem isn&#x27;t really a problem, since ligatures are provided by fonts, not character encodings. From the Unicode FAQ on ligatures and digraphs (<a href="http:&#x2F;&#x2F;unicode.org&#x2F;faq&#x2F;ligature_digraph.html" rel="nofollow">http:&#x2F;&#x2F;unicode.org&#x2F;faq&#x2F;ligature_digraph.html</a>):<p><i>&quot;The existing ligatures exist basically for compatibility and round-tripping with non-Unicode character sets. Their use is discouraged. No more will be encoded in any circumstances.</i><p><i>&quot;Ligaturing is a behavior encoded in fonts: if a modern font is asked to display “h” followed by “r”, and the font has an “hr” ligature in it, it can display the ligature. Some fonts have no ligatures, some (especially for non-Latin scripts) have hundreds. It does not make sense to assign Unicode code points to all these font-specific possibilities.&quot;</i><p>The second problem still stands, though, especially since these sequences of characters can be tokenized differently in different programming languages. IMO, if you&#x27;re going to have character replacement like this, it should be a configurable editor feature like syntax highlighting.
评论 #14832101 未加载
评论 #14837876 未加载
评论 #14831267 未加载
评论 #14832754 未加载
wmilalmost 8 years ago
The article lists a bunch of non-issues. Yes, you can create confusion by abusing unicode.<p>But that&#x27;s not new. C++ allows zero width spaces in identifiers. There&#x27;s a guy on reddit who uses characters from Canadian Aboriginal Syllabics block to have angle braces in Go identifiers.<p>Yes, they are guaranteed to be wrong sometimes. The big one is the &lt;&lt;&lt; ligature makes the merge conflict zipper look strange.<p>But it&#x27;s incredibly obvious when they are wrong. So it&#x27;s not an issue in practise.<p>The reality is that no one is making anyone use a ligature font, and some people like them. If it&#x27;s causing a problem then you can spend ten seconds changing your font.
评论 #14831371 未加载
mg794613almost 8 years ago
Ugh to answer the last line of the author: I have been using them for that long and the up and downsides are very well known to me. He has an subjective opinion about them, states them as facts &#x27;and everyone who thinks differently is just stupid&#x27; OK author...
评论 #14831330 未加载
Stenzelalmost 8 years ago
I agree with the article, but the arguments the author gives are not quite spot-on. Ligatures render code unreadable, there is no way to see how to enter a particular character sequence that is shown as a ligature. They might beautify code for some individuals, but they should never be used for showing code in an public or explanatory context, like on the web. Some operators are no longer recognisable, a few just look wrong - a clear case where simplicity and functionality is sacrificed for style.
评论 #14831337 未加载
评论 #14874428 未加载
abritishguyalmost 8 years ago
I use ligatures in atom and they are 100% aware of context. I disable them in contexts where they don&#x27;t make sense e.g comments and I disable them on the line the cursor is on.<p>I&#x27;ve not had any issues. The =&gt; ligature looking like the right arrow character is just like a cyrillic A looking like a latin A - it&#x27;s a problem that never manifests itself.<p>The author has a very subjective opinion that they try and present as fact.
anorakoverflowalmost 8 years ago
The author&#x27;s point about &quot;dumb&quot; ligatures doesn&#x27;t really hold up: While the &quot;fi&quot; ligature will always mean &quot;f followed by i&quot; its use is not always correct.<p>For example, in German compound nouns, you do not set a ligature between the two nouns. For instance, &quot;Kaufläche&quot; (Kau: chewing, + Fläche: area) should be written with ligature, while in &quot;Kaufleute&quot; (Kauf: purchase, + Leute: people, = merchants) the ligature should be avoided.
评论 #14832113 未加载
评论 #14831897 未加载
idle_zealotalmost 8 years ago
I use fonts with ligatures while programming because they&#x27;re more expressive of intent. Many languages use a combination of characters to form a single meaningful token, such as JS with =&gt;. This token is meant to appear similar to an arrow, and has nothing to do with = or &gt;. In this case, I find it preferable to draw a ⇒.
评论 #14831228 未加载
SCdFalmost 8 years ago
Honestly, this sounds like the kind of argument you could present about how syntax highlighting is a terrible idea. It might be wrong!<p>I don&#x27;t use ligatures, but I really don&#x27;t see a problem with other people using them. It&#x27;s fine, it&#x27;s a style preference thing, that, like fonts and colour schemes, is as much fashion and personal preference as it is anything. But it&#x27;s fine.
评论 #14832330 未加载
评论 #14831485 未加载
nvivoalmost 8 years ago
I work with someone who uses ligatures. Everytime I need to see his screen is a problem, I can never recognize what exactly the characters mean. Yes, you get used to it if you use it, but if you don&#x27;t, working with other people becomes a problem.<p>I thought it was a bad idea the first time I saw it, and after seeing it in real code I still think the same thing.
评论 #14832131 未加载
captainmuonalmost 8 years ago
I think ligatures can be a great feature, but they should not be decided by the font, but by the editor. So you can can destinguish between &#x27;input &gt;&gt; var&#x27; and &#x27;vector&lt;vector&lt;int&gt;&gt;&#x27; and render the literature in one case but not the other. This and more creative text decorations can be really helpful to read code. Other examples are rendering css colors inline, rendering of tables and formulas in emacs, ...
评论 #14831551 未加载
评论 #14832556 未加载
frou_dhalmost 8 years ago
Ligatures in programming fonts really seem like something you&#x27;d only get into in the midst of a hardcore procrastination bout.
sk0galmost 8 years ago
Q: Should random people on the internet dictate what you do and like? A: Hell no<p>I quite like the ligatures that come with Fira Code, and most of the author&#x27;s issues are not applicable to it.<p>Maybe they should spend more than 5 minutes trying things out.
Arcanum-XIIIalmost 8 years ago
It seems there is some confusion for the author between the display part and the on disk part. text will not be saved with the ligature, it will still be pure unadorned text when saved... and for the confusion that could arise between a simple quote and a typographic one, it&#x27;s not coming from the font but from the editor rendering engine (word does those kind of change, IntelliJ does not for example, but both can display correctly ligature)
评论 #14831214 未加载
VeejayRampayalmost 8 years ago
Am I the only one thinking that &quot;www&quot; using Fira Code is unreadable?
ktpsnsalmost 8 years ago
Interestingly, nobody mentioned Mathematica&#x27;s (Wolfram langauge) approach of getting Unicode characters into code. &quot;High level&quot; mathematical symbols can be used in Wolfram language all over the place, for instance the arrow → indicating a Rule (<a href="http:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;ref&#x2F;character&#x2F;Rule.html" rel="nofollow">http:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;ref&#x2F;character&#x2F;Rule.htm...</a>) or ∞ indicating Infinity (<a href="http:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;ref&#x2F;Infinity.html" rel="nofollow">http:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;ref&#x2F;Infinity.html</a>).<p>As Mathematica inherits the homoiconicity from LISP, ie. the paradigm &quot;code is data&quot;, it abstracts the code representation (called &quot;Forms&quot;, <a href="http:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;tutorial&#x2F;FormsOfInputAndOutput.html" rel="nofollow">http:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;tutorial&#x2F;FormsOfInputA...</a>). Every shortened code full of greek symbols can be written in a completely similar form in ASCII. Thus it is solely to the Mathematica notebook (a Qt-based GUI) to render the Unicode. The GUI also allows to quickly enter any named symbols with an approach like typing &quot;[ESC] alpha [ESC]&quot; and an α appears (cf. <a href="http:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;tutorial&#x2F;SpecialCharacters-MathematicalAndOtherNotation.html" rel="nofollow">http:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;tutorial&#x2F;SpecialCharac...</a>).<p>I think this is the right approach: Let the beautification to be done by the code viewers. The approach to enter named symbols probably stems from (La)TeX where one writes &quot;$\alpha$&quot; to get α and is typical to Computer Algebra Systems. For instance, SageMath as well as SymPy allow to define something like a=var(&quot;alpha&quot;) and render it like α.
评论 #14874366 未加载
jstewartmobilealmost 8 years ago
Somewhat off-topic, but the explosion Unicode glyphs can lead to problems more serious than aesthetics:<p>Punycode exploit: <a href="https:&#x2F;&#x2F;www.xudongz.com&#x2F;blog&#x2F;2017&#x2F;idn-phishing&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.xudongz.com&#x2F;blog&#x2F;2017&#x2F;idn-phishing&#x2F;</a><p>Greek question mark: <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;26965331&#x2F;javascript-prank-joke" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;26965331&#x2F;javascript-pran...</a><p>Shameless plug: <a href="https:&#x2F;&#x2F;github.com&#x2F;BourgeoisBear&#x2F;A-E-S-T-H-E-T-I-C" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;BourgeoisBear&#x2F;A-E-S-T-H-E-T-I-C</a>
mrkgnaoalmost 8 years ago
&gt; The problem is that ligature substitution is “dumb” in the sense that it only considers whether certain characters appear in a certain order. It doesn’t have any awareness of the semantic context.<p>True, which is why Iosevka has language-specific ligatures that a sufficiently smart editor (I think the &quot;JS types&quot;, like Atom&#x2F;VSCode, have CSS for this) can use to ligate (?) intelligently.
mikelwardalmost 8 years ago
Premise: don&#x27;t make =&gt; look like ⇒, because ⇒ is already a separate thing.<p>Then later: check out this font I made where 0 looks like Ø.
fuzzygroupalmost 8 years ago
Ignoring the Unicode issues, I installed all of these, switched to the retina version of each in my editor and I found none of them any better than what I had been using (Menlo). I&#x27;m certain that YMMV but at least for me, there was no improvement (languages tested with were Ruby, and ERB formatted HTML).
broxpalmost 8 years ago
Fortress (a dead JVM programming language by Guy Steele) had an interesting approach for special characters:<p><a href="https:&#x2F;&#x2F;de.wikipedia.org&#x2F;wiki&#x2F;Fortress_(Programmiersprache)#Darstellung_des_Quelltextes" rel="nofollow">https:&#x2F;&#x2F;de.wikipedia.org&#x2F;wiki&#x2F;Fortress_(Programmiersprache)#...</a>
wodenokotoalmost 8 years ago
Do ligatures really act like one character? I&#x27;ve never encountered not being able to select only the f ro the i in a &#x27;fi&#x27;-ligature, but I don&#x27;t really use ligatures outside of word processing.
评论 #14833398 未加载
qariozalmost 8 years ago
Ligatures are for personal usage only. If you are doing presentation to me and use ligatures, I will judge you.
评论 #14874376 未加载
hamstergenealmost 8 years ago
They call it ligatures, but prettifying --&gt; to a long arrow is quite out of scope of historical and practical meaning of typographic ligature. It&#x27;s abuse of typesetter to scratch one&#x27;s typography &#x2F; graphic design itch, no less.
warrenmalmost 8 years ago
I didn&#x27;t even know those were a thing<p>But in a monospace font? No. No. No. no. No.<p>Epicly bad plan to use something like that to display code
评论 #14831100 未加载
评论 #14831144 未加载
评论 #14830950 未加载
ktpsnsalmost 8 years ago
mnm