Live data from Hacker News

Ligatures in programming fonts: hell no (2019)

practicaltypography.com

191–200 of 201 posts

Re: Ligatures in programming fonts: hell no (2019)

#191
Such 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.

Re: Ligatures in programming fonts: hell no (2019)

#192
Something 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.

Re: Ligatures in programming fonts: hell no (2019)

#193

Something 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 t…

These 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

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.

Re: Ligatures in programming fonts: hell no (2019)

#194
post #131

Earlier quoted context omitted.

Whatever font you prefer in the terminal, Julia Mono is an excellent fallback due to its high symbol coverage.

You know what, I'd tried JuliaMono in my editor (gVim) and for some reason didn't like it there, but making it my console font makes my terminal look so much better. Thanks for the recommendation.

It's definitely a slightly quirky font. It took me a bit to decide that I like it, but after a bit, I've gotten pretty used to it and it has become my default mono font.

Re: Ligatures in programming fonts: hell no (2019)

#195

Earlier quoted context omitted.

A Compose key is the best general-purpose way. For example: • ≥: Compose > = • ≠: Compose / = You can define your own sequences too, if you want. I like to type exactly what I mean, including curly quotes and dashes and narrow no-break spaces and emoji and so on, but often didn’t like the default mappings (if there were any). As an example, I use this for curly quotes (look at the keys’ locations on the keyboard to u…

Fun but I tend to type code fast . Really dont need an extra modifier key. Not to mention there isnt one on your regular keyboard.

"regular" keyboards are really crappy anyways. With half-decent one, like qmk/zmk based, you can macro and layer the keyboard to be really effective.

Re: Ligatures in programming fonts: hell no (2019)

#196
post #189
post #67

Earlier quoted context omitted.

You 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 high…

> having variables with different names can be colored differently This, too, is entirely personal preference. I've tried it and found it resulted in too many colors for my brain to assign individual meanings to, and then I couldn't even benefit from syntax highlighting anymore because those colors also blended into the rainbow of text.

> entirely personal preference

The differentiation benefit is not. Personal preference is what tool you choose to deal with spoofing, eg, you could also use a different font for different symbol ranges instead of colors.

> I've tried it and found it resulted in too many colors for my brain to assign individual meanings to

Well, you don't assign individual meaning to individual colors, but to color ranges which a given type can vary over. For example, going from green to yellow could be the range for variable names, so you associate that range with variables

Which color ranges have you tried?

Re: Ligatures in programming fonts: hell no (2019)

#197
post #9

I 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.

So now you have: - A character harder to type - The same potential confusion - Code bases with both operators Maybe programmers just need to know that ligatures exists. If you are programming in Java or Kotlin you know that intelliJ tend to use it. Of course, if you have code, coping it to an ide with ligatures disabled will be rendered there old way just add it will use your preferred font or color highlighting sche…

No you don’t have a code base with both operators. Either the editor catches it, or you transform the data at commit time, the same with other code formatters. This isn’t a new idea I’m presenting, just a new wrinkle on a very old one.

Re: Ligatures in programming fonts: hell no (2019)

#198
post #170

Earlier quoted context omitted.

Fixed width is what monospace is intended for and ligatures maintain that feature. Nobody would use them if they caused code typesetting issues.

Whether that is considered an issue or not is merely in the eye of the beholder. E.g. a compacting ligature for "www" seems to be welcome in some typefaces for coding. But again, only to stress the reminder: It ain't monospace any longer. We do still may prefer for the typesetting pleasantry that it still is styled as monospace (or fixed width). but those ligatures aren't fixed width any longer as with the letter A,…

Here's how monospace ligatures work in real life: the width of a glyph is strictly proportional to how many ASCII bytes it represents. A 1-byte glyph like `m` gets 1 cell. A 2-byte glyph like `->` gets 2 cells. A 3-byte glyph like `===` gets 3 cells.

1 ASCII byte, 1 cell. That way ligatures don't change the width of the original text. If a line used to require 42 columns, it still requires 42 columns. That's why we call them "monospace": each ASCII byte requires the exact same width, even when it's part of a ligature.

> a compacting ligature for "www" —

Is obviously out of scope. We're discussing monospace ligatures here, not compacting ones.

Re: Ligatures in programming fonts: hell no (2019)

#199
post #39

> 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 edi…

Vscode 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.

Re: Ligatures in programming fonts: hell no (2019)

#200
> 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).

Post reply on HN