4 ms·
Why is coding so associated with monospace type? Has anyone tried using a proportional-width typeface? The vast majority of use-cases I can think of are simply
by losvedir 14y ago
Why is coding so associated with monospace type? Has anyone tried using a proportional-width typeface?
The vast majority of use-cases I can think of are simply allowing you to line up the first letter of a line, or possibly an equals sign or something like that. This seems like something a tab-stop or somesuch in the editor could handle with ease, and shouldn't require sacrificing nice-looking text the rest of the time.
- chc 14y agoI think it harkens back to coding's origins on punchcards. Many compilers still give errors along the lines of "Line 500, column 16", so it seems natural to use a font that incorporates those concepts into its design. But yeah, I can think of a few people who AFAIK do mostly use proportional fonts, and they do just fine. I think it's mainly a path-of-least-resistance thing.
- DavidAbrams 14y agoBack in the day, a lot of programming revolved around reporting. One reason I can think of would be laying out columns on reports, on terminals that didn't support proportional fonts. A lot of people rail against tabs; most of the time, these are people who don't understand them or have never tried to use them. You see this debate about tabs vs. spaces in code all the time, and I've yet to hear any valid argument about why spaces are better (at least in any modern context). But there is an obvious reason that tabs are better: It's much easier to line things up, keep them aligned across different users' fonts, and realign them if you change the text to cross a tab.
- eropple 14y agoHow quaint, another person who insists that people who don't use their preferred formatting just doesn't understand it! Never mind that maybe they just disagree--there has to be something wrong with them, right? I don't use tabs because of an equally obvious reason that spaces are better: because I end up padding with spaces because the tabs are too big. For example, I like having horizontally consistent parameter argument lists, like below: class Thing { def beep(bar: String, baz: Int, quux: Seq[String], quuux: Map[String, String], quuuux: Int) = false } If I tried to use tabs there, I'd be off by a space and have to add another space. Someone with a different hard-tab width would then get mad because there's an "extraneous" space in their view. And then we all have a nice big slapfight and sound like your post in the process. (Plus, my editor treats four spaces in a row as a soft tab anyway, so I don't even notice it except when I want to. Life is peachy.)
- DavidAbrams 14y agoI pointed out that they never give a specific reason for preferring spaces. At least you did that. You can still achieve what you want, and even faster, by using tabs to get your subsequent parameter lines most of the way there and then padding with a couple of spaces.
- eropple 14y agoI covered that exact "solution" in my post--the exact one! It blows up when somebody else is using a different tab width than I am. And given that I use soft tabs, it is no faster at all.
- biff 14y agoI used a proportional-width typeface on one of my recent projects in Java. It felt quite natural, actually, and took some of the pointless formatting distractions away from the coding process. Didn't constantly think about trying to keep lines of code within 80 characters, for example -- if it was readable on my screen it was fine. The drawbacks were things like confusing lowercase L with 1 (one) in the sans-serif font I preferred, or the sort of editing where I was trying to change stuff at, say, character position 67 in a series of lines. It seems better for writing code than for editing it. Definitely give it a try if you haven't yet.
- zacharyvoase 14y agoWhen I code, I have a bar down the window that shows the 80-character mark. If I didn't use a monospace font, that bar would be impossible to draw. In fact, my editor of choice (Vim) assumes in many places that all displayed characters have the same width; it makes it a more consistent experience and allows you to do things on a simple console that you'd normally have to draw a complex (non-portable) GUI for.