News for hackers. Stuff that matters.
Re:Collection of the best fonts for programming by alcuadrado on Sunday April 28, 2013 @04:14PM (#5622566)
Interesting, but how do you know if you passed the column 80? how do you work when the coding standards mix tabs and spaces (like tab for indenting, spaces for multi-line aligning)?
Re:Collection of the best fonts for programming by Stratoscope on Sunday April 28, 2013 @05:18PM (#5622813)
Those are coding standards designed for monospaced fonts. They work poorly with proportional fonts, but there is a simple solution: abandon those standards.

With regard to indenting vs. column alignment, don't do column alignment. Code is an outline. It's not a spreadsheet. Column alignment is not beneficial in most cases, and it wreaks havoc with source control diffs. Is it really better to code like this:

  double someFunctionName( int                 index,                 // counts things
                           SomeType            secondParamWithStuff,  // fancy object with stuff
                           SomeLongerNamedType third )                // whatever
instead of this:

  double someFunctionName(
      int index,  // counts things
      SomeType secondParamWithStuff,  // fancy object with stuff
      SomeLongerNamedType third  // whatever
  )
Now sure, the second version may look a bit sloppy if you're used to the first, but it has several real advantages:

* Much less horizontal eye movement

* No eye tracking across wide swaths of whitespace

* Changing one name doesn't require reformatting the whole thing

* Since you don't have to reformat, it doesn't generate unrelated diffs

* It works equally well in proportional or monospaced fonts

Oddly enough, many years ago I switched to the second style, not because I was using a proportional font at the time, but because I was really tired of reformatting multiple lines of code just because I'd refactored one variable or type name.

And then some time later I tried a proportional font. My code looked fine in the proportional font, and it was still just as readable in a monospaced font.

WRT 80 columns or whatever your limit is, I just don't worry about that. I generally keep my lines quite a bit shorter than that, but if a particular piece of code is more readable with a longer line, I don't sweat it.

Re:Collection of the best fonts for programming by jussij on Sunday April 28, 2013 @08:12PM (#5623438)
> Code is an outline. It's not a spreadsheet. Column alignment is not beneficial in most cases

But there are many cases where code works best as a spreadsheet.

For example any time you need to initialise an array of structures, that is best viewed using a grid like pattern.

> but because I was really tired of reformatting multiple lines of code just because I'd refactored one variable or type name. Any decent editor with smart indenting should eliminate most of that effort.

Also if the editor is scriptable editor, it should be possible to create a simple script to semi-automate the task.

Re:Collection of the best fonts for programming by Stratoscope on Sunday April 28, 2013 @09:45PM (#5623662)
> But there are many cases where code works best as a spreadsheet.

Indeed, that's true, and I don't mean to be too much of a proportional font fanatic. Even if I try to avoid coding styles that require monospaced fonts to be readable, there are always cases where it helps to get a monospaced view of the code.

One feature I really like in an editor is an easy way to switch between proportional and monospaced views. The best support I've seen for this is in Komodo [1]. Like many editors, Komodo supports multiple themes of font face/size/colorization/etc. What it does differently, though, is that each theme has two font selections, a proportional font and a monospaced one. So you can pick your favorite for each, and then choose whichever works best for the particular code you're looking at right now.

Oddly enough, out of the box Komodo doesn't give you a keyboard shortcut to switch between proportional and monospaced, but it's easy enough to add a keyboard shortcut for this. (In the Key Bindings dialog, look for User Interface: Use Fixed/Proportional Font.) I have this set to Alt+O which is unused in a default Komodo installation on Windows, and it's easy to remember because "proportional/monospaced font" has a heck of a lot of "O"s in it. :-)

But when I do use an editor that only offers monospaced fonts, it's not a terrible thing. I use your excellent Zeus IDE [2] for my Go coding and it's a pleasure to work with. Sure, I miss my proportional fonts, but having the integrated debugger and other goodies for Go makes it well worth it.

[1] http://www.activestate.com/komodo-edit

[2] http://www.zeusedit.com/

Re:Collection of the best fonts for programming by jussij on Sunday April 28, 2013 @10:26PM (#5623761)
> I use your excellent Zeus IDE [2] for my Go coding and it's a pleasure to work with.

Funnily enough I'm the author of the Zeus editor. Glad to read you like using it :)

> Sure, I miss my proportional fonts, but having the integrated debugger and other goodies for Go makes it well worth it.

Over the years many Zeus users have asked for proportional fonts so you’re not the only user who misses them.

The reality is many years ago, Zeus was designed with only mono-spaced fonts in mind.

At that time, the simple rule of knowing all characters are the same width and height seemed to greatly simplify the design of the editor.

And once that design decision was made it's amazing how many places in the editor code that rule then ends getting coded, making it very difficult to change :(

Given the time again I think the underlying design would be different.

Re:Collection of the best fonts for programming by Stratoscope on Monday April 29, 2013 @07:45AM (#5625478)
Ah yes, I know how that goes. Very hard to undo a fundamental design decision. Well, proportional or monospaced, Zeus is great either way. :-)
Re:Collection of the best fonts for programming by ShirtlessRod on Sunday April 28, 2013 @09:05PM (#5623571)
> Also if the editor is scriptable editor, it should be possible to create a simple script to semi-automate the task.

True, but why do it in the first place?

Note that I'm not supporting proportional fonts here -- I much prefer fixed-width -- but I also don't like formatting function signatures like that.

Re:Collection of the best fonts for programming by jussij on Sunday April 28, 2013 @09:24PM (#5623620)
> True, but why do it in the first place?

For me, I prefer reading and editing vertically aligned code.

Also I don't find it overly difficult to make sure everything is line up vertically.

Re:Collection of the best fonts for programming by ShirtlessRod on Tuesday April 30, 2013 @09:53PM (#5636021)
It's not difficult, it's just one more thing to have to do.

Like most things, I think it really just boils down to an aesthetic preference, and it's usually up to whoever actually maintains the code anyway. :)

Re:Collection of the best fonts for programming by mapleoin on Monday April 29, 2013 @04:57AM (#5624871)
> Those are coding standards designed for monospaced fonts. They work poorly with proportional fonts, but there is a simple solution: abandon those standards.

Do you ever work in a team?

Re:Collection of the best fonts for programming by Stratoscope on Monday April 29, 2013 @06:24AM (#5625178)
> Do you ever work in a team?

Yes, of course, many times. And on teams with a variety of coding standards, some loose and some more strict.

Did the coding style I suggested seem unsuitable for team use?

Re:Collection of the best fonts for programming by mapleoin on Monday April 29, 2013 @06:47AM (#5625274)
Yes, you suggested abandoning coding standards designed for monospaced fonts, specifically maximum line length. While most programmers use monospaced fonts, you are bound to clash with someone and make their lives harder by dropping some standards.
Re:Collection of the best fonts for programming by Stratoscope on Monday April 29, 2013 @07:22AM (#5625403)
Don't read too much into that part of what I wrote; I said it poorly. I'm quite aware that most people use monospaced fonts, and my code has to be just as readable in a monospaced font as in a proportional font, or it's no good.

I don't like excessively long lines any more than anyone else does, and I do pay attention to the column numbers. I just don't worry about them much, partly because my coding style naturally tends to produce shorter line lengths.

Compare:

  function niftyExampleFunction( niftyExampleParameter,            // nifty comment
                                 anotherNiftyExampleParameter ) {  // another comment
      doStuff();
  }
vs.

  function niftyExampleFunction(
      niftyExampleParameter,  // nifty comment
      yetAnotherNiftyExampleParameter  // another comment
  ) {
      doStuff();
  }
That's a line width of 84 vs. 56 for the same code. Fair enough?
Re:Collection of the best fonts for programming by Stratoscope on Monday April 29, 2013 @06:15PM (#5629211)
Just another thought that I forgot about last night. You were asking about teams and maximum line length. As I think back, most of the teams I've been on in recent years just weren't very worried about that. We all kept to short lines as a matter of readability, but didn't have any particular hard limit if a particular piece of code happened to be more readable with longer lines.

Of course this was long after the days of 80-column Teletypes, and we were mostly using various GUI editors that didn't have a hard restriction on line length.

But back in the days when I coded on a Teletype, I definitely kept all the lines shorter than 80 columns! :-)

Re:Collection of the best fonts for programming by sltkr on Sunday April 28, 2013 @06:06PM (#5622988)
Elastic tabstops [1] would work perfectly with proportional fonts.

1. http://nickgravgaard.com/elastictabstops/

Re:Collection of the best fonts for programming by anonymous on Monday April 29, 2013 @03:41AM (#5624615)
One critique I have of elastic tabs is that you need to read the whole document to know how to lay out just what you see before you. That's not an issue with files up to a couple of thousand slocs, but I've had to work with 60ksloc autogenerated source files and waiting for one of those to be parsed and laid out would be a pain in the ass.
Re:Collection of the best fonts for programming by VLM on Sunday April 28, 2013 @04:34PM (#5622634)
I don't use a proportional font like the OP but graphics art stuff like that is best handled by computer.

For example if you do sysadmin scripts in perl and edit with vim and have perltidy installed, its more or less just (esc) :%! perltidy (enter) and it looks beautiful.

Gave up on 80 columns a couple years ago. Haven't looked back much.

Re:Collection of the best fonts for programming by hmottestad on Sunday April 28, 2013 @04:31PM (#5622620)
First off I'm a student. Though the last summer job I had people didn't really care that much. Tabs/spaces doesn't really matter much. 80 char width also never been a problem. If it makes sense to have it on a 150 char line, then so be it. If it makes sense to split it up, then do that.

The only time I ran into length problems was when I was asked to print my code on A4 paper for an exam.

Re:Collection of the best fonts for programming by alcuadrado on Sunday April 28, 2013 @04:41PM (#5622669)
80 coloumns avoid that (and other) problems.

mixing tabs and spaces is strange and IMO should be avoided, but it sometimes happen :( all-spaces FTW