Hacker News new | past | comments | ask | show | jobs | submit login
Programming with proportional fonts is great (m-mz.posterous.com)
48 points by brokenmusic on Jan 16, 2010 | hide | past | favorite | 50 comments



I can't stand proportional fonts for programming. Aside from it being harder for me to read, inability to use any sort of ASCII art, etc, it just feels sacrilegious.

Not to mention my editor of choice (TextMate) fails horribly with proportional fonts.

But then again, I used to feel the same way about anti-aliased programming fonts, and have since switched.

Currently Inconsolata 16pt anti-aliased is my font of choice. It helps to have a big screen...


> inability to use any sort of ASCII art

That actually makes me support the idea of using proportional fonts even more.

- If something's that complex you need a diagram to support it, that probably doesn't belong in your code - you should maintain documentation in documentation format, and doc updates shouldn't mean new code revisions. Throw a URL to the documentation in as the comment.

- Diagrams could be illustrated much better with an actual diagram rather than an ASCII visualization of one.


Design documents and complex diagrams don't belong in code, but a simple ASCII diagram right there in the code to illustrate how the transformation tree is created:

- is always within easy reach of the eye.

- is harder to forget about when changing the code.

- doesn't require you to download, install, register and fire up Visio Community Edition 2008 to add a new FileLogger node to the illustration of the data transformation tree.


Simple and complex diagrams can be made in any decent graphics app (Inkscape or Keynote are fantastic) and easily exported to PNG or SVG.

Personally I also have a lot of trouble reading ASCII diagrams. Knowing that pipe-slash-dash is a curved line, when the line is broken and the ends don't line up properly.

On a separate note, I suggest whoever moderated me to zero should read the HN guidelines.


Why do proportional fonts fail so bad with TextMate?


I don't know, but they do: http://tlrobinson.net/skitches/Screen%20shot%202010-01-16%20...

Edit: Hah, I swear I didn't notice that Growl notification in the corner until just now...


"more text in an eye fixation" is not necessarily a good thing for reading code, because code is semantically more dense than regular text. I think one will not be able to absorb all information and therefore not get a faster reading experience due to re-reading. I find the fixed-width font example easier to read, because it appears not as cramped as the proportional-width example, and I can easier get an overview of what the code does.


Agreed - I don't think the speed-limiting factor when reading code is how fast it transfers from screen to brain. That's totally different with prose, where you often skip over almost 90% of the characters because the choice of words that fit the context comes naturally - not quite the same for function call arguments...

A possible benefit of fixed-width: say you take a for-loop (which you can probably recognise even skipping over 95% of the characters) - now your brain wants to extract the indices at which it starts and ends: it seems to me a fixed-width font makes it easier to predict where you'll find the indices in the given line. (Not sure if that's how my eye-coordination really works, but it feels like it does...)


i don't know. Taking a clojure example :

    (defn say [word]
      (println "You said"
               word))
This wouldn't be possible without fixed width. Now a lot of languages don't use that kind of indenting a lot, but in lisps it's mandatory.

Also fixed width ensures that you can write code and it will lay in the same way on other computers, regardless of what other fixed width font they're using. That's a big big point i think, since code is most of the time a collaborative effort


I agree, but I think it would be possible to have proportional text aligned properly if you are working above the level of raw text, as in with sexps in paredit.


There are good heuristics for checking whether spaces are being used for indentation. You can look at where they appear in the line, for one thing, and whether they're in clumps of two or more for another. In those cases it would be simple enough to make them align perfectly with the characters above/below them.

Of course, you'd have to decide which to do - above or below. There are reasonable heuristics for that, but they're probably more complicated and less accurate.

The nice thing about doing it this way is that it degrades perfectly when the code is viewed in fixed-width (which is good for tools and other developers).


Or how about a font with proportions made for code?

I would imagine special proportions for markers like (){}[] and punctuation marks and fixed proportions for numbers. At one point the difference between that and syntax highlighting and automatic indentation blurs.


Maybe for a fortress program http://projectfortress.sun.com/Projects/Community/wiki/Integ... my brain will allow proportional fonts, but for anything else it is actually wired in such a convoluted way by now that it expects monospace!


I switched to a proportional font by mistake when I started using acme as my primary editor. A few months later I realized what had happened and tested how things looked in fixed width. Turns out I like proportional better.

A big difference was probably the fact that the codebase I was editing used tabs for indenting and had non-ascii art indenting rules (basically just indent the next line).


Acme works very well with proportional fonts, although it doesn't do relative indentation well as a result (think lining function arguments up on the left paren). Still a really brilliant editor in many ways.


I honestly think fixed width fonts are only used because of fixed terminal widths, and when repeating instructions on separate lines was common enough that the shape of a line being different was a kind of proto syntax highlighting to show you'd done something wrong.

Ultimately, a space is a space in whatever font, so everything still lines up along the left margin nicely.


Bjarne Stroustrup's The C++ Programming Language has all the code set in a proportional font: bold italic Times. I found it at least as readable as any other programming book. The ideal typeface is different for print than for screen, of course.


When I tried this I liked it, too, but after a week or two gave it up: I write code for others to read, and, sadly, they will be reading it in a fixed-width font.


I'm not sure I understand. Was using a proportional font changing the way you chose to format the code to such a degree that it annoyed people?


Using a proportional font will break if you try to align code other than using indentation, e.g. aligning assignments.

More examples: http://mysite.verizon.net/astronaut/vim/align.html#Examples

Of course, I really hope nobody's coding like that. I've never seen anyone who's been able to maintain that kind of formatting consistently.

I don't see any reason why proportional fonts shouldn't work for most programming styles. The problem is that most existing proportional fonts aren't very well suited for programming. At the very least, you need a font with unambiguous shapes for similar glyphs, like 1lI0oO`',.;:


Leading spaces aren't much of a problem, but aligning comments on the right-side is much harder due to the variable widths of each line. And even if you align them in your editor, they'll be misaligned for people who use fixed-width fonts. Does that make any sense?


Use a word processor (or a text editor that allows for fixed tab stops). This will also allow insertion of diagrams and other non-textual stuff (think clickable buttons, for compilation and testing, for example) into source code.

See, for an example implementation, BlackBox Component Pascal - Windows only, but runs moderately well under Wine.


It does. However a lot of people avoid comments on the same line as code.


I think this is one of those "religious" wars things - although us proportional fonts people are much the minority.

I've used proportional fonts since the early nineties and written thousands and thousands of lines of code since then in a proportional font. I have occasionally tried to go back to a fixed width font but I can't be bothered trying to get past the "it makes my head" hurt stage. (and likewise I can't imagine a lot of fixed width people getting past that stage going in the other direction).

We can rationalise our choices all we like but I doubt that there is any serious advantage or disadvantage in either.


In my experience, proportional typefaces only work for code if the IDE/editor is using a pretty-printer that uses word-processor style indentation. (That is, it uses tab stops as opposed to just inserting spaces/tabs in the text.)

The only IDEs I've seen work this way was the old THINK Pascal from the 68k Mac era, and its predecessor Instant Pascal for the Apple II. Anybody else seen a more recent example in the wild?


That brings back memories. I used THINK Pascal back in the late '80s in an undergrad computer graphics class, and it did take a little while to get used to proportional fonts. But once I got the hang of indenting with tabs instead of spaces, it was actually kind of nice. As the article says, the text was much easier to read, especially the comments.

EDIT: I checked my dev environments, and it turns out both Eclipse and Visual Studio support proportional fonts in the code editors. I had just never thought to look.


Maybe not an IDE, but the AppleScript Editor in Mac OS X (and Classic, IIRC) has you enter text in fixed width by default, but then changes it to a proportional font after syntax-checking.


Yup, completely forgot about the Script Editor. Though, as you say, it doesn't really hew purely to monospaced type, but more of a hybrid. (Hypercard was similar, IIRC.)


    Tomato  vs. Tomahto
    Bug     vs. Feature
    Tabs    vs.  Spaces
Either approach introduces about as many problems as it solves. I personally like being able to line things up with a few extra spaces to give some hints to my future self regarding the structure of my code.


Except for Tabs, obviously. All those problems are space-specific ;)


You didn't notice I right justified then. My peeve with embedded tabs is they are editor-defined and generally too wide.

    i       = 0.0;
    Tomato  vs.     Tomahto
    Integer vs. Doubles
    Integrals       vs.     Derivatives


Are you really using an editor that doesn't let you define your tab widths? I couldn't name a single modern IDE that lacks that feature.

(and extra points to the grandparent for the ironically mis-spaced "tabs vs. spaces" chart!)


The second comment on the post:

Of course proportional fonts can be read faster. That's not the point. Programming uses lots of non-standard glyphs, has meaningful syntax (eg. parens, brackets), and often meaningful whitespace. You can real _words_ faster in proportional font, but (arguably) not _code_.

I agree completely.


gvim hates proportional fonts:

  E596: Invalid font(s)
I just can't bring myself to use emacs.



I'm not sure I'm smart enough to use it, much less understand it. I can understand that it's mouse based though, and I can't grasp how that would be more efficient for the way I code. I am intrigued by the idea of no built-in commands, relying instead on making external commands easy.. I guess I should look at Oberon again too.

http://doc.cat-v.org/plan_9/4th_edition/papers/acme/


It works best with the plumber, which is to pattern matching as file name extensions are many file browsers. Plumb a uri and it opens the browser, unless you added a more specific rule to follow a different action.

http://swtch.com/plan9port/man/man4/plumber.html

For instance in Plan 9 I mount the file system of my webserver (across the internet), tail -f /n/remote/var/log/httpd/error_log.

An example error would be

[Thu Nov 26 15:28:15 2009] [error] PHP Warning: Invalid argument supplied for foreach() in /staging/php/restricted.class on line 286

For which I have a plumbing rule

    type is text
    data matches '(/staging/[^ ]+) on line ([0-9]+)?'
    data set	/n/remote/var/www/$1 
    attr add	addr=$2
    plumb to edit
    plumb client $editor
My apache is chrooted so I set the un-chrooted path with relation to my plan 9 (the remote server is mounted at /n/remote)

So in Acme I plumb the error message and Acme opens the file (if it isn't open) and scrolls to the appropriate line.

Ok this is nothing amazing in and of itself, other editors can do similar things - EditPlus on Windows can scan error messages) but combining simple things like this makes a bigger system.

Typing your own menus is also a great feature. You can whip up an awk script and apply it to selected text.

Here's a little one

http://plan9.bell-labs.com/sources/contrib/maht/rc/exe

If I type 'exe doit' in the current window, select the text and middle click it creates the file (in the pwd of that window) , chmods it, adds the hash bang and opens it in new window.

Again, not amazing on it's own but one builds up such things over time and there is no restriction on what language to use, I even have a few that ssh into a remote server and run them there.

There is no best editor, but Acme is the best for me.

Oh and if you middle click Font it switches between the two specified fonts (sans and mono by default).


It's hard to keep code within the 80 char per line limit of PEP8 without using fixed-width.


then again, that's probably the most obsolete recommendation in PEP8


I really like having two 80-char wide Emacs buffers side by side.


It's actually 79 chars ;-)

"Limit all lines to a maximum of 79 characters."


ugh, syntax highlighting

this is what I use, it's available for Lunix too

http://en.wikipedia.org/wiki/Acme_(text_editor)


> ugh, syntax highlighting

Care to explain? I didn't know there was debate on this point.


There is no debate on my personal preferences. But do you actually think that everyone uses syntax highlighting?

Obviously Dennis Ritchie and Rob Pike didn't need it and though I don't in any way pretend I'm in that league of programmers, I am in that league of editor users.


As crazy as it sounds, for the longest time I used notepad as my primary editor. Then I switched to Notepad+ (still no highlighting). I'm now on TextMate (mostly due to my switch to OSX), but I find the syntax highlighting to help in quickly scrolling through and finding segments of code. If I'm looking for a variable, I just look for that color, etc.


You're on your way... Come join the rest of us in the world of IDEs. Once you've seen your "editor" autocomplete a member from another class (in a namespace you haven't even imported), there's no going back.


At my 9-5 I have to use Dreamweaver (code view) and I have no gripes about the text editing portion at all. Maybe there just aren't any IDEs for OSX I've fallen in love with yet, but they all have a sort of clunky aspect to them that can be annoying and can't be changed. Any IDEs that are like TextMate but with auto-completion? (I've done my fair share of looking in the past 3 years on osx.)


I can do that in Vim...


Sweet. My Vim sessions generally consist of issuing a dozen random commands before I happen to type an "I", followed by exiting, restarting, and cursing. Glad to hear you're having more success!


Sounds awful, I hated all that stuff in VStudio. I'm one of those crocks that thinks it makes you lazy in your organisation.

    grep '^fname' *.c 
is good enough for me




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: