14 ms·
Ligatures in programming fonts: hell no (2019)
- keybored 3y ago> They contradict Unicode. What? > The problem? Many of the programming ligatures shown above are easily confused with existing Unicode symbols. Oh. But that’s not a contradiction? Ligatures are just for display and don’t really interfere with Unicode. I don’t see how you could be confused, really, considering the state of the art. Widespread Unicode in programming languages are rare. You probably know if you are in the process of reading Haskell code (ASCII) or Agda (Unicode).
- cabirum 3y agoMuch ado about nothing. It's a matter of personal taste. An actual ≠ has a low chance to sneak into the source code, even lower chance to somehow type it by hand. Either way, it would be a syntax error highlighted by any editor. I'd like my code to look nice and I accept the risks.
- ggm 3y agoIt's probably fine for you reading your code. It's not impossible it causes others reading your code some confusion when they render it with ligatures or receive eg pdf of it in ligatures, distinct from how it looks when they edit it. Minor issue mostly. I tend to "no", but for no very good reason: Aesthetically they're lovely.
- threatofrain 3y agoOther people reading your code... on your laptop, using your editor? Because on anyone else's computer it's going to be based on their personal viewing preferences. Setting your tab spacing size too large will also make your code unreadable. But only on your computer.
- teo_zero 3y ago> Other people reading your code... on your laptop, using your editor? No, rather in your web page, in the slides that you're projecting, in the paper that you typeset into PDF... The point is not about how you edit your own code. You could even write comments in sanskrit, if they are for your eyes only, but please don't dostribute them!
- ggm 3y agoAs an aside, I have seen literate French perlcode some time ago that had very good French language comments alongside quite normal western variable and function naming, which I suspect was in everyone's interests.
- layer8 3y agoScreen sharing is a thing.
- kazinator 3y agoIt's only a matter of personal taste because it's not statistically examined, so there is no hard evidence in the form of numbers that the yea or nay side could use. If it were properly studied, and it turned out that ligatures have an effect on the rate of mistakes, then one side of the debate would have to concede that though they choose persist in their personal taste, it is in conflict with what is good for their work.
- mpweiher 3y ago> An actual ≠ has a low chance to sneak into the source code, Hmm...my programming language supports ≠ directly ... > even lower chance to somehow type it by hand. ... and my keyboard lets me type it (almost) directly, via Alt-=. I think the author is spot on in that the current state is not the correct end-state, though given path-dependencies it is understandable how we got here.
- toastal 3y agoI've witness many a question after/during technical slides where the audience was confused by symbols. At a bare minimum, don't use ligatures in slides or blog posts or anything meant for a broad audience. Ideally, languages would support Unicode as well so you can mean what you say when you type—some folks will naturally prefer this to “keyboard-compatible” options and this should be fine (though ask many non-Anglophone users where the `$` key is and they won't be able to tell you). With Vim digraphs, Kitty unicode input, extra layers on a keyboard… there are many ways to tackle the ‘input hard’ problem. A good example of this is Dhall where Unicode is optional, but could be enforced with a built-in formatter option.
- JoshTriplett 3y agoThe initial presentation of Kotlin at Google I/O used fonts with ligatures. As a result, many people in the audience were confused about what the actual syntax of the language was.
- jeroenhd 3y agoI've personally never heard of anyone having a problem with my ligature preferences (other than "they're weird"). People know ≠ and != mean the same thing. But a presentation introducing syntax? That's just silly. I can't believe someone would get that wrong.
- petesergeant 3y ago> At a bare minimum, don't use ligatures in slides or blog posts or anything meant for a broad audience This seems a much more reasonable take
- throwawaymaths 3y ago> slides or blog posts or anything meant for a broad audience. Or if you're screensharing while pairing, or if a coworker is looking over your shoulder when you're sharing something, or...
- toastal 3y ago
- galkk 3y agoThere was one occasion when, by some unknown reason, >= rendered as > for me in browser. You increase/decrease font size and everything was ok, but I was extremely confused when colleague sent me a screenshot when after I commented in code review. Also there were issues with formatting of ligatures of some fonts in kitty terminal. Other than that, ligatures are great and I will never turn them off.
- dang 3y agoRelated: Ligatures in programming fonts: hell no (2019) - https://news.ycombinator.com/item?id=29637876 https://news.ycombinator.com/item?id=29637876 - Dec 2021 (195 comments) Ligatures in Programming Fonts: Hell No - https://news.ycombinator.com/item?id=19805053 https://news.ycombinator.com/item?id=19805053 - May 2019 (86 comments) Ligatures in programming fonts - https://news.ycombinator.com/item?id=14830797 https://news.ycombinator.com/item?id=14830797 - July 2017 (82 comments)
- nicbou 3y agoPractical Typography is a really good website that is worth reading end to end. It's exactly what the name says: a short, straightforward introduction to typography for practical use.
- fileeditview 3y agoLink: https://practicaltypography.com/ https://practicaltypography.com/
- grzm 3y agoThis submission itself is hosted at practicaltypography.com (https://practicaltypography.com/ligatures-in-programming-fonts-hell-no.html https://practicaltypography.com/ligatures-in-programming-fon...)
- hinkley 3y agoI gotta say I’m a little tired of using * for multiplication. It’s time for programming languages that use Unicode characters for operators, and let the editor replace != with the Unicode slashed equals character. No ligatures, just operators.
- nikolay 3y agoYes, terminals today even support emojis!
- Animats 3y agoThere are really two separate issues here - ligatures in the classic typographic sense, such as æ, and having some way to type mathematical symbols useful in programming, such as ≠ and ⨯, without having cntl-alt-meta-super keyboard combos to remember. The former doesn't help in programming. The latter is fairly standard for ideographic languages, and has been well worked out for Chinese and Japanese.
- midchildan 3y ago> has been well worked out for Chinese and Japanese. Not really. Typing CJK text is a tedious and frustrating experience. People cope with it because no one has come up with a better alternative. Both Chinese and Japanese alphabets have way too many characters to fit on a keyboard. To deal with this, CJK users type in the English spelling and convert it to CJK characters using software called input method editors (IMEs). The problem is, this conversion process is often not straightforward. Unlike English, CJK sentences don't have spaces in them so IMEs have to guess how to split sentences into words. Then, it has to identify the right words, which is complicated due to the existence of homophones. To deal with all the ambiguity involved in this conversion process, IMEs rely on predictions to provide users with a list of possible conversion candidates. This leads to an awful typing experience in which users have to constantly choose from the IME-provided list for every little snippet of text. This is distracting, slows down typing, and makes key presses non-deterministic. To make matters worse, IMEs sometimes get things wrong and users have to get "creative" to work around it. In comparison, typing English text is a breeze. You can just type what you want directly.
- woolion 3y agoI have absolutely no idea how many people might share print screens of their code, and how often some beast looking at these images might, because of that, find a way to discover how to type a similar looking symbol in unicode, enter it in their editor, and compile it without error, therefore introducing a subtle bug. Luckily I rarely share my code through pdf, but mostly through git. Therefore, that hypothetical beast will read the code through its own editor, so the risk is mostly avoided. There is still the risk that this beast might appear behind my shoulders, see the pretty symbols and start that process anyway, but I have no idea how often that might happen too. It's a weird thing that this beast can do such an elaborate process, but not ask a question about what the symbols are. For better arguments, there's a long history of problems with programming languages that use non-ASCII symbols as default, and it has been considered a mistake. That crazy idea of 'letters' that look alike and thus introduce bugs is much worse with unicode than ligatures: >>> a = "hello world" >>> b = "hеllо wоrld" >>> a == b False Example from "Unicode text spoofer": >This browser-based utility fakes regular characters in text and replaces them with Unicode characters from other alphabets. The text that you paste or enter in the input text area automatically gets all possible characters replaced with Unicode homoglyphs in the output. You can spoof letters, punctuation marks, spaces, and even insert zero-width spaces between individual symbols. Now imagine instead of doing this, you use hello_world as variable name. You can thus interleave use of different variables that look alike, and have really buggy code. Last argument, which is the one most important to me. Typing <= or != is ugly as shit. That is not how these symbols are supposed to look like, it's just a practical kludge. Ligatures are a simple solution to have both, that do not require a revolutionary way to change programming languages, and only engage yourself. To share print screens of code without ligature maybe configure a second editor with another font. That does not sound really hard...
- eviks 3y agoYou don't kill good design just because it can be misused, you improve tooling design to deal with misuse For example, the text spoofer issue can be resolved in the text tools, like having variables with different names can be colored differently (this coloring scheme is better than having color just denote variable even without spoofing as it allows you to catch typos easily) Also you can have zero-width spaces highlighted
- eternityforest 3y agoThe ones that just look like regular code with fine tuned spacing are nice. The rest are terrible. Especially if you don't have a math background. If you come from coding, the symbols are meaningless new inventions. To me, >= IS exactly the right symbol. It's the one I learned, the one I actually encounter in daily life, anything else looks like a math paper, not code. Even emoji aren't the best if you didn't type them explicitly. :) is mostly similar to although not exactly the same, but :P is definitely nothing like any of . Edit: apparently emoji don't work here again? I thought they added them?
- awestroke 3y agoI like them. You just have to get used to them, and before you know it you don't even notice it's a ligature instead of multiple characters
- rcarmo 3y agoI don’t agree. I find that ligatures in Fira Code make it rather more pleasant to read contrived pieces of JavaScript (I’m looking at you, “===“). But to each his own.
- jeroenhd 3y ago=== and !== are definitely the main reason I tried out ligatures in the first place. The author has hidden their point all the way at the end of the article, though. They're mostly talking about sharing code, such as in screenshots, printed works, slides, etc. People who don't know fonts commonly use ligatures (plenty of fonts that mess with fi or other commonly custom kerned characters) so they don't realise I'm not actually using the ≠ or ≥ characters in my code.
- chenxiaolong 3y agoI don't mind the look of ligatures too much in most monospace fonts that have them. However, I use my editor and terminal emulator for a lot more than just editing source code in common programming languages. In every single ligature-supporting font I've tried, there are edge cases where glyphs are combined in a way that don't make sense in context, which is jarring enough to not be worth it for me.
- omnimus 3y agoBecause they are intended to be a tool for typesetters to use in right scenarios - or in your case turn off in wrong ones. In text editors you can only go all in or not. It is not really intended for that.
- zokier 3y ago> In text editors you can only go all in or not. I don't think that needs to be the case. Text editors already do syntax highlighting, and if using treesitter they have accurate understanding of the syntax. So there isn't major blockers for applying ligatures selectively based on syntax.
- omnimus 3y agoIt might be possible in code because it's more constrained enviroment but well it hasn't been solved in general typesetting. The rules are very hard to hardcode because it is subjective and often requires broad context (like understanding line above or what you do with names). Thats why it has been always done by humans if you want good results. And its not like smart people havent tried (like Knuth for example).
- bobogei81123 3y ago> “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... I've been using programming fonts with ligatures for years. I had wasted several hours because of those stupid bugs when I mixed up O and 0, - and _, but ligatures never caused me any problem. It is obvious when they are there, and you rarely see non-ascii characters when programming (unless you are writing Lean).
- FridgeSeal 3y ago> Whereas ligatures are going the opposite direction: making distinct characters appear to be others. Yes. On my computer. In my editor. That I am using…because I like ligatures, because they make my code easier to read. For me. Use of ligatures on my setup does not force anyone else to use them? They’re not “viral” like a language feature. “Oh but what if the >= Unicode symbol ends up in your source code and you don’t notice because you’re using ligatures?” Is this the most contrived issue ever? Yeah and what if someone runs “find and replace” using Unicode confusables on my codebase? That’s arguably worse and requires no special font features. Plus I suspect most programming languages would throw an error immediately if you used the >= symbol instead of the pair. If you don’t like ligatures, that’s fine, but there are those of us that do, and our font preference isn’t a threat to you.
- grzm 3y ago> Yes. On my computer. In my editor. That I am using…because I like ligatures, because they make my code easier to read. For me. Later in the submission, Butterick addresses this directly, and doesn't disagree: > “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. So if you’re preparing your code for others to read—whether on screen or on paper—skip the ligatures.
- hakre 3y agoThat's a good advice, isn't it? Thanks for pointing to it. But it is interesting still, how many seem to read the text it feels to them touching their privates and need to make themselves vent off.
- grzm 3y ago> how many seem to read the text it feels to them touching their privates and need to make themselves vent off. Not dissimilar to those choosing to highlight the worst aspects of comments rather than addressing them in good faith. Please don't make things worse.
- teo_zero 3y ago> when triplicate would get ligatures, Powerline characters, and so on. Answer, as nicely as possible: never. Undoubtedly he made an argument for ligatures, but why are Powerline characters in the same basket?
- hakre 3y agoIt's a bit ouf of context, the whole sentence is: > The other inspiration for this piece were the people who repeatedly asked me when Triplicate would get ligatures, Powerline characters, and so on. Answer, as nicely as possible: never. So the answer is, for the same argument. Not going to happen with that typeface, by the authors design.
- its-summertime 3y ago(1) exists regardless of ligatures, (2) context is super easy to apply, an editor can very reasonably enable or disable ligatures depending on where they are in the code: sublime text does this already
- kazinator 3y ago> For instance, the example below is from Kent Dybvig, The Scheme Programming Language, 4th ed. In this chunk of Scheme code, the opening-quote marks are supposed to be backticks; the closing-quote mark is supposed to be a single straight quote: Sorry, as a Lisp person, I don't see the problem. In Dybvig's typography, it's evident that an opening quote which looks like a 6 is the quasi-quoting backquote, and the closing quote is the regular quote. It is legitimate for the apostrophe to appear as either a vertical tick or a 9 shape: https://en.wikipedia.org/wiki/Apostrophe https://en.wikipedia.org/wiki/Apostrophe Particularly this section: https://en.wikipedia.org/wiki/Apostrophe#Typographic_form https://en.wikipedia.org/wiki/Apostrophe#Typographic_form Evidently, the 9 shape is the "typographic form" whereas the straight tick is "typewriter". The last paragraph of that section claims that this was a simplification for typewriters so that the glyph could fulfill multiple roles at the same time (including, possibly, simulating an exclamation mark, if overlaid over a period!) In the USASCII system, there is only one character code for this, so in a given font, you get only one or the other. In a font where the ' character looks like a 9, you want ` to look like a 6. Or else if ' looks like a vertical stroke, then ` looks like a backward-slanted stroke of a size which harmonizes with that one. It looks like the printed version of Dyvbig's book has a font which is typewriter-like, but uses the typographic form for these glyphs (thus undoing the hack that was perpetrated for the sake of typewriters). It's quite readable; there is no mistaking the forward tick for the backtick. I now want a programming font which has those.
- deleted 3y ago[deleted]
- keyle 3y agoI think it's deeply personal and some fonts just do it better than others. I tried for a while and it had pros and cons. Unfortunately it made me be confused one time too many so I reverted to not using ligatures. Point is, find what works for you, we don't have to debate about this, and thankfully, we don't commit that stuff so that it becomes flame wars like tabs and spaces.
- renewiltord 3y agoSomewhere out there there's a surgeon talking about whether or not you should monogram your scalpel. I wonder what his blog looks like.
- pedroma 3y agoCounterargument: Using ligatures will reveal when others are using wrong Unicode symbols and sneaking them into the codebase. "Huh? Why isn't this >= rendering as ligature?"
- thxg 3y agoLigatures are an interesting contrast to Julia programmers' habit of using actual (non-Latin) Unicode characters in their code. It seemed to me that the use of Greek letters and symbols is actively encouraged in the Julia documentation. I think they advise using editors that allow inputting special characters through their LaTeX equivalent (but source files are then saved to disk with the Unicode characters). I am not very familiar with the latest trends, could anyone else chime in here? Do Julia coders use fonts with ligatures? That could indeed be one case where confusion is possible. Or maybe not?
- grzm 3y agoI'm not familiar with Julia, but I think a useful distinction can be made between input methods and ligatures. An input method is what you have to type to get a particular "code point" or character. Japanese, for example, is often typed using a latin keyboard, and as latin characters are typed, the application substitutes the appropriate Japanese character code point. For example, if I type the characters "n" (U+006E) and "i" (U+0069) using a Japanese input method, a に (U+306B HIRAGANA LETTER NI) (or 二 U+4E8C CJK UNIFIED IDEOGRAPH-4E8C or ニ U+30CB KATAKANA LETTER NI, or others as the case may be) can be selected to be entered. The actual character bytes will be substituted. You typed "n" and "i" but what gets stored is U+306B. This is in contrast to ligatures: say if there's a fi ligature, I type "<" "=", and the "≤" character is substituted during rendering, but the individual characters are still the "character string". (You could also choose to directly insert the "≤" character directly, and that would then be a single code point, but I think for the purposes of this discussion, people are mostly talking about cases such as when the character string "<=" is rendered as "≤". If Julia (like APL) uses characters outside the ASCII range as syntax, I suspect that there are input methods to assist in entering them as opposed to ligatures representing them on screen. But that's just naïve supposition on my part. Another interesting case is TLA+ [1], where the language shares some LaTeX operators which can be rendered for display. [1]: https://lamport.azurewebsites.net/tla/tla.html https://lamport.azurewebsites.net/tla/tla.html
- sundarurfriend 3y agoA lot of Julia folks use the JuliaMono font, which has a minimal set of ligatures: https://juliamono.netlify.app/#contextual_alternates https://juliamono.netlify.app/#contextual_alternates (just above this segment, they mention this very article as something they agree with). I personally don't like any ligatures, especially when people use them in presentations to public like the article mentions. Confusion between operators is rare, but possible, for eg. when using Catalyst (https://docs.sciml.ai/Catalyst/stable/catalyst_functionality/dsl_description/#Arrow-variants https://docs.sciml.ai/Catalyst/stable/catalyst_functionality...). > It seemed to me that the use of Greek letters and symbols is actively encouraged in the Julia documentation. I don't remember getting that sense from the docs, but I may be wrong. The general convention is that Unicode at the level of user code is fine, and a lot of the community (including me) likes it because it makes it much closer to the actual equations and scientific notation we're working with. For libraries, it's strongly encouraged to have ASCII equivalents for any Unicode operators, keywords, etc. that you expose, and all the major libraries do this. The same is true in base Julia as well, every non-ASCII Unicode name has an ASCII equivalent too.
- ketzu 3y ago> if you’re preparing your code for others to read—whether on screen or on paper—skip the ligatures. The article should have led with this. Instead this main caveat is buried in a paragraph, where it is preceded by, what boils down to, "do what you want, but you will recognize its wrong someday." Of course people will focus on that part and on the most prevalent use of ligatures in programming: In their own local editor. (Where people usually have strong opinions about what's the right thing to do.) The tangent in (1) on how they contradict unicode could have been skipped as well, just go straight to the "the problem is" part. Why? Unicode already "contradicts" itself: △ is WHITE UP-POINTING TRIANGLE (trine) or U+25B3, which I am sure everyone can easily distinguish from the mentioned Δ Greek Capital Letter Delta U+0394 especially when used outside a clear context. (There are other symbols that are easier confused, but I find them close enough for the point, especially because fonts might render them differently.) For private use, I find ligatures make spotting negations and reading comparisons easier more often than they are wrong. But I see why ligatures might not be a good choice for a presentation or code blocks on a website.
- Fatnino 3y agoVscode highlights characters that might be confused for other characters if you use anything other than the common variant. I'm not sure if this is default behavior or something I did to it over the years. I can see it being helpful but it feels way too trigger happy. It's always notifying me about Hebrew letters that only look similar to other things if you take off your glasses, squint, and change the font.
- 3836293648 3y agoYou don't even have to go as far as a triangle. There are two sets of the latin alphabet in unicode and two sets of the greek. The normal one and the maths one. And the mu on your keyboard is not the same on a windows machine and a linux machine. (Alt Gr + m, at least in my language)
- hakre 3y agoFor portable code, use UTF-8 only, and only the part in ASCII. This also helps to distinguish digits from alphas etc. Unicode is a different code. (and as I learned today, Julia code might be exclusive here)
- TonyStr 3y ago[dead]
- rswail 3y agoJust reading all of this (I haven't used ligatures when coding), but the confusion between a ligature of >= and the Unicode ≥ (U+2265) could be handled by the language parser accepting either to mean "greater than or equal to". Would moving beyond ASCII be that much of a stretch for modern languages?
- pwdisswordfishc 3y agoI can’t wait for a programming language that considers the strings ">=" and "≥" to be equal.
- eloisius 3y agoMost modern languages already use Unicode for variable names and such. But why would you want to type a Unicode lte/gte character? I’m sure it’s not that hard on a Mac keyboard, but can’t be easier than <=
- xigoi 3y agoBecause readability is more important than writeability.
- eviks 3y agoOf course it can be easier since <= are a shifted char and a very far pinky char. Yes, you'd have to use a keyboard remapping tool to make it easier And the most basic reason is because a dedicated symbol looks much better (and doesn't break vertical alignment since it's one glyph)
- frou_dh 3y agoIn practical terms, the big sin is using them in the web documentation of languages and libraries (which is public reference material and should reflect the reality of the syntax). All this debate about individuals and their text editor setups is inconsequential compared to that.
- LunicLynx 3y agoLove them. Next
- deleted 3y ago[deleted]
- eviks 3y ago> Many of the programming ligatures shown above are easily confused with existing Unicode symbols. That's just silly, the reason there are ligatures is precisely because all these programming languages are poorly designed not to allow using the proper ≠ instead !=, but then this is also why there is no ambiguity - your editor would highlight the real ≠ as a syntax error
- ranting-moth 3y ago[flagged]
- pyrale 3y agoI happen to be of the same opinion as the author, but their reasons are not very compelling. Unicode is an encoding tool, fonts are a display tool. And just because the right symbol happens to be available in unicode doesn't mean it's right or easy to use it in every context ; especially when writing a compiler or when writing code. Who wants to have to write ≠ in their code dozens of time a day, without a keyboard made for this? Fonts exist just for that: decide what the encoded text you have should look like. They are not competing with encoding, they're complementing it. Different fonts exist because people have different opinions about what's best for them to read. The second point that is raised is a matter of tradeoffs and personal taste. If someone feels like seeing ≠ instead of /= or != in a given context is worth a surprise once a year, who am I to say they're wrong? It's not like I have to use their font, or like they can't use different fonts for different situations.
- _V_ 3y agoA page that does not load any content with disabled JavaScript: hell no I mean am I the only one that is browsing with completely disabled JS by default? :-D More and more sites don't load anything withnout a JS and I'm not talking about advanced apps like Microsoft Office online...
- sundarurfriend 3y agoThere are dozens of us! Dozens! But it's sadly true that more and more pages don't load anything if you have JS disabled. Often, the answer to "is this worth disabling JS for" is no.
- 2b3a51 3y agoAnd yet the page renders text fine in both lynx and links in the terminal. I've noticed that with a few of these 'no javascript means no content in Firefox' Web sites.
- _V_ 3y agoI hope that there will be more and more of us :-) Usually when I get empty page I just close the tab and move on. Very rarely the content is so unique and in general worth the hassle anyway. The thing is that you enable JS and it will load bunch of trackers and cookie popups and GDPR popups etc... I just hate that.
- Aeolun 3y ago> I mean am I the only one that is browsing with completely disabled JS by default? :-D I have no patience for that. There’s enough frustration in my life without inflicting more on myself.
- _V_ 3y agoThe problem is that pages today are waaay too bloated and they use JS to download a bunch of unnecessary crap such as various trackers and "analytics" etc. And with the WebAssembly there is even more tracking the page can do (no thanks!). When I disable JS globally, I genuinely get faster experience on most of the pages.
- alpaca128 3y ago> The problem? Many of the programming ligatures shown above are easily confused with existing Unicode symbols. How so? It's either a ligature or a syntax error: weird unicode symbols can't be valid operators and operator ligatures cannot be valid identifiers. The exception would be string literals, though that situation would be quite rare - probably less common than ambiguity due to different but similar-looking unicode characters. Though I agree it mostly makes sense in one's own editor, not when sharing the code. Meanwhile people don't mind at all that their code may contain invisible characters with variable length that can make cursor movement less predictable and cause syntax errors - tabs.
- chrisweekly 3y agoI agree the "confused w Unicode symbols" arg is pretty weak. As for "people don't mind [tabs] at all", some people mind very much and consider them pollution. If you mean _some_ people don't mind tabs, ie you're highlighting that tabs vs spaces is a bigger deal than ligatures, I concur. The logical reason to prefer spaces is that the choice is not "spaces vs tabs", it's "spaces vs (tabs and spaces)", and that mix of (tabs and spaces) is highly problematic.
- alpaca128 3y ago> If you mean _some_ people don't mind tabs, ie you're highlighting that tabs vs spaces is a bigger deal than ligatures, I concur. Yes, contrary to spaces/tabs ligatures only affect how it is displayed on screen, letting everyone choose how they want it without any drawback or inconsistency. Which is why I find the other argument in the link a bit unconvincing too - most code isn't shared in static screenshots, though I'll agree when it comes to books.
- veidr 3y agoI initially had this same reaction. Well, perhaps less stridently assembled, but my initial take on it was the same: that ligatures for coding fonts were objectively dumb. But, I was wrong. In several years of using them now, there has never been even one case of the theoretical "mistaking a different glyph that looks similar to the ligature" or "mistaking a ligature character sequence for a single character". It's never happened to me, and I have never heard of it happening to anybody else that I know either. If you have a U+2260 in your code, and that's not valid in your programming language but your editor isn't flagging it as an error, then you have way bigger problems than ligatures. On the flip side, though, it has absolutely made it easier for me to scan and read my own code, and the code of other people. So what I initially thought was "all downside, no upside" turned out to be quite the reverse. Note the "for me" qualifier, though; I get that not everybody benefits in these ways. YMMV. I like speed metal, avocado toast, ligatures, and Allman brace style. You may not like these things. But only that last one has any effect on others. If I insist on using my favorite brace style, sure that's annoying if you have to regularly work with my code and you prefer one of the incorrect brace styles like K&R. But ligatures don't affect you; they just make my life better. Therefore, it's not a topic worthy of controversy, or of trying to tell other people whether or not they should be using them.
- scotty79 3y ago> Allman brace style If only that could be as easily configurable in IDE as liatures.
- veidr 3y agoIndeed. I think we’ve gotten a lot closer in the past few years though (after wanting this for almost 20 years without progress). Rust’s language service (optionally) adds phantom code to several modern editors, showing inferred types in the editor, that aren’t really part of the source code. That is very nearly the same thing...
- wffurr 3y agoMy takeaway from this article is that I want to go try Fira Code now.
- nxpnsv 3y agoGoose from a feather. I use them all the time, it looks a litte prettier, and I can’t think of a single problem they caused me. If i somehow use the wrong symbols my language server, linter, tests, etc would yell
- the-pellmeister 3y ago> ... 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. With all due respect, am I the only one expecting a strong argument for why ligatures on my own personal machine's terminal emulator should go? I think "code for others to read" having to be free of ligatures was never in dispute at all. Unfortunately, the most significant reason isn't even mentioned: people's lack of awareness of the existence of programmer font ligatures. In clear terms: a confusion between != and ≠ does NOT exist for people who don't know of the existence of ligatures: they'll straight up believe they're looking at a ≠. (* if not slightly put off by the spacing around the character). The one thing I did take away from this, is that people using Polacode/CodeSnap and the likes, should probably be aware to disable ligatures before exporting their pictures.
- deleted 3y ago[deleted]
- TallGuyShort 3y agoNot technically ligatures, but the author does touch on quote marks. I see a lot of website engines swap " out for “ and ” in code snippets and it's annoying if you copy / paste a line. Especially if it's for a language with loose syntax like shell script that doesn't catch it while parsing.
- cosmotic 3y agoMS Word has this feature and it calls them "Smart Quotes"
- valcron1000 3y agoI've never had the issue of mistaking a Unicode character with a ligature, specially when using Mono fonts: a ligature will be 2+ characters width while a single Unicode character will only take 1.
- virtualritz 3y agoRefute of point one: these are substituted for display only. It does not matter if they clash with an actual Unicode code point Why? This brings us to refute of point two: lack of semantic substitution is a hypothetical problem (it could easily be solved though by parsing the source before substituting). But here is the refute: how often do I come across this? And how, exactly, could I shoot myself in the foot with it? The author omits answering that question. I studied typography alongside CS and worked in the former field for years so I have strong opinions on use of type for stuff other people look at. My editor is, however, something only I look at. I use code-type fonts with ligatures since years in various editors (vscode the last four), writing mainly Rust. I never ran into either issue one or two.
- jpease 3y agoAre people committing and deploying screen captures of their code?
- 206lol 3y ago[dead]
- skrebbel 3y agoLigatures in code is choosing form over function. It’s like a rectangular sink with sharp edges that’s hard to clean. It’s like writing javascript without semicolons: yes, it’s prettier, but you gotta keep yet another set of rules and exceptions in mind to get it right. For example, a JS regex like /=foo/ combines the /= into a ligature in Fira Code with default settings. That’s just confusing right? The / is a delimiter and the = is part of the regex itself. It means you need to keep like 0.5% of brainspace available for “reverse parsing” the ligatures on your head. Why waste that? Why spend even a tiny fraction of your mind worrying if you saw that thing right?
- seanmcdirmid 3y agoFor any language that uses / as a delimiter, well, you probably don’t want to use a font that does something special to /=. Rendering should also avoid using ligatures in quotes (strings, where reflex might be used in Java or Kotlin). I see ligatures as potentially good, but not unless they are integrated into the language’s lever rather than provided directly by a font.
- gibspaulding 3y agoThis reminds me of a struggle I've run into lately. Can anyone recommend a convenient way to identify an individual Unicode character or string of characters? Ideally I'd like to be able to e.g. highlight one of these weird ligatures, or a whitespace that I want to identify, or an emoji my font doesn't support and select something like "identity this character" from the context menu to see what symbol or series of symbols I'm actually looking at.
- unhammer 3y agoOpen in Emacs, hit `control+h` then `c` with your cursor on the character, it'll show everything you want and more: https://i.imgur.com/X8xp1WS.gif https://i.imgur.com/X8xp1WS.gif (also shows the decomposition of composed characters so you can discern ä vs ä and emoji combinations)
- kps 3y agoA context menu operation will be platform-specific, and I don't think you mentioned your platform(s). On MacOS, I used to use https://earthlingsoft.net/UnicodeChecker/ https://earthlingsoft.net/UnicodeChecker/ (which also does HTML entities). If you're OK with a command line tool, I just finished updating and finally publishing a Python script I wrote for that purpose around 15 years ago: https://pypi.org/project/unicode-name-inquiry/ https://pypi.org/project/unicode-name-inquiry/ Lots of options, but default usage is, for example: $ uni ≥ ≥ U+2265 GREATER-THAN OR EQUAL TO (It doesn't currently do the string-of-symbols case, because it tries to interpret strings as some other character identifier, e.g. `uni tilde` or `uni 8805`, but that sounds like a reasonable option to add.) Typically, people just search for the character on the web and land on one of the many ‘monetized code charts’.
- gibspaulding 3y agoUnfortunately where this typically comes up is at work where I'm stuck on Windows, but I'll check out your python script! I've been teaching myself python on the side in order to automate parts of my job so it would be neat to see it used here.
- mberning 3y agoThat www one is a true abomination.
- deleted 3y ago[deleted]
- pc86 3y agoIt's interesting that the author is complaining about the readability/usability of ligatures while their site has horrible linking usability. Tiny red superscript circle with zero indication of what text is linking and what size the clickable area of the link is.
- bombcar 3y agoAs is painfully common on typesetters’ work when done “online” as they seem unable to bend the rules for ease of use in a digital world.
- taeric 3y agoKind of surprised not to see literate programming mentioned. It takes the opposite view and specifically changes some symbols for print. And I don't think I've ever seen anyone cite that as a complaint.
- wwarner 3y agoI changed my mind on this one. As long as the text editor is not introducing its own transformations (as wysiwig editors do), then it's alright with me for programmers to use as many unicode characters as they want. In other words, as long as I'm confident that the function I'm reading is exactly what was committed and what will be compiled, it's fine with me that programmers expand the charset.
- nick__m 3y agoIs there a way to add programming ligatures to an existing font, similar to how Nerd Font patches existing fonts to add useful terminal glyphs like the Powerline symbols¹? I would love to have a ligatured version of that font https://github.com/rbanffy/3270font https://github.com/rbanffy/3270font 1) the last sentence of the article implies that the author of the article abhor them as much as programming ligatures. I don't understand why but preference in taste, color, esthetic are not objective, nor absolute, so I am not the one to judge him.
- hackan 3y agoI couldn't agree more! The first time I was faced w/ FiraCode, I was like "WTF is this!?". I tried using it, and lost my mind on the way... Well, I'm exaggerating a bit, but it was really uncomfortable... For me, its Mononoki all the way, or JetBrainsMono is not bad, too.
- matiasfernandez 3y agoI got some banana bread at work today. Hell yeah. So it goes to show that waiting for things is, like, worth it. But there's a lot of bad things in this world, dude. Like fucking skunks, dude. HELL NO. Scratching your eye, but it's still fucking itchy. HELL NO. The fucking Cubs, dude. HELL NO! Fucking ligatures in fucking programming fonts, dude. HELL! NO! BUT BANANA BREAD, ON FUCKING WORK, DUDE! HELL YEAH! HELL YEAH, BRO!
- deleted 3y ago[deleted]
- helmsb 3y agoSuch a bizarre take. It would be much easier to state something like: If you’re printing code for others to read, stick to standard characters. If you’re choosing a font for your editor, do what you want. I really like ligature fonts. I was an early adopter of Fira Code and later moved to JetBrains Mono. I like it because I find it’s much easier to skim and understand the intent vs a standard character representation. At the end of the day, it’s your editor, do what you want.
- ttepasse 3y agoSomething I’d like are soft programming ligatures, a concept I just invented: Ligatures which are ligatures and thus show that the unit is a semantic unit, but displays a minimal visual break in-between, showing that there are two code points underneath. Similar to the classic fi ligature which doesn’t make a complete new glyph, but arranges the glyphs for f and i in a more pleasing manner. For programming ligatures that would mean that "===" doesn’t give "≡" but more something like "⩶". I’m approximating with mathematical unicode characters here, the real thing would of course have a width of 2 or 3ch.
- sparkie 3y agoThese exist and are part of the fonts the article is talking about, though I've not seen it done for `==` because there's already a gap there. The ligatures for `==` in these fonts usually combine them to remove the space, but keeping it as two distinct characters. In JuliaMono/Fira Code, if you sequence `::`, the left colon in shifted slightly to the right and the right colon is shifted slightly to the left and both are scaled down slightly vertically. Try ::, :=, --, #!, ``, !!, ;; using Fira Code: https://www.programmingfonts.org/#firacode https://www.programmingfonts.org/#firacode These fonts can contain optional features which can be enabled/disabled dynamically by supporting editors. You could customize the behavior for specific languages and have the editor only show those features when you have the relevant language file loaded.