7 ms·
Isn't the whole point of monospaced fonts columnar alignment (e.g. the table in the article)? Seems like "almost" defeats the point. Then again, I don't see v
by bsimpson 4y ago
Isn't the whole point of monospaced fonts columnar alignment (e.g. the table in the article)? Seems like "almost" defeats the point.
Then again, I don't see values lined up much these days:
{
"someKey": "someValue",
"someOtherKey:" "someOtherValue,
and if you only care about leading whitespace (that is, the whitespace before a character appears on the line), maybe it doesn't matter how your font is spaced.
I suspect numbers in these almost-mono fonts are monospaced, so numerical values should still have nice rhythm too.
- blakewatson 4y agoYeah, you’re right. You lose columnar alignment but beginning indentation still aligns and, in Input Sans, I believe the numbers are tabular. David Jonathan Ross makes this argument in the explainer for Input: > Sometimes programmers rely on the monospaced grid to create a second column of values or comments on the right side of the page. It’s true, these secondary columns won’t align in a proportionally spaced font. But why are we making these columns in the first place? Even in a monospaced font they can be finnicky and hard to maintain. > In virtually every other form of typography, the responsibility of alignment is given to the typesetting application, not the font. If source code editors can highlight syntax, they could also interpret tabs and syntax to create true, adjustable columns of text. https://input.djr.com/info/ https://input.djr.com/info/
- bsimpson 4y agoI still can't believe personalization isn't more widespread in coding. For instance, it ought to be reasonably trivial to set up your formatting preferences in your editor, but have the file saved to disk be in a common format. You want 8-space tabs and braces on their own lines? Cool. We'll save the file with all the formatting defaults, but run a formatter tuned to your preferences before displaying.
- kaashif 4y agoHere's my reason: if what I see on screen doesn't match the code actually being committed, that freaks me out. Same reason I don't like using those things where <= turns into ≤ in your editor but it's written to disk as <=.
- somethingsaid 4y agoSimilarly, for some languages the meaning of what is written can change based on the indentation and line breaks. Or a statement written under one formatting standard can become significantly harder to read under a different formatting standard.
- bsimpson 4y agoThere are plenty of automated formatters - clang-format, prettier, gofmt, black. You would delegate to one of them, configurable in the project/editor, and adjustable by file extension. If the code doesn't parse, save it as-is. If it does, run the formatter with the defaults before saving. When opening, run the formatter with the user's preferences before displaying. Gets you the benefits of a formatter, with the freedom to control your environment to your tastes. You can already pick your editor, font, and color theme. You ought to be able to pick your formatter settings too.
- kevin_thibedeau 4y agoThis invariably leads to fucked up diffs and useless blaming. In theory tabs are superior as a way to provide configurable layout but as soon as you have to collaborate between users with different tooling you end up in a mixed whitespace hellscape.
- Beltalowda 4y agoAccurate reporting of the error positions is one reason this is a non-trivial thing to implement. It's a fixable problem, just takes quite a bit of tooling and complexity for a good experience, and all things considered: is it really worth it?
- throwaway27727 4y agoAsk and receive: https://blog.jetbrains.com/idea/2022/11/intellij-idea-2022-3-beta/#Visual_formatting_layer_in_Reader_mode https://blog.jetbrains.com/idea/2022/11/intellij-idea-2022-3...
- coldpie 4y agoIMO, the fact that personalization isn't more widespread is good evidence that code style doesn't actually matter. Humans adapt. So long as it doesn't actually interfere with the function of writing code (eg mixed tabs & spaces; wildly inconsistent identifier names), your reader will get over it quickly after some snide comments to their friends on IRC, and then work on the actual work that needs doing. I think people spend too much thought on this topic.
- opk 4y agoI long ago concluded that trying to line stuff up in columns like this in code is a mistake. It often results in realignment of blocks for small changes so what should be a small diff in the git history ends up being big. Only rarely is the vertical alignment useful because mostly code isn't read vertically. Used in moderation, the reverse Christmas tree style used in the Linux kernel can be as good for readability (sorted longest to shortest). For some constant structures a reordering of fields to put the variable length element at the end of the line removes the need for padding space (like in the output of `ls -l` where filenames come last). A common indentation style for continuation lines is to align with the start of arguments to the function. I've never seen the sense of this variable amount where indentation after a while is much more than after an if. Double the normal indentation for continuation works well in languages where line continuation isn't otherwise distinct from normal blocks.
- andai 4y agoThis just seems like a limitation of the technology. When you change the width of one column, the whole table should realign, without any changes to those parts of the file (it's just about how it's displayed). I recall reading something about "tab stops" that solved this problem, but I don't think there are any mainstream implementations of it.
- archseer 4y agoI think you mean elastic tab stops https://nickgravgaard.com/elastic-tabstops/ https://nickgravgaard.com/elastic-tabstops/
- operator-name 4y agoElastic tabstops actually mentions the input font in its "see also" section!
- mmis1000 4y agotab stops is still available in terminals. Tab in terminal move the cursor to next x*8(depends on setting) position independent of what character you input before. But a major flaw is that it only works when your cell has less than 8 characters. Or it will go to the wrong stop. Which isn't that common today. Because why insist in short names and 80 width character limit? Almost everyone have a screen that can fit hundreds of characters per line today.
- kqr 4y agoNumbers in many non-monospaced fonts are also monospaced. It's a font feature known as tabular figures.
- lelanthran 4y agoWith non-monospaced fonts, it doesn't matter how many or how few leading spaces you insert, the columns may never line up, and your IDE can't determine them automatically. With monospaced fonts, the columns will be guaranteed to line up with the correct number of spaces, which your IDE will determine anyway.
- jen20 4y agoThis “feature” of lined up values annoys the hell of me when using Go (in particular) and also seems prevalent in Ruby-derived things. IMO unless you pinstripe line backgrounds, it makes it harder to trace which value maps to which key in the presence of a single longer key name. It also leads to noisier diffs.
- karmakaze 4y agoIf spaces had half-width, then the Duo could still use spaces for alignment, though monospaced text would need to be run through a filter.
- Cthulhu_ 4y agoYou know, now you mention it, I thought about this and realized I mainly want items to START on the same column, after that I don't care; only exception is tables in markdown, but those are few and far between. I might give these fonts a try, although I've been used to Menlo for a long time.
- WithinReason 4y agoI wonder if it would be possible to create a font that is not monospaced for letters but it's monospaced for words, so if you have a word + white space the end of the white space is the same as it would be with a monospace font. Alternatively, one could write "alignment characters" like & if one wanted to align lines like in LaTeX formulas.
- rob74 4y agoYeah, that's why I'm skeptical about these "almost monospaced" fonts too. In my opinion, the actual problem is sans serif monospaced fonts: there most of the glyphs are sans serif, but then the designers are forced to add serifs only to the narrow glyphs to fill up the available space, so these end up sticking out like sore thumbs. So monospaced fonts that have serifs on all glyphs look much better IMHO.
- rrwo 4y agoTypewriters and dot matrix printers were monospace. It had nothing to do with lining code up. When I attended university in the mid-1990s, and again in mid-2000s, we were required to hand in papers using monospace font, black ink, with a specific point size and margins. It kept everything looking consistent with typewriters (which some people still used through the 1990s), but also kept people from using distracting or illegible fonts, or trying to work around page or word limits by using different fonts.
- lucideer 4y agoAnother benefit of monospaced fonts is ease of calculation of text-container width: any line x character count will always be the same length as any other. The main use of this in practice is using line-char-count limits as a proxy to lint for code readability, but it can also be beneficial in other contexts.
- scythe 4y agoIf you drop the awkward "3/4" width and just have 0.5, 1, 1.5 char widths, then you could recover alignment by using U+2009 as the half-width space, maybe entered as Shift+space.
- IshKebab 4y agoFrom the article: > You might be thinking, “Okay, but now characters won’t line up neatly.”
- jamesfisher 4y agoI agree "almost" defeats the point, and that columnar alignment is not very valuable, and so there's actually a stronger argument to be made: we should just use normal fonts for coding. What's wrong with, say, Helvetica?