Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interestingly enough, his "parenthesis-stacked" C code looks just like Python, which I find a pleasure to read.

There's one difference, though: conventional Python is indented four, not two, spaces. In fact, the main aspect of his "normal" C code that makes it more readable (to me, at least) is his use of four spaces for indentation.

Personally I think the biggest barrier to Lisp readability is too little indentation (two spaces is typical). Looking at his reformatted Lisp, the way I identified the nesting level of his highlighted line was not by looking at trailing parens but by looking at the indentation, which was much wider (and therefore clearer) than standard Lisp.



Highly nested constructs are more common and natural in Lisp. I think that explains the low level of indentation. It also hurts readability compared to imperative languages, where it's common to have long sequences like this:

  do something;
  do something else;
  do something else;
  do something else;
  do something else;
Sequences like that give you long columns of aligned text that make it much easier to judge relative indentation on the screen.

Lisp's readability advantage (if it indeed has one; I'm giving it the benefit of the doubt for now) are at the whole-program level. On the function level, it seems more difficult than imperative languages. It would be more fair, and more to the point, to compare it to functional languages. If you write in an imperative style in Lisp, all the parens line up neatly, and it isn't so hard to read. But who codes that way unless they have to?


Your mention of Python made me wonder if anyone's experimented with an indentation-sensitive syntax for Lisp. It turns out they have.

In this Scheme RFI, "I-expressions" can be freely mixed with S-expressions in source:

http://srfi.schemers.org/srfi-49/srfi-49.html

This argument for I-expressions touches on many of the same points as the OP; e.g., whether source needs to be readable independently of the editor:

http://www.dwheeler.com/readable/retort-lisp-can-be-readable...


If you watch a Lisp-related mailing list, it seems like once a week someone brings up the topic "hey, what if I replaced the parens with significant whitespace?"


The answer:

You end up with seemingly arbitrary limitations like single line lambdas, just like Python.


False. The I-expression:

  lambda (x y)
    display x
    + x y
corresponds to the S-expression:

  (lambda (x y)
    (display x)
    (+ x y))


The stacked C code requires much less jumping around with your eyes and it's easier to quickly get an overall idea of what the code is doing. The other version just looks too scattered, which is fine if you're working on a particular line, but most of the time I'm just glancing at major portions of code.


That was my reaction - admittedly, I'm a Python fan, myself.

The real problem is two-space indents. The example would have been much easier with even four-space indents.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: