3 ms·
Use a proportional font for code reading! I really can't stand reading archaic type writer fonts anymore that are only optimized for ascii art.
by seanmcdirmid 12y ago
Use a proportional font for code reading! I really can't stand reading archaic type writer fonts anymore that are only optimized for ascii art.
- robert_tweed 12y agoThe problem with that is that it doesn't work when you have code (and comments) formatted in neat columns. Since plain text doesn't have any portable way to handle tabstops, everything has to be padded out (after the initial indent) with extra spaces. Characters must have equal widths or nothing lines up properly. This is pretty common in long repetitious declaration blocks, at least when the code is written by someone that cares about formatting. It vastly improves readability. Example: int some_variable = 100; // Foo float another_variable = 1000.0; // Bar The gofmt tool actually does this kind of column formatting automatically.
- morsch 12y agoKind of strikes me as something the editor could do ad-hoc. Maybe the tab character could return to let programmers tell the editor to align the adjoining lines according to the tabs. Would work well at least in your example.
- seanmcdirmid 12y agoElastic tab stops: http://nickgravgaard.com/elastictabstops/ http://nickgravgaard.com/elastictabstops/ You could also pad your spaces in the editor so that they align along a global axis. This does fix your code to a particular editor, however.
- morsch 12y agoExactly what I was thinking of, brilliant!
- robert_tweed 12y agoYeah this is nice. All we need now is for this to be supported in all major text editors and we're set! The only possible issue (not sure how it's handled, can't remember if/how gofmt handles it either) is when sometimes you actually want something to be misaligned because the width is so far out of the norm, e.g: int const1 = 10; // There's lots of space here for a long comment int const2 = 5; // Here too, unless the tabs get moved too far right float const3 = ( const1 * 123.45 ) / MAGIC_CONSTANT; // Not here. Normally when this happens I try to regroup the code so that "plain" constants are together and long formulas are in another group, but sometimes the order is important for some reason or doesn't make logical sense to regroup items, so the formatting has to suffer a bit.
- morsch 12y agoAs long as you rely on the tab character to signal the programmer's intent on inserting an elastic tabstop, that's not an issue. In this case, insert a \t in front of the comments on the first two, but not the third line. All three lines could have \t's in front of the equals character so align on it. The other nice thing is that it degraces quite gracefully in non-supporting editors.
- seanmcdirmid 12y ago> The problem with that is that it doesn't work when you have code (and comments) formatted in neat columns. I mentioned ascii art as something that fixed-width type writer fonts are optimized for.
- klibertp 12y agohttp://tvtropes.org/pmwiki/pmwiki.php/Main/BigNo http://tvtropes.org/pmwiki/pmwiki.php/Main/BigNo Of course, once you implement an editor which does a good job of keeping things aligned even when using proportional fonts, I'll switch immediately. It's not like I didn't try - default font in Pharo is proportional and I tried working with it for a few weeks. Smalltalk syntax is so clean and minimal that I thought it would be ok, but even there I had to change the font to monospace - in the (few, like populating a dict, writing to a stream, things like this) instances where I wanted the code to be aligned I couldn't do this and it was too irritating for me.
- DanBC 12y agoMay I ask: what is being aligned here, and why does it fail? Aligning stuff to a left margin / tab-stop / 4 space set should be easy, no? And are there any non-monospaced fonts that are designed for programming?
- klibertp 12y agoDon't know how well it displays, but I mean something like this: Dictionary new at: #symbol put: #something; at: #symbol2 put: #somethingElse; yourself. Notice how the first "put" is not aligned with the second one here. It looks aligned in Pharo though, when displayed with default font. This alignment may fall fall apart if I so much as change a font. This is bad, and that's why until the editor is able to preserve my alignment across different fonts I'm going to use monospaced ones.
- joshka 12y agoSounds like that formatting scheme would lead to changes on lines unrelated to the change, e.g. if I renamed symbol2 to sym2, the spacing on #symbol will be reduced. To me this sacrifices diff readability for code readability. It's generally not a tradeoff I like to make, but I can see how it is appealing.
- klibertp 12y ago