247 points · by Lwrless · 3y ago · 150 comments
I don't like ligatures either, but I think that this depends on the editor. For example, if typing Rust in IntelliJ, if you type `Box<Box<String>>`, it will show two regular ">" characters. But if you type `x >= 3`, it will replace it with a single glyph.
I would be very surprised if the editor enabled and disabled ligatures in sections of code based on information from a proper parser...
I've tried both Fira Mono and Jetbrains Mono, it seems to barely get the two glyphs closers. Below are screen captures of Jetbrains Mono.
With ligatures: https://ibb.co/vQ3nCsd
without ligatures: https://ibb.co/DtD1P9X
But, to your point, it would seem it doesn't enable ligatures based on the parser, since there is a difference between ligatures active and disabled, and it applies on both lines.
Luckily we can each have our own way and still work on the same code.
Agreed. Looks very nice in editor, but programming is not about looks. It's about ease of editing and maintainability.
What if ligatures makes it easier to edit and maintain?
I assume you only use light mode and the system fixed font for your programming?
However.
If ligatures were turned on by default, I would turn them off.
Same reason one uses spaces over tabs, except in Makefiles because someone decided tabs are mandatory. With spaces copying the code from one place to another doesn't change the indentation too much.
I'm sure I would get used to it after a while, but right now I'm having trouble even reading the examples. I don't need my editor to be too special.
I respect that people use it, but it's really not for me. It makes the code harder to read IMO
It reminds me of the debates about font antialiasing back in the 1990s. A vocal minority of programmers then insisted that font antialiasing wasn't suitable for coding, as a pixel-oriented monospace font (e.g. Monaco at 9 points) provided better text density and better readability[1].
Then, like now, I could see the validity of the arguments of both sides. Readability is a highly subjective thing (and also varies over time, even for the same person). And the screens and antialiasing algorithms of the day weren't as sophisticated as what we now enjoy.
Personally I waffled on it for a while, but now I always code with ligatures enabled in my main work (which is predominantly using TypeScript and Rust, so the default ligatures of these fonts make sense).
I suspect that the majority opinion will shift to using ligatures for coding (if it hasn't already) once that is the default experience of most editors with the default fonts, and it becomes something you have to turn off, rather than turn on.
[1]: This is an example of Monaco, although what they show as 12 point is how I remember 9-point looking... not sure if my memory is faulty or what, though, it was a long time ago. https://www.fontriver.com/font/monaco/
It's absolutely a personal preference thing, and I personally prefer it. At least for the languages that I typically work with. I could see it being annoying with certain languages.
Also kinda meta but I see three different font related links on the homepage right now? Just coincidence?
*opens comments*
*shakes head, closes tab*
Can we get slashed 7s too? Maybe even slashed Zs.
I would like to learn how most people decide on choosing a monospace font for their code editor and terminal. Is it pure choice based on looks? Or some other things are considered?
But fwiw, there is this game-ified tool to choose fonts: https://www.codingfont.com/
[1] And if ligatures are designed independently from ordinary glyphs, there is no reason to make them default.
I think it’s because operators like != are actually considered a singular symbol not two characters. We just don’t have that many available keys so we use multiple characters. But in my mind it’s a single symbol and ligatures go a long way to help my brain parse it that way
> Your eye spends a non-zero amount of energy to scan, parse and join multiple characters into a single logical one.
I don’t know how many calories are expended by the brain to perform this, but it has to be near-negligible.
I am _extremely_ used to seeing characters as they are in ASCII, and retraining myself for some infinitesimal savings in visual processing seems like a net negative.
Maybe this is useful if you grew up with them? By all means do whatever you want for your own env.
As for the brain, the brain doesn't see characters at the perceptual level, that it then needs to join at the cognitive level into tokens. At the perceptual level it just sees shapes. Whether it takes more energy to parse != or ≠ is something I don't anyone has ever researched.
Ever wonder why you can't really seem to read properly when you're hungry and tired? That part of your brain is in power-saving mode.
Is the implication that with FiraCode, the eye will finally spend zero energy on scanning, parsing and joining glyphs? Finally, after all these years, a perpetual motion machine! :-)
There’s the reason. It’s different than what you’ve been seeing most days of the last X years
Cascadia Code (introduced with MS Terminal, aka Caskaydia) is also a very great typeface as well.
I like Fira Code slightly more though... especially as a terminal font, I use the fork with extra nerd font characters linked from starship.rs[1][2]
1. https://starship.rs/presets/nerd-font.html 2. https://www.nerdfonts.com/font-downloads
It has a more stylized look than your typical coding font, and I don't use it all the time, but I enjoy swapping it in when Source Code Pro starts to feel a bit boring.
One (minor) language that does have quite a lot of support is Rakudo which allows both unicode and ascii equivalents for many operators. https://docs.raku.org/language/unicode_ascii
Edit: There is annoying popup, but click away from it and you can do the thing.
My favorite coding font is the Go font. It’s very readable and brutally simple.
I use comic mono and I absolutely love it.
I like to use Monokai/Molokai and joke with my colleagues that I'm using "clown colours"
I’ll admit I prefer ligatures while working with ML syntax and Lisps, they feel a little wrong(?) when working with C style languages. Is anyone aware of a way to toggle them on a per language basis in vs code?
"[c]": {
"editor.fontLigatures": true
},- [1] https://input.djr.com/ - [2] https://github.com/ToxicFrog/Ligaturizer
I’ve been code using Input Sans a (gasp!) proportional coding font for years now and I love it. Input also comes in a monospaced version FWIW.
a = 1
ab = 2
abc = 3
Guess what, this is equally readable a = 1
ab = 2
abc = 3
and some code formatters yield this anyway (eg: Elixir's, if I remember well.)It's a very good exchange: a little feature to miss, much more readable code.
I gave a try to Input but it was not OK for me. I can't remember the details. I'm giving a try to Sweden Sans, from yesterday's HN.
I used to use all the column alignment tricks like the one you showed, and stuff like this:
do_something_special(first_argument,
second_argument,
third_argument);
Then one day I renamed a function and the length of its name changed, and I had to go through all the code and line things back up again.So I abandoned this kind of column alignment completely and switched to a purely indentation-based format:
do_something_special(
first_argument,
second_argument,
third_argument
);
(Assume for the sake of discussion that those arguments are long enough that they need to be on separate lines.)That's when the proverbial light went on. I thought, "since I'm not using column alignment any more, why not try a proportional font?"
I did just that, and never looked back. If you're not doing column alignment, proportional fonts work just fine.
Where I currently work, most of our code is in Python. We used to use the YAPF formatter with Google's settings that are full of column alignment. Last year we switched to Black, and I noticed something interesting.
Black-formatted code does not use column alignment at all. It uses only indentation, as in your second example and my second example. So it is just as readable in a proportional font as in monospaced!
My current coding font is something I call Trebuchet++. It's based on Trebuchet MS, but with a few customizations that I like for code: a better tilde glyph (the one in Trebuchet MS look too much like a hyphen), a little extra space before and after a dot, and a sneaky trick to make names_with_underscores more readable: I reduced the width that the underscore takes up but extended the underscore below the text before and after it. These last two adjustments fix a problem with stuff like foo_bar_baz.moo_mar_maz() where the underscores are wider than the dot, creating the wrong visual grouping.
Call me basic, but I love it. :)
Also on the list of things people hate… victor mono has joined-up italics! Which I also love. :)
In the end, they don't make that much of a difference other than being a small source of aesthethic pleasure. zero impact on supposed readability
IMHO coding really needs a simple monospaced font. I use Input Mpno with a slightly squashed horizontal spacing, and an almost overlapping vertical spacing.
Ligatures are just presentational so they don’t impair editing. If you ever try them again and use VSCode, you might like the Disable Ligatures that dynamically disables them for the selected line or cursor position.
https://marketplace.visualstudio.com/items?itemName=Coenraad...
I just wish Fira Code had an Extra Light option, sometimes, depending on the terminal/OS I find Fira Code too chunky.
https://github.com/be5invis/Iosevka/blob/main/doc/stylistic-...
Anything new here?
[citation needed]
The font looks good but I find it really hard to read C code with the ligated symbols.
And it looks like I am not alone: https://practicaltypography.com/ligatures-in-programming-fon...
Personally, I'd love to do my coding without a mono-spaced font but most of the world keeps space-aligning things, so that's not going to work unfortunately.
Of course, you don't have to use ligatures, no-one is suggesting we make them compulsory
- if a ligature looks just like a grapheme of another character, why not use that character? why the replacement is done at font level???
- using ligature across morpheme or token boundary is rude typesetting. e.g "selfish" or "c<int>=1;"
Other than that, I do not have anything against ligatures that enhance legibility of text (what they are meant to accomplish)