4 ms·
I've wanted a proportional font for coding for a long time! I sympathize with Rob Pike: https://twitter.com/rob_pike/status/567476552187641856 https://twitter.
by delish 9y ago
I've wanted a proportional font for coding for a long time! I sympathize with Rob Pike:
https://twitter.com/rob_pike/status/567476552187641856 https://twitter.com/rob_pike/status/567476552187641856
I much prefer reading proportional fonts. This new font solves a problem I've had: punctuation is hard to discern in proportional fonts. But I'll still have trouble with deeply-nested functions not lining up.
- hyperpape 9y agoIn the example in that stream of tweets, you have: put = blah get = blah post = blah patch = blah gofmt accepts it as aligned, but the equals signs are visually unaligned when using a proportional font. I wonder what it would take to create an editing environment where you have a proportional font that shrinks or grows the (visual) whitespace to align those, and whether it could scale to things like nested functions.
- e12e 9y agoSurely, one logical space of variable width is a tab? I prefer spaces to tabs - but if one makes concessions to readability like variable-width fonts - it's time to bring back tabs, too? (I do think this is a good idea, but "before" spaces won, in no small part because pre high-resolution screens, I think monospace was the better choice. With high dpi comes pretty layout - also of code).
- teddyh 9y agoThe solution: Elastic Tabstops (http://nickgravgaard.com/elastic-tabstops/ http://nickgravgaard.com/elastic-tabstops/)
- ActsJuvenile 9y agoThis is awesome - thank you!
- Stratoscope 9y agoFor me the low DPI vs. high DPI displays didn't make a difference. I've been using proportional fonts ever since the days of very low DPI displays and still like them now that I only use high DPI displays. The key to using proportional fonts is to stop using column alignment and use only indentation instead. There's an illustration of this in the rustfmt code I posted elsewhere in this thread. And you're right, once you abandon column alignment, there's no longer any reason to prefer spaces over tabs, so you can take advantage of the other benefits of tabs.
- pugworthy 9y agoThe catch is, if I try to work with code relying on special stuff, and I don't have your special font, or special extension, etc. your code will look terrible. Consider for any of these ideas (and the idea of various fonts) just how well it would work for the masses. Consider the mess if someone works on an open source project and checks in a bunch of code formatted for this. Which is why I guess I'd see any kind of "fancy" spacing or even proportional fonts to be a real problem in an organization or structure where potentially many people, or new people over time, will have to work with the code.
- Stratoscope 9y agoWhat is really strange about this is that Rob Pike prefers proportional fonts, but gofmt mandates a column-aligned format that only works well with monospaced fonts. This is one reason I don't use Go today. I am never going back to a column-aligned format that is hard to read in a proportional font, so I would have to avoid the use of gofmt, which would make me an outcast in the Go community.
- to3m 9y agoI gave up on proportional fonts after a while. That was about 15 years ago, though... I think using clang-format and Comment Reflower/Emacs M-q/etc. would solve most of the problems I had with creating code that looked sensible when other people looked at it. If you've got the whole team layout out their code using tools like that, then the proportional font people won't find themselves having to line things up and whatnot. Still doesn't solve the issue of having ASCII art diagrams in your comments. Though... the comment word wrap plugin I use for Visual Studio has markup to say that it should leave a section of the comment alone (I use this for ASCII art bits). And clang-format has similar directives for blocks of code that it should leave alone. Would be nice if text editors could recognise these (and other similar markup - or perhaps markup could even be standardized between tools?) and render the appropriate sections in a monospaced font. That might be a useful compromise.
- repsilat 9y agoI wonder if you could approximate the readability of proportional fonts with kerning rules -- let some letters steal or donate width, so it's not perfectly monospaced within any word, but word boundaries still line up.
- Stratoscope 9y agoCould you share the name of that comment word wrap extension? I use proportional fonts for all my code editing, but I would like a way to be able to switch a block of code within a file to monospaced - like you mentioned for ASCII art, or for matrices (the one place where I still would use column alignment). This doesn't sound exactly like what that extension does, but it might be something good to look at to get some ideas. (Hopefully it's open source!) Thanks!
- to3m 9y agoNo, it doesn't do anything like that - it just does word wrap. Comment Reflower: https://marketplace.visualstudio.com/items?itemName=codebeast.CommentReflower https://marketplace.visualstudio.com/items?itemName=codebeas... (page says it works up to VS2015, but I've got it in VS2017 too - so presumably it's forwards-compatible?) One of its features is that you can pop comments sections in a <pre>...</pre> block to stop Comment Reflower doing anything to them. Here's an example, where you can see that the preformatted section extends past the wrap column. // Watford DDFS reads by initiating a multi-sector read, // counting sectors read, then doing this when it's got // the data it wants: // // <pre> // 0D43: ldy #$60 A=00 X=FF Y=60 S=DC P=nvdIzC (D=60) // 0D45: dey A=00 X=FF Y=5F S=DC P=nvdIzC (D=D0) // 0D46: bne $0D45 A=00 X=FF Y=5F S=DC P=nvdIzC (D=01) // 0D48: lda #$D0 A=D0 X=FF Y=00 S=DC P=NvdIzC (D=D0) // 0D4A: sta $FE84 A=D0 X=FF Y=00 S=DC P=NvdIzC (D=D0) // </pre> // // The loop at D43 is $5f*(2+3)+(2+2)=$1df=479 cycles, or // 240 usec. So if you had a text editor that implemented my idea, the first and last paragraph would be in proportional type, and the disassembly bit in the middle would be shown in monospaced to preserve the formatting. (In the long run, ideally, I suppose, you'd want your code text editor to support a wide range of formatting options, so that you could have italics and bold and monospaced and all sorts. But if you just decided that initially a simple proportional/monospaced font switch would be useful, this is the sort of markup you could use to key the transition off.)
- Stratoscope 9y agoI tried Input for a bit but wasn't really fond of the way it looked. My favorite coding font for some time has been Trebuchet MS. It looks really nice in the environment I use: fairly large fonts on a high-DPI display. With one exception, it has easily distinguished punctuation and characters like 0Oo and 1lI|. The exception is that it has a rather poor tilde. One of these days I'll load it into a font editor and put in a better tilde. Regarding deeply-nested functions not lining up, the solution there is to stop using column alignment and use indentation instead. As an example, the Rust team recently changed their style from this alignment-based format: let mut rewrites = try_opt!(subexpr_list.iter() .rev() .map(|e| { rewrite_chain_expr(e, total_span, context, max_width, indent) }) .collect::<Option<Vec<_>>>()); to this indentation-based format: let mut rewrites = try_opt!( subexpr_list .iter() .rev() .map( |e| { rewrite_chain_expr( e, total_span, context, max_width, indent ) }) .collect::<Option<Vec<_>>>() ); Even if you use a monospaced font, the latter style is much more practical. For example, if the arguments to `rewrite_chain_expr` were longer in length, you would simply change it to: let mut rewrites = try_opt!( subexpr_list .iter() .rev() .map( |e| { rewrite_chain_expr( e, total_span, context, max_width, indent ) }) .collect::<Option<Vec<_>>>() );
- Retra 9y agoI would get pissed to shit trying to click between 'i's and 'l's when coding. Proportional fonts are for sequential writing, reading, and editing. They are designed to hide mistakes. The are designed to make all words have a similar texture. None of that is what I would would want a programming font to do.