Hacker News new | past | comments | ask | show | jobs | submit login

As a long term (40+ year) Lisp developer I carry that forward into my other languages. Vertical whitespace is free in lisps,* as with most languages, so what I try to do us clump together an "operation" ideally so that it fits in my fovea when when I'm glancing at the code. So a quick glance tells me "this isn't what I'm looking for" or alternatively "all this goes together so read the whole thing before changing anything, but there's a good chance your change won't affect other parts of the function."

Thus: (if (< foo 0) (do-this) (do-that))

or if it's long

   (when (< foo this)
     (some-stuff)
     (more-stuff)
     ...)
Obviously one can do this in C++ by introducing a block, but it isn't as syntactically natural; a block implies that there is important RAII involved, so usually I just do it by "vertical clumping"

I find the standard c style (used by lots of languages) actually spreads the code out too much, emphasizing the curly braces rather than the code itself. (this is a local version of the OO+IDE plague that smears functionality across lots of tiny files.

This sense of locality is presumably why the gnu programming style is compact in some ways and expansive in others, different from K&R style, for example,

return-type function-name ( type1 arg1 ) {

allows the eye to see the identifiers without the syntactical markers () and {}, letting indentation and vertical whitespace to tell a story.

* except, de facto, Interlisp because it normally used a structure editor rather than a text editor.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: