46 points•ibobev•2 days ago•80 comments•

80 comments

whartung2 days ago
The parentheses are large glyphs that distract the eye, and do not stand out (to the untrained eye) as delimiters.

Consider:

  (defun split-line (line)
    (remove-if #'(lambda (word) (string= word ""))
               (split-sequence:split-sequence #\Space line)))
Now imagine if we had some "lower weight" glyph besides the paren.

  .defun split-line .line,
    .remove-if #'.lambda .word, .string= word "",,
               .split-sequence:split-sequence #\Space line,,,
Obviously a contrived example replacing () with ., but you can see how "heavy" the parens and how they can dominate what the eye sees.

With experience, the parens vanish. The parens being large and common take control of the conversation more than they should.

Avshalom2 days ago
this actually gets at the real problem. Lisps are wordy as hell. like jesus

  (split-sequence:split-sequence #\Space line)
now imagine if that was

  (split-string " " line)
image if the whole function was

  (defun split (line)
    (remove [\(word) (= "" word)] [split-string " " line]))
or even

  (defun split (line)
    (remove "" [split-string " " line]))

*using [] in place of rainbow parens for clarity of sub arguments
fweimer2 days ago
I think with CLOS, you can go back to using single verbs for function names. However, this has a performance cost. Encoding the receiver type in the function names makes the call much easier to optimize.

What remains is field access. Curiously, first-edition K&R C actually required similar type-encoding in field names because field names were global:

https://usenet.trashworldnews.com/?thread=288637

Same for ML, which is roughly of the same age, except that it took much longer for ML-derived languages to lift this restriction.

On the other hand, every time I wrote down examples that I think should look really bad in prefix notation, like this one:

    p3.x := (p1.x + p2.x) / 2;
It is actually not so terrible with a sufficiently streamlined prefix syntax:

    (setf x p3 (/ (+ (. x p1) (. x p2)) 2))
But maybe there should be a mechanism that the reader transforms p1.x to (. x p1), in the same way that it transforms 's into (quote s). Then we get this:

    (setf x p3 (/ (+ p1.x p2.x 2)))
Or if there is a concept of a place:

    (set p3.x (/ (+ p1.x p2.x 2)))
But that probably needs static typing for an efficient implementation (or set needs to deconstruct its first argument during compilation).
Jtsummers2 days ago

  (split-sequence:split-sequence #\Space line)
Why would you do that? You could just use `uiop:split-string` and import the function symbol into your current namespace so you can call it as `split-string`.

  (split-string "a b c")
acomjean2 days ago
Lisp is why I started using emacs and its parens matching features.
whalesalad2 days ago
I don't think the parens are the issue.

But when your function ends with ))))))))) -- that is the issue. Too much shit is being shoved into one method. But this is not the fault of lisp, it's the fault of the programmer who is wielding it.

kccqzy2 days ago
That is frankly not a problem at all. People rarely bat an eye when your Python function ends by having eight simultaneous levels of dedent. People definitely don’t bat an eye when your HTML ends with </span></span></div></div></td></tr></table></section></body></html>. All you need is just good indentation, which is enforced in Python but optional in Lisps; then lazy programmers take shortcuts and don’t indent at all.
waffletower2 days ago
OMG, the "improved" example is so cluttered and far far far less readable -- and even foreign -- to someone like me that has developed using lisp professionally for at least 10 years.
regenschutz2 days ago
That's a crazy effect. For me, as someone who has a very minimal understanding of Lisp (apart from messing with it in Emacs for at most an hour), the improved version is much more readable.
pfdietz2 days ago
Lisp isn't difficult to read, so I don't understand the question.

This feels like someone who doesn't know French asking "what makes French difficult to read?"

stcg2 days ago
Exactly, it's just unfamiliar to most people.

I find Clojure (a Lisp) more readable than many other languages. It's the style I like for pseudocode. Because I used it a lot. It's familiar.

"Easy" is relative and doesn't mean anything without a subject. Easy for whom?

caaqil2 days ago
> Lisp isn't difficult to read

You'd be surprised how seemingly simple things can be hard for some. As an example, it's extraordinarily difficult for some HN users to read beyond the title and try to understand the reasoning behind it, so they instead settle for showcasing their intellectual prowess by answering the question outright as if that was the thesis. It's a very smart strategy, I must say.

mpalmer2 days ago
You should really follow the HN commenting guidelines, specifically #1, 7 and 11.
iLemming2 days ago
> read beyond the title

Feels good to find a perfect opportunity to be witty and snarky, yeah? Well, allow me to murder this vibe of yours. Titles do exist for a reason. This article's title specifically, assumes too much. It's nearly click-baity. Imagine a title like "Why does the Holocaust feel like a hoax?", and then it goes into intricate detail to prove it isn't. Some people still get triggered by the title alone.

perrygeo2 days ago
> I have not yet encountered a fully satisfying explanation as to why Lisp is perceived as being less readable.

Difficulty is, by definition, relative to one's skill. You cannot so quickly discount the fact that 99% of programming is taught in Java/C style language syntax. If you've had lifelong exposure to Lisp, you might feel exactly the opposite. The author does a poor job of justifying why these pop-cognitive-psych theories should have more weight than prior exposure.

Personally, as someone with decades of exposure to both styles, I look at the factorial example and see everything I love about Lisp syntax - consistent, no magic keywords and syntax to memorize, it represents a tree just like my mental model of code, there's no way to fall through and forget an else, expressions instead of statements, no early returns ... literally everything about the Lisp example is more readable to me. YMMV.

Supermancho2 days ago
> Difficulty is, by definition, relative to one's skill

It's a factor and not the sole factor. Saying it's "by definition" is incorrect.

> The author does a poor job of justifying why these pop-cognitive-psych theories should have more weight than prior exposure.

There's no reason to believe either way, except one path has decades of evidence. Human behavior is not overcome by programmatic "elegance". The dismissive "pop" prefix is signaling bias.

> no magic keywords and syntax to memorize

ie no syntactic sugar. Pointless repetition is counter productive.

>a there's no [logical] way to fall through >b [no way to] forget an else, >c expressions instead of statements >d no early returns

b. The interpreter catches it. d. Pointless execution is counter productive.

> literally everything about the Lisp example is more readable to me

That's a single data point. Statistically it's worse, but you're practiced and apparently still physically able to quickly discern the nested count (or use an IDE). Yet another example of a position that is counter to existing studies. Heavy nesting is error prone, even when a program compiles (eg Monden et al., “Evaluating the Applicability of Reliability Prediction Models between Different Software,” ISSRE 2001)

perrygeo1 day ago
Of course it's a single data point, stating my personal preference and the objective characteristics of the code that make it more readable, to me. That's what the article did too! But they tried to use their biases to establish a claim on objective truth. That's the difference - I'm not trying to make a generalizable scientific claim!

I'm trying to say that making such claims in the first place is invalid.

There is no language that is objectively more or less readable. Yes, I've read the studies. No, none of them come close to adequately addressing the confounding factor of prior exposure/education. A randomized controlled trial starting from childhood could establish such truths, but such an experiment has not been done. Until then, small-n studies that don't address this flaw in any way yet continue to make broad claims - "pop" science is perhaps not dismissive enough.

convolvatron2 days ago
every time I get to use lisp syntax I feel a sense of relaxation, as if the background stress of thinking about precedence and the meaning of all these magic sigils and control flow constructs just melts away and I can finally see clearly what's going on. my first professional programming language was lisp, and almost every single project in the 35 years afterwards was C style. but it still feels like home.
tombert2 days ago
I'll repeat what other people here have been saying: I don't think Lisp is actually "hard" to read, in any objective sense.

It's "difficult" to read because it's different that other languages, but I think some of those differences actually improve readability once you understand the language. The forced use of parentheses everywhere guarantees that precedence is never ambiguous, for example.

so-cal-schemer2 days ago
I wouldn't say "never ambiguous" (at least for Scheme):

140 Assignment introduces a subtlety into step 1 of the evaluation rule. As shown in Exercise 3.8, the presence of assignment allows us to write expressions that will produce different values depending on the order in which the subexpressions in a combination are evaluated. Thus, to be precise, we should specify an evaluation order in step 1 (e.g., left to right or right to left). However, this order should always be considered to be an implementation detail, and one should never write programs that depend on some particular order. For instance, a sophisticated compiler might optimize a program by varying the order in which subexpressions are evaluated.

https://sarabander.github.io/sicp/html/3_002e2.xhtml#FOOT140

neilv2 days ago
I have a suspicion that 99.999% of people who say that Lisp syntax is difficult to read haven't really tried to use it (outside of a random homework assignment in CS101).

The syntax is incredibly trivial, and needs very little initial instruction (except to tell newbs to stop trying to put the close-paren on a line by itself, like they are fresh out of a JavaScript boot camp and have no frame to conceive anything else, and that, really, the automatic indentation and the shapes should be at least as readable once you try to use it in real-world examples, and see how that works in practice).

> Since Lisp puts the function name after the opening parenthesis, there is more distance between the parentheses. This makes it less likely that the parentheses are close enough to be scanned as a single shape.

Or we can navel-gaze differently, and claim it's more a shape, because then it's a nicely rounded shape that contains the whole function application/call:

    (foo x y z)

    foo(x, y, z);
There is a small chance that you're doing the following in a Lisp or C, but you'd be doing something fancy that most people do not (like writing the internals for a pluggable framework or object system):

    (((f a) b ) c)    Pseudo-Lisp

    f(a)(b)(c)        Pseudo-C
If you were doing this, and you thought the particular code was hard to read, you could throw in a variable or two, for the intermediate function (or function pointer) values. Or use a combinator...

When you don't have this fancy function-that-produces-function-that-produces-function pattern, your list head will typically have the name of a function there, and then the syntax simple shape and indentation visually disambiguates.

In skimming the article, I did see something the article could've followed through on, for a good syntax criticism of many Lisps:

    f[a][b][c]    Pseudo-C, array access notation
Array-intensive Lisp code could use syntax/dialect extension for square brackets for this, if the Lisp doesn't already have comparable syntax:

    [m a b c]
In both references and setters; see my most recent mention of it: https://mastodon.online/@neilvandyke/117067069023420085

Read the full thread on Hacker News →

Related stories