> Ligatures in programming fonts are a terrible idea.
> And not because I’m a purist or a grump. (Some days, but not today.) Programming code has special semantic considerations. Ligatures in programming fonts are likely to either misrepresent the meaning of the code, or cause miscues among readers. So in the end, even if they’re cute, the risk of error isn’t worth it.
If you think "→" misrepresents the meaning of "->", then certainly "->" also misrepresents the meaning of a semantic arrow "→". The set of symbols in 7-bit ASCII is somewhat arbitrary after all.
Let's say "→" misrepresents the meaning of "->" even as much as 0.1% of the time. Would you rather your risk of error be 99.9%, or 0.1%?
I'm sick of anti-ligature people telling everyone else not to enjoy their fonts, on every single post about a font. Ligatures have caught on for a reason.
If you say it is a "terrible idea" that kind of implies that anyone who has the idea to add them to their font or use a font that supports it has made a terrible choice. At least, that's how I interpret it.
The only thing that is annoying with -> as two characters is the misalignment of the horizontal center. If the ligature had always centered the - to the middle of the >, I’m not sure so many people would be pushing towards having a single arrow.
Ligatures caught on because users like 'clean' designs where 'clean' means 'the removal of affordances which are not needed by frequent users but are useful to new users'. Your example doesn't make any sense because while the dash arrow attempts to mimic an actual arrow it's not ambiguous that it's two characters and will be understood by a compiler as such. A reading of source code either on a blog or shoulder surfing with this font does have that ambiguity, which is the problem.
I don't think "→" necessarily misrepresents the meaning of "->" (though see the objections throughout the thread re: differing ways that languages notate "not equal to.")
The point is that programming isn't just an exercise in semantics. But it is deterministic symbolically.
Screenshots are a suboptimal way to share code in general, and should be avoided. If you are trying to copy code from a screenshot something has gone horribly wrong in your process. If you are having trouble reading ligatures, that may be a learning curve issue you can adapt to with more use. (Arguably, most ligatures should be obvious with enough familiarity with the programming language without needing to look them up or learn them.)
Most other ways of code sharing you just copy and paste into a non-ligature font if you need to.
Aside: "ASCII" symbols are neither universally shaped or styled either. The easiest and obvious example to mind is the plain 0, dotted 0, slashed 0 choice and confusion with nearby symbols such as O and o and θ (Theta, not far away in "Extended ASCII"). Similarly all the variations of lower-case L (versus 1 and i). Those choices vary considerably between fonts and are another huge reason some people prefer certain monospace fonts over others and the debate over "best" will likely be an ever ongoing one. You may not think these issues compare to ligature use, but it's exactly the same sort of style debates.
I make less errors and find errors more readily with ligatures on. The instant I saw them on my coworker's machine, I had installed Fira and enabled ligatures in Jetbrains. I have ADHD and I'm a highly visual person. I love ligatures, emojis, and any CLI tool that "makes my terminal look like a disco" (to quote a different coworker).
I'm sure it's a highly personal thing, but Matthew Butterick proclaims it's more universally bad than it actually is.
That is why there's a checkbox for enabling ligatures.
Like why is this a thing? It's like proclaiming certain font sizes aren't worth it. My dev machine is my interface. I should be able to do what I like with it.
Edit: I guess he addresses this in a footnote, but hardly:
> “What do you mean, it’s not a matter of taste? I like using ligatures when I code.” Great! In so many ways, I don’t care what you do in private. Although I predict you will eventually burn yourself on this hot mess, my main concern is typography that faces other human beings.
A) I've never burned myself b) other than screen shares (again, nary a complaint, but several "cool! How do I get that?") I'm never rendering code for others to consume. I agree that a ligatured font would be bad e.g. for publishing code in a whitepaper.
I find ligatures increase the difficulty of communicating/collaborating with other developers. When working through a problem together in a screenshare, or at their machine, having to visually parse what they're displaying creates a speedbump in my head as I have to pause and translate. Some ligatures are not too bad, easily discernible, but some are particularly egregious.
The worst offenders tend to be anything involving '!' and '=' and the many varying stylistic interpretations of it. It appears that font designers are in a race to outdo each other, or introduce it for the 'coolness' factor and eschewing the practicalities involved.
But I don't want to be a grump and I do keep trying out ligature fonts every now and again, always with negative results.
"Is this a ligature or is it a homoglyph attack" is certainly a waste of cycles that nobody should have to endure. (why am I thinking of Scala all of a sudden, Scala has done nothing wrong!)
Perhaps if some radical homoglyph defenses get established they could also take this sting out of ligatures? (how about highlighting everything that cannot be typed with your current keyboard layout, or with the layouts in whatever quick access scheme you might have?)
Hmm. Yeah, I really don't think I like != ligature. I don't want to mistake it for some non-ascii unicode symbol, and I generally like what I type to stay the way I typed it (including curly quotes!).
Yeah, no thank you.
Also, I notice that Jetbrains Mono doesn't ligature ~= as !=, but that is what it means in Matlab. So it really seems like assumptions about language semantics is baked in to the font.
Jetbrains Mono does offer the no-ligature version.
This gives me the same vibe as "Why get rid of the DVD drive?".
I've used ligatures now for several years (with JetBrains Mono in particular for some time). I've done lots of pair programming and a common immediate reaction is "How can I get those too?! It makes it so nice to read and understand".
Instead of throwing them out because of some edge cases, why not improve the software for the edge cases?
I'm the most whiny opinionated person on the planet and even I find this stupid. Why would you care about what code looks like on other people's screens? If it works for them, it works for them. Christ. I hate this industry sometimes. There are serious problems and then there's people writing argument bait about ligatures.
He explicitly doesn't care what code looks like on other people's screens, as long as it stays there:
> I don’t care what you do in private. Although I predict you will eventually burn yourself on this hot mess, my main concern is typography that faces other human beings. So if you’re preparing your code for others to read—whether on screen or on paper—skip the ligatures.
Thank you. This guy is the equivalent of Richard in Silicon Valley when he tries to take the stairs three steps at a time to demonstrate how tabs are superior to spaces.
It's a strange claim - to say it's a terrible idea. I've been programming for over 20 years and I've been using a font with ligatures for nearly a year now. For me, personally, it increases legibility and clarity. I feel slightly stunted when I don't have them. I read other people's code with ligatures on just fine as well.
I also hate dark mode and small fonts, and I let my code run way past 120 chars per line when it's right to do so.
I couldn't possibly care how other developers read code. I want them to be able to read my code and so I try to code for clarity, but I can't imagine a font choice or many other IDE preferences affecting their ability to read the code I write.
I always felt it's slightly sad that we're stuck with only being able to type the ASCII symbols !"#$%&'()*+,.-./\:;<=>?@~|{} efficiently.
So languages that want to express more with different symbols find it difficult to do so with our limited set. You end up with combinations of symbols that look familiar to existing combination of symbols, and for those who find this problematic to read we have ligatures.
I might be imagining this but I think that I have seen ligatures on/off being used as a deliberate hint to convey the difference between read-only and editable code. That's a very nice tweak. InteliJ at least can be configured that way, might be a case where its Android Studio incarnation has different defaults.
I thought it was weird at first, but I grew to really enjoy the way they look. It isn't too difficult to figure out, because even if you don't use ligatures when you look at one you know right away it is an unusual symbol and you need to look at it a little closer to figure out what it is.
Also, if something doesn't turn red when you swap an = for a == then it's time to re-evaluate code coverage.
Edit: I should note that I mainly write C and C++. Other languages may make ligatures less pleasant
Functional considerations aside, there's definitely some personal issues with ligatures. Spacing in code is incredibly important for a lot of people. I'm dyslexic, so distinguishing between something like someValue=someOtherValue() and someValue->someOtherValue() adds additional unnecessary complexity compared to simply writing assignments with spacing (ie, someValue = someOtherValue()). This makes it significantly easier for me to interpret it at a glance.
That leads into my personal issue with ligatures: they change what should be a binary operation into a more complex one. Instead of "I see equals signs, one space or two?" it becomes "I need to stop, change to a vertical reading direction, and see if that's 2 or 3 lines" or "I need to estimate if that is 2 or 3 characters worth of width, or get off track comparing it to characters on the line above." Comparison operators should simply be "greater space equals" but become "wait, was there a second line there? I have to go back and double check that."
I'm sure someone will come along and say "how is reading the number of spaces different than reading the number of lines?" It might be that the spacing is normalized without ligatures, it might just be the vertical spacing in ligatures is too small, I don't really know. It's incredibly difficult to convey this to someone who doesn't experience it, all I can say is it is a night and day difference to me.
I've given Fira Code a shot 2 or 3 times but have found the ligatures to hinder my productivity every time. I also tried them just in the "reader mode" with Jetbrains Mono when that feature was first released, but had to turn it off after a few days.
That all being said, I won't fault anyone for using them if it helps them in the same way that not using them helps me. I'm just glad they can be disabled in Jetbrains Mono as it is otherwise an incredible font.
Interesting. A friend of mine is dyslexic and has expressed a strong preference for ligatured fonts for programming for the opposite reason. I guess the lesson is to leave people alone with their preferences...
> There are a lot of ways for a given sequence of characters, like !=, to end up in a source file. Depending on context, it doesn’t always mean the same thing.
While this is true, it doesn't seem to come up that often in practice. I'd say this appears when I'm viewing log files or something that isn't a programming language.
Surely the readers are reading the code in the font of their choosing. If they get miscued by ligatures, that's squarely on them, because they're the ones that chose to read it in a ligature font. That's the beauty of fonts - they can be very personal.
For me it depends on what’s being written. For the stuff I work with day to day (all very “boring”/mainstream languages) there’s no possibility of ligatures causing confusion, and I find them to be an enhancement in both aesthetics and readability.
I also think it would be interesting if a programming language used the Unicode characters that ligatures simulate rather than combinations of general purpose characters, but that seems unlikely given that it’d require a new programmer-oriented keyboard layout.
The "risk of error" is miniscule and trivial to figure when it does occur. The other 99.999% of the time the ease of reading and writing with them more than makes up for those 30 seconds of confusion every couple of weeks.
Hilarious enough, many of the people who claim ligatures are objectively harmful are also those using archaic tools like vim/emacs. The number of errors that could've been prevented by highly sophisticated IDEs instead of toy text editors from the 80s is surely orders of magnitude higher than the purely theoretical ligature confusion.
It's a very common logic operator across a multitude of languages. In what situation do you have that sequence of characters that isn't a logic operator?
Using Haskell is one such situation. Haskell's inequality operator is /= which someone could expect when they see ≠. Some people redefine != as a custom operator (see link), which can bring even more confusion with this ligatures.
I agree. The symbol combinations may have different meaning depending on where they appear. Replacing raw symbols with ligatures will create confusion.
I was using this font in Rider when JetBrains made it the default, but gave up after several months. The ligatures were giving me a pause still. The effect was opposite to ease of reading the code.
I tend to agree not because I think they often get the semantics wrong, but because it's an unnecessary translation operation my brain has to do. Why does my brain need to process two different ways of representing the same thing (one when typing, one when reading)?
Yes, there are some problems, like a double arrow to the left `<=` which is not the same as a 'less than or equal' or, to a lesser extend, 'less than -1', which can be written as `a<-1`, which is no arrow `a <- 1`.
I've witnessed curly quotes finding its way into html due to copy paste causing at least an hour of debugging.
So I can imagine when there are tools to prettify code for blogs this can become an issue for some languages.
While not entirely related to ligatures, my own biggest offender has been strange whitespace being treated as an identifier in LuaJIT. Mostly caused by my Norwegian keyboard layout producing strange whitespace when you want to write the not operator "~=" if you're not careful enough.
You can blame many parts here, LuaJIT for allowing this in the first place, editors lacking tools to deal with it or normalize pasted code, me for not using a us layout, me copy pasting code, or me not being careful enough.
Thankfully vscode will now highlight non standard whitespace with a yellow box. And best of all I've learned to be aware of these things when copy pasting code from the browser.
Ah, yes, my preference for how a couple of bytes of data in my text file end up getting mapped to a few dozen more bytes of data on my screen. That. That was the moment things went to far.
> And not because I’m a purist or a grump. (Some days, but not today.) Programming code has special semantic considerations. Ligatures in programming fonts are likely to either misrepresent the meaning of the code, or cause miscues among readers. So in the end, even if they’re cute, the risk of error isn’t worth it.
- Matthew Butterick, Ligatures in Programming Fonts: Hell No, https://practicaltypography.com/ligatures-in-programming-fon...