7 ms·
Ligatures in programming look cute, and maybe if you want to showcase a snippet of some particularly clever and elegant code, print it on some expensive paper w
by WesolyKubeczek 5y ago
Ligatures in programming look cute, and maybe if you want to showcase a snippet of some particularly clever and elegant code, print it on some expensive paper with tasteful palette (and none of your CMYK nonsense! Only pure pigments!), frame it, and hang it on the wall, I can see its appeal.
At work, I've tried it. I've tried hard to like it. I had to stop because Fira Code (and ligatured Iosevka) took the principle of the least astonishment, threw it on the concrete floor and kept beating it down till it stopped breathing, and then some.
I found myself spending time wondering "what characters is this made of?", and "how do I type THAT?" when viewing some existing code, and "WTF is this?" when a ligature that would have likely made sense in Ruby or Haskell (or in APL?) made it into my Perl code.
Also, "is this a ligature or some Unicode glyph?" was a question I found myself asking. In a better world, I shouldn't be wondering about it while fixing some integration with one of Intuit's molochs or somesuch. But here I was.
Switching to non-ligatured text shed a lot of cognitive burden off me. At least I can tell which thing is ASCII and how I type it. And my code doesn't look as a Guillome Apollinaire's calligramme.
- avgcorrection 5y ago> Also, "is this a ligature or some Unicode glyph?" was a question I found myself asking. In code editors that use monospaced fonts the ligatures will often look nicer since things like Unicode arrows will only take up a single “character space”.
- eyelidlessness 5y agoMany of these ligatured programming fonts look the same way, by shifting the combined characters horizontally into a single width space.
- WorldMaker 5y agoYeah, but that "single width character" is often still in the middle of two widths worth of space. In most environments that should still often be enough of a clue.
- eyelidlessness 5y agoIt wasn’t, for me, trying Fira and other ligatured fonts. The cognitive overload was too much, for no clear (again to me) benefit. I love well crafted typefaces, but decided this is a place where this particular craft wasn’t for me.
- WorldMaker 5y agoIt's a subtle clue still, but you pick up on it more and more with use, especially after cursoring through/deleting past the ligatures enough. It eventually becomes second nature. Of course, there's no reason to pick up those subtle clues/habits if you don't see a benefit to the ligatures in the first place. The benefits themselves are sometimes subtle, and I'm unlikely to convince you if you've already made up your mind on that. For what it is worth, I find that they improve readability (and per the Python maxim: code is read way more often than it is written), and they do catch subtle bugs sometimes. As one example, in Fira Code (and successors), the difference between the ligatures of == and === are quite noticeable and useful in JS programming. But yeah, mostly it's just for cleaner reading: math symbols and pretty arrows. If that doesn't appeal to you, it doesn't appeal to you.
- klyrs 5y agoThis is precisely my problem. I like monospaced fonts because a single character occupies a well-defined width. I do not like it when len('≡') == 3
- zerocrates 5y agoThough if you did it differently and the ligature was in a single-character width it would mess up alignment between users who are and aren't using the ligatures... probably a worse problem.
- klyrs 5y agoNo, that's what happens in some ligature fonts: '=', '<=' and '===' all render a single character wide. It messes up alignment and drives me up the wall
- pindab0ter 5y agoExcept no ligature font I’ve ever seen does that, because that’s a terrible idea and a mark against any specific font that does that, not against ligatures in general.
- avgcorrection 5y agoI don’t think code should be aligned to begin with.
- michaelcampbell 5y agoI tend to read horizontally and not vertically, so that hasn't been an issue for me. The column oriented code layouts I just find so eye-rolly but people like different things.
- zozbot234 5y agoUnicode includes "double width" characters as well.
- avgcorrection 5y agoI don’t understand the relevance.
- nitrogen 5y agoThe displayed width alone is not enough information to tell a ligature from a single character.
- avgcorrection 5y agoI was under the wrong impression that “double width” was only a property of some codepoints that were effectively double width variants of the printable ASCII symbols, for use in East Asian contexts. But now I see that there is a combining codepoint, so codepoints in general can be made “double width”. So this does indeed seem relevant.
- CRConrad 5y agoCheck boxes and stuff occupy about a character- width-and-a-half when pasted into Notepad++ set to use Lucida Monospace.
- michaelcampbell 5y ago> I found myself spending time wondering "what characters is this made of?", and "how do I type THAT?" when viewing some existing code, and "WTF is this?" when a ligature that would have likely made sense in Ruby or Haskell (or in APL?) made it into my Perl code. I guess everyone's got their thing, but on that paragraph I have to say my experience with ligature'd fonts in programming has led me to wonder the same thing... never. I don't say this over some love of them; I'm fickle and change fonts about quarterly; some with ligatures some not, but I can't think of a single instance of WTF or actual confusion.
- nitrogen 5y agoSymbol-dense languages and coding styles, especially those that differ from the mindset of the font designer, are probably more likely to trigger spurious ligatures.
- WorldMaker 5y agoYeah, I'd imagine Perl development is pretty much the exact worst case for programming font ligatures both as a code developer and a font developer (accidentally creating ligatures the font never intended to exist in strange runs of symbols). Especially in how much Perl development exists that treats spaces as rare/unnecessary/optional.
- Shorel 5y agoEven without ligatures, Perl code makes you say: "WTF is this?" more often than any other language I have tried.
- WorldMaker 5y agoA classic joke I've heard is that Perl is the closest to a "write only" programming language that has escaped into mainstream usage.
- skhm 5y agoI can't agree. I type up something in Fira Code - I look at it - and I smile inadvertently. It's just another one of the small, pleasant aesthetic experiences that make up programming as a whole for me.
- WesolyKubeczek 5y agoGood for you, I'm not saying my experience is a universal truth. But this is my experience. I love all things typography, and thought it was genuinely a good idea. Turned out it wasn't for me. But I'm glad it clicked for you.
- simooooo 5y ago
- TacticalCoder 5y ago> I found myself spending time wondering "what characters is this made of?" Funny sidenote: I've got my Emacs configured to show any non-ASCII char in source code in bold pink on a pure black background (including zero-width spacing chars). That way the non-ASCII chars do really standout and I rarely wonder "which char is this?". I don't forbid them: they do just really stand out. Most of the time the only Unicode chars in source file are anyways the copyright symbol and some chars in author's name (in comment). Sometimes in strings.
- mananaysiempre 5y agoThis works as long as those characters truly are a rarity and will probably become unbearable otherwise. For example, try opening some Agda code, or reading firmware or BSP code with Chinese comments (hello, ST Microelectronics), or some other ancient or internal code with non-Latin native-language comments (Japanese is pretty common, my native Russian can also be found in the wild occasionally). I’ve heard somewhere that Java’s support for Unicode identifiers was originally motivated not only by “oh shiny” (although I expect there’s a measure of that, too), but also by allowing the Japanese to write their code how they wanted it, and apparently did indeed help with capturing mindshare. Though, to be fair, I’ve never actually seen Java code with Japanese identifiers.
- a_e_k 5y agoInteresting. I just check for non-ascii on-demand with a tiny macro around occur (because I can never quite remember the regexp syntax for named character classes): (defun find-non-ascii () "Find and show all of the non-ascii characters." (interactive) (occur "[[:nonascii:]]"))
- ertian 5y agoI've had the same experience, with ligatures applying in languages they weren't designed for. It struck me that the font is a strange place to make the decision about what character combinations should be combined. Something like emacs' prettify-symbols-mode seems like a better approach: make the decision per-language. Of course, that's not nearly so simple to implement.
- Shorel 5y agoI had the opposite experience. In Sublime Text for some time, the C++ ligatures did not work. It is fixed now. By default, no ligatures are used.