‹ BackHN Continuity

Thread

What makes Lisp difficult to read?

47 points · 81 comments · ibobev

Loading the complete thread in the background. This saved snapshot is available now. Refresh

  1. perrygeo · · focus · HN ↗
    > 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.

    Personally, 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, no early returns ... literally everything about the Lisp example is more readable to me. YMMV.

    1. convolvatron · · focus · HN ↗
      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 contracts just melts away and I can finally see clearly what's going on.
    2. Supermancho · · focus · HN ↗
      > 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 has decades of evidence and study. The "pop" prefix is dismissive.

      > 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 case of studies as to why 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)

      1. perrygeo · · focus · HN ↗
        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.

  2. PaulHoule · · focus · HN ↗
    I tend to struggle with other people's indentation rules for code and other programming languages, like nobody liked my article that said you should carry indentation into embedded strings that represent other programming laguages like SQL

       result = sql.execute("""
          SELECT someColumn
          FROM thatTable
          WHERE anotherValue>55
            AND state='pending'
          ORDER BY createdDate
       """)
    
    Ultimately the idea is that indentation should be influenced by semantics, the intention of the code, and not just the syntax. Of course that is against the "one way to indent" philosophy of Go, Biome, and such... But I might accept less than optimal indentation to put an end to tab wars once and for all.

    I find indentation of Lisp always seems to fail at communicating in the semantics, much worse than other languages. Things like

       (if condition truePath falsePath)
    
    are scrambled when your eye skips over something. If the Lisp community got over its respect for tradition perhaps they'd develop some kind of syntax highlighting or tooltips or something that would clarify this sort of structure.

    About 90% of real language have subject-verb-object or subject-object-verb orders

    <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Subject%E2%80%93object%E2%80%93verb_word_order" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Subject%E2%80%93object%E2%80%9...

    verb-subject-object and verb-object-subject are more Lisp-like and represent 10% of languages including Standard Arabic, Finnish and Fillipino.

    1. wat10000 · · focus · HN ↗
      Isn&#x27;t it extremely common for programming languages to put the verb first? They just write it as verb(...stuff...) instead of (verb ...stuff...).
      1. PaulHoule · · focus · HN ↗
        Well, you see a lot of patterns. In OO there is the classic

           subject.verb(object)
        
        In a case like

           add(left,right)
        
        isn’t the return value the subject and left and right both objects? That way

           a = add(b,c)
        
        Is really SVO.

        That said, you can build data structures in Java with functions like

           Expression&lt;Number&gt; add(Expression&lt;Number&gt; left,Expression&lt;Number&gt; right)
        
        and build something like S-expressions (not so nameless tuples) when you functions like the above, nested inside each other. You then can then write code to eval those expressions or write out Java code during a code generation phase —- it is fun on some level but if somebody else thought it combined the worst of Common Lisp and Java I woulsn’t blame them. Build a system like that and you will realize Expression&lt;Expression&lt;Number&gt;&gt; is a thing, you have to introduce a quote() operator, etc.

        And that quoting is also part of the Lisp problem. You have to not only decode your code relative to distant parenthesis but you also need to know the quoting state of the code you’re looking at which could agin involved involuntary nesting. Burns up precious working memory, just as multi-line if requires cognitive effort because your eye is not guided by if&#x2F;then&#x2F;else. It’s another one of those languages like C++ that seduces smart people into burning up their IQ on trivia and you can’t get them to listen about it because they think they are smart.

    2. pasc1878 · · focus · HN ↗
      For syntax highlighting try using a different colour for each level of indentation or parenthesis. I use prism-mode in emacs.
  3. whartung · · focus · HN ↗
    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 #&#x27;(lambda (word) (string= word &quot;&quot;))
                   (split-sequence:split-sequence #\Space line)))
    
    Now imagine if we had some &quot;lower weight&quot; glyph besides the paren.

      .defun split-line .line,
        .remove-if #&#x27;.lambda .word, .string= word &quot;&quot;,,
                   .split-sequence:split-sequence #\Space line,,,
    
    Obviously a contrived example replacing () with ., but you can see how &quot;heavy&quot; 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.

    1. waffletower · · focus · HN ↗
      OMG, the &quot;improved&quot; 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.
      1. regenschutz · · focus · HN ↗
        That&#x27;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.
        1. WillPostForFood · · focus · HN ↗
          Do you mean readable, as in it is easier for you to match &quot;.&quot; to &quot;,&quot; than ( to ), or is it just easier to look at without reading because there is less there.
          1. regenschutz · · focus · HN ↗
            The latter. Maybe it&#x27;s different in Lisp, but whenever I read code, I rarely care about the exact order of operations, just which ones are actually being executed. In that regard, the improved version allowed me to comprehend the gist of what was happening much faster than the regular version did. For a few seconds, before even attempting to start comprehending the actual operations being executed, my eyes were stuck trying to comprehend the parentheses.
    2. acomjean · · focus · HN ↗
      Lisp is why I started using emacs and its parens matching features.
    3. whalesalad · · focus · HN ↗
      I don&#x27;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&#x27;s the fault of the programmer who is wielding it.

      1. kccqzy · · focus · HN ↗
        [delayed]
        1. whalesalad · · focus · HN ↗
          We can agree to disagree
    4. Avshalom · · focus · HN ↗
      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 &quot; &quot; line)
      
      image if the whole function was

        (defun split (line)
          (remove [\(word) (= &quot;&quot; word)] [split-string &quot; &quot; line]))
      
      or even

        (defun split (line)
          (remove &quot;&quot; [split-string &quot; &quot; line]))
      
      
      *using [] in place of rainbow parens for clarity of sub arguments
      1. Jtsummers · · focus · HN ↗
        [delayed]
        1. Avshalom · · focus · HN ↗
          I mean ask OP, I don&#x27;t know what&#x27;s what in the Scheme rXrs or Common Lisp standard libraries.

          Although my general stance remains, most lisp code bases I&#x27;ve seen are remarkably verbose which leads to a glazing over far more than the lack of distinct symbols or prefix notation

      2. fweimer · · focus · HN ↗
        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&amp;R C actually required similar type-encoding in field names because field names were global:

        <a href="https:&#x2F;&#x2F;usenet.trashworldnews.com&#x2F;?thread=288637" rel="nofollow">https:&#x2F;&#x2F;usenet.trashworldnews.com&#x2F;?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) &#x2F; 2;
        
        It is actually not so terrible with a sufficiently streamlined prefix syntax:

            (setf x p3 (&#x2F; (+ (. 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 &#x27;s into (quote s). Then we get this:

            (setf x p3 (&#x2F; (+ p1.x p2.x 2)))
        
        Or if there is a concept of a place:

            (set p3.x (&#x2F; (+ p1.x p2.x 2)))
        
        But that probably needs static typing for an efficient implementation (or set needs to deconstruct its first argument).
  4. lukaszkorecki · · focus · HN ↗
    It&#x27;s the same thing that makes reading Swift code hard if you never worked with it: lack of familiarity.
    1. sinabis · · focus · HN ↗
      Exactly. Assembler looks like Gobbledegook. But if you have worked with it for a year it looks like a perfect and delicious dish.
  5. ltbarcly3 · · focus · HN ↗
    1. it violates normal syntax rules you have been practicing since you were 4 years old.

    Lisp will say:

      (+ (- (\* 3 5) 7) (&#x2F; radius pi))
    
    but you are taught since 5:

      (3*5 - 7 + radius&#x2F;pi)
    
    2. Humans are highly adapted to using language, and understanding language constructs such as implicit context rules. Humans reduce token counts and structure in favor of implicit rules and making common patterns shorter. Lisp makes them all explicit, which forces you to cope with way more tokens. Lexical binding was added to Common Lisp almost as an afterthought, and the way LET&#x2F;LET* force you to add layers of nesting demonstrates that. Every time you assign a variable the &#x27;modern&#x27; way, you have to indent another block of code.

    A concrete example is introducing local bindings with actions in between. The thought is &quot;calculate this, do something, then continue&quot;:

      user = find_user(user_id)
      require_admin(user)
      report = build_report(user)
      write_audit_log(user, report)
      receipt = send_report(report)
      record_delivery(receipt)
    
    In Common Lisp, a direct translation adds a level of nesting for each binding:

      (let ((user (find-user user-id)))
        (require-admin user)
        (let ((report (build-report user)))
          (write-audit-log user report)
          (let ((receipt (send-report report)))
            (record-delivery receipt))))
    
    This is much closer to what is actually happening, and does not require you to understand scoping rules, but it&#x27;s cumbersome and stupid.

    LET* handles consecutive bindings, but here the actions must happen between them. You can use PROGN inside the initializers, or introduce dummy bindings for the actions, but either way you&#x27;re restructuring a flat sequence to fit the binding syntax.

    That&#x27;s the implicit context I mean: the statement order combined with syntax rules of the language can supply the scope, without requiring a new enclosing expression every time you introduce a local. Lexical scope itself doesn&#x27;t require this nesting to be explicit in the syntax of the language and it&#x27;s not helpful for it to be.

    3. So many inconsistencies.

    Common Lisp uses alternating keys and values for property lists:

      &#x27;(:name &quot;Ada&quot; :age 37)
    
    Association lists use a list of pairs:

      &#x27;((:name . &quot;Ada&quot;) (:age . 37))
    
    And LET uses two-element binding lists:

      (let ((name &quot;Ada&quot;)
            (age 37))
        ...)
    
    Those aren&#x27;t interchangeable conventions. In an association list, (:name . &quot;Ada&quot;) pairs the key with the string; (:name &quot;Ada&quot;) pairs it with a one-element list containing the string.

    Lookup conventions differ as well:

      (getf plist key)
      (gethash key table)
      (assoc key alist)
    
    GETF puts the container first; GETHASH and ASSOC put the key first. ASSOC also returns the matching pair, whereas GETF and GETHASH return the value as their primary result.

    The parentheses give you a uniform surface syntax, but you still have to learn whether a construct expects alternating entries, dotted pairs, or binding lists, and which argument comes first.

    1. iLemming · · focus · HN ↗
      [delayed]
      1. ltbarcly3 · · focus · HN ↗
        No, Common Lisp was not Lexical from day one. You are not familiar with the history. It was more or less a merging of several lisp dialects each sponsored by a different lisp machine vendor. Many of those were primarily not lexically scoped, although Zetalisp did add modern lexical scoping by 1985.

        Steele himself mentions the lack of lexical scoping in contrast to scheme. <a href="https:&#x2F;&#x2F;research.scheme.org&#x2F;lambda-papers&#x2F;lambda-papers-compiler-optimization.html" rel="nofollow">https:&#x2F;&#x2F;research.scheme.org&#x2F;lambda-papers&#x2F;lambda-papers-comp...

        &gt; I don&#x27;t even want to waste my time to unpack.

        It is typical for people who can&#x27;t respond substantively to brag about how they could respond but imply their relative status makes doing so beneath them.

          (local
            (def user (find-user user-id))
            (require-admin user)
            (def report (build-report user))
            (write-audit-log user report)
            (def receipt (send-report report))
            (record-delivery receipt))
        
        What the hell is that supposed to be? It&#x27;s not common lisp. `local` is not defined in CL, it is a keyword in Racket that does something like what you typed there, but not really the same.

        Anyway I don&#x27;t know what you are showing here but it&#x27;s nonsense in every language I&#x27;m aware of.

        <a href="https:&#x2F;&#x2F;www.lispworks.com&#x2F;documentation&#x2F;HyperSpec&#x2F;Front&#x2F;X_Mast_L.htm" rel="nofollow">https:&#x2F;&#x2F;www.lispworks.com&#x2F;documentation&#x2F;HyperSpec&#x2F;Front&#x2F;X_Ma... (no local there)

        <a href="https:&#x2F;&#x2F;www.lispworks.com&#x2F;documentation&#x2F;HyperSpec&#x2F;Front&#x2F;X_Mast_D.htm" rel="nofollow">https:&#x2F;&#x2F;www.lispworks.com&#x2F;documentation&#x2F;HyperSpec&#x2F;Front&#x2F;X_Ma... (no def either)

        1. Jtsummers · · focus · HN ↗
          [delayed]
          1. ltbarcly3 · · focus · HN ↗
            OK, Common Lisp as described by the standardization process has always had lexical scoping, no argument there. Lisp, including the variants of Lisp that CL was largely derived from, did not always have lexical scoping.

            So what you are saying is a lot like if I said &quot;C++11 has ALWAYS had the auto keyword!&quot;. While I ignore the fact that C++ did not always have the auto keyword, and the repeated typing of the same type signature over and over was a major complaint about the language for over 20 years. Yes, it&#x27;s true, but it&#x27;s just ignoring reality and not informative to the overall point I was making, which was Lisp is clearly not designed to make lexical scoping &#x27;nice&#x27;, because lisp predates the use of lexical scope being the dominant way to do scoping. You can see that in the very conception of scheme, originally designed to be &quot;Lisp but with lexical scoping&quot;.

            Edit: corrected responding to the wrong person. For the record &quot;Jtsummers&quot; and &quot;iLemming&quot; do look quite a bit more alike than two random usernames!

            1. Jtsummers · · focus · HN ↗
              &gt; You are ignoring the part where you don&#x27;t actually know Common Lisp and write nonsense code.

              Read the usernames, &quot;Jtsummers&quot; and &quot;iLemming&quot; don&#x27;t even look alike.

              EDIT:

              &gt; So you&#x27;re saying it had it from day 1 post standardization effort being abandoned (since the ratification members never voted to ratify it), not day 1 of being a language developed originally as Maclisp and later standardized.

              CLTL1 (the book I referenced) was published in 1984, over a decade before standardization which is what you&#x27;re referring to.

            2. iLemming · · focus · HN ↗

              [dead]

            3. Jtsummers · · focus · HN ↗
              [delayed]
            4. iLemming · · focus · HN ↗
              [delayed]
        2. iLemming · · focus · HN ↗
          [delayed]
          1. ltbarcly3 · · focus · HN ↗
            Ok, so the original question was &quot;Why is Lisp so difficult to read?&quot; and your answer is it&#x27;s not, so long as you fix the things that make it difficult to read?

            How does that help me read Lisp code more easily? When I open a file with Lisp code in it, I just say to myself &quot;this would be easier to read if they used serapeum instead of writing it in normal idiomatic Lisp&quot; and then it&#x27;s easier for me to read?

            1. iLemming · · focus · HN ↗
              [delayed]
              1. ltbarcly3 · · focus · HN ↗
                So in your mind assigning variables and calling functions is &quot;contrived&quot;? LOL ok
                1. iLemming · · focus · HN ↗
                  [delayed]
                  1. ltbarcly3 · · focus · HN ↗
                    Lisp has had massive investment and almost 0 adoption, even in it&#x27;s heydey. It&#x27;s been dying for 50 years lol. It&#x27;s crap.
                    1. iLemming · · focus · HN ↗
                      [delayed]
                      1. ltbarcly3 · · focus · HN ↗
                        Look at Clojure job listings. Over 80% are trying to hire people to port them off Clojure. The community is insular and not growing and has been shrinking for a decade while the rest of the industry has grown 5x.

                        Truly a success story.

                        1. iLemming · · focus · HN ↗
                          [delayed]
  6. whalesalad · · focus · HN ↗
    Personally, I find that a lot of LISP hackers put way too much logic into a single form or method rather than breaking it into smaller components that can be composed together. And I think that&#x27;s often why we see frustration with LISP is that you&#x27;ll have something that is indented really deep when it could be a much smaller function that&#x27;s leveraging other functions. It&#x27;s even worse in certain lisps like Clojure, where you&#x27;ll see a lot of shorthand symbolic stuff, like for anonymous functions, or when you&#x27;re using core.async, where you look at it and you think, is this brainfuck?
    1. joshlemer · · focus · HN ↗
      And the reason that LISP code tends to be reluctant to split things out into multiple forms with variable assignment IMO is because it introduces a new level of nesting. It&#x27;s too much friction to go from

          (defn foo [] 
             (+ 1 2))
      
      to

          (defn foo []
            (let [x 2]
               (+ 1 x)))
      
      I wish that there were some kind of macro available in Clojure that would provide a local &quot;def&quot; kind of functionality that doesn&#x27;t pollute the namespace and just creates a binding in the parent scope. So that you could do something like:

          (defn foo []
             (let! x 2) 
             (+ 1 x))
  7. thewillowcat · · focus · HN ↗
    It is not.
  8. meken · · focus · HN ↗
    I think it has to do more with infix vs. prefix notation - infix is more natural and easily understood.
    1. Jtsummers · · focus · HN ↗
      [delayed]
      1. tgv · · focus · HN ↗

        [dead]

    2. iLemming · · focus · HN ↗
      [delayed]
  9. pfdietz · · focus · HN ↗
    Lisp isn&#x27;t difficult to read, so I don&#x27;t understand the question.
    1. caaqil · · focus · HN ↗
      &gt; Lisp isn&#x27;t difficult to read

      You&#x27;d be surprised how seemingly simple things can be hard for some. As an example, it&#x27;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&#x27;s a very smart strategy, I must say.

      1. mpalmer · · focus · HN ↗
        You should really follow the HN commenting guidelines, specifically #1, 7 and 11.
        1. caaqil · · focus · HN ↗
          &gt; follow the HN commenting guidelines, specifically #1, 7 and 11

          This never occurred to me, you should really think about accompanying dang on his tireless job here, and maybe even get some dough along the way. I appreciate the insightful suggestion.

      2. iLemming · · focus · HN ↗
        [delayed]
        1. Neywiny · · focus · HN ↗
          That went to Nazism real fast. But the thing is, most people don&#x27;t think the Holocaust is a hoax (I think), whereas most people do think Lisp is difficult to read.
          1. pfdietz · · focus · HN ↗
            There have been lots of attempts to &quot;improve&quot; Lisp over the years (starting from the very earliest days) that assumed the primary thing holding it back was the syntax. All went nowhere, since that assumption is false. If you spend enough time to become familiar with the language (which you have to do with any new language) the syntax becomes a non-problem.
          2. iLemming · · focus · HN ↗
            [delayed]
            1. Neywiny · · focus · HN ↗
              My guy, most people are unfamiliar with Lisp
              1. iLemming · · focus · HN ↗
                [delayed]
                1. Neywiny · · focus · HN ↗
                  .... Veritasium and a ton of other YouTubers made entire careers off of that. Steve Mould, the action lab... I mean there are so many
                  1. iLemming · · focus · HN ↗
                    [delayed]
    2. stcg · · focus · HN ↗
      Exactly, it&#x27;s just unfamiliar to most people.

      I find Clojure much more readable than many other languages. It&#x27;s even the style I like for pseudocode. Because I used it a lot. It&#x27;s familiar.

      &quot;Easy&quot; is relative and doesn&#x27;t mean anything without a subject. Easy for whom?

  10. shevy-java · · focus · HN ↗
    (The(.

    People say we can ignore them but I find the difficult to ignore.

    But this is not the only problem with lisp syntax. I found that reading Ruby or Python is simply, on average, so much more efficient.

    I found scheme somewhat readable - see haxima game world, <a href="https:&#x2F;&#x2F;sourceforge.net&#x2F;projects&#x2F;nazghul&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sourceforge.net&#x2F;projects&#x2F;nazghul&#x2F; it contains scheme files - but I would not want to write any game logic in it.

  11. groundzeros2015 · · focus · HN ↗
    Unfamiliarity.
  12. waffletower · · focus · HN ↗
    There is so much conjecture in this article -- take the difference between &#x27;lisp formatting&#x27; and &#x27;javascript formatting&#x27;. I use so-called &#x27;javascript formatting&#x27; (a decided and embarrassing misnomer) routinely when I develop Clojure. This article exudes inexperience with Lisp.
  13. delegate · · focus · HN ↗
    You get used to it after a while and at some point the parenthesis &#x27;disappear&#x27; and stop taking up mental cycles.

    I often thought about this - at first I struggled a lot and wasted so much time trying to match parens, but after some time my brain adapted and then I actually liked the syntax, especially if your editor supports selecting forms or you use something like parinfer, which matches parens based on indentation.

    Clojure has special syntax for collections of various types, so it&#x27;s even easier to parse after you get used to it imo.

    For me, the bigger challenge was wrapping my head around functional programming using immutable data structures, since that wasn&#x27;t just syntax, it required me to &#x27;unlearn&#x27; thinking in OO paradigm and adopting a new way of thinking about how the program works. You get used to that too after a while.

    1. JJMcJ · · focus · HN ↗
      Similar to syntactically meaningful indentation, as with Python.

      It&#x27;s weird for a half hour, then it&#x27;s second nature.

  14. piloto_ciego · · focus · HN ↗
    I love lisp and think it’s amazing. One of the things that commonly throws me off when I haven’t been writing it very much day to day is sometimes it’s unclear what’s going to be returned by a function.

    An explicit return 0 is a lot more obvious than just having a 0.

    Also, I’ll agree that a ‘ or a , in the wrong place is very easy to visually miss, then you can read a totally different meaning out of the code.

  15. tombert · · focus · HN ↗
    I&#x27;ll repeat what other people here have been saying: I don&#x27;t think Lisp is actually &quot;hard&quot; to read, in any objective sense.

    It&#x27;s &quot;difficult&quot; to read because it&#x27;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.

    1. so-cal-schemer · · focus · HN ↗
      I wouldn&#x27;t say &quot;never ambiguous&quot; (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.

      <a href="https:&#x2F;&#x2F;sarabander.github.io&#x2F;sicp&#x2F;html&#x2F;3_002e2.xhtml#FOOT140" rel="nofollow">https:&#x2F;&#x2F;sarabander.github.io&#x2F;sicp&#x2F;html&#x2F;3_002e2.xhtml#FOOT140

  16. aaroninsf · · focus · HN ↗
    Hot take: it&#x27;s the recursive referential grammar, which does not have an analog in human natural language.

    Human languages have hard limits on the reference tracking they support, regardless of syntax (marking, positional grammar, etc.). Humans have to reason to unpack LISP (or deeply nested functions or delegation in other languages).

  17. bel8 · · focus · HN ↗
    Lisp is more diffucult to read for most devs because most devs are used to C&#x2F;Java -like synthax.

    If most devs were used to Lisp, it would be the other way around.

    It&#x27;s a chicken and egg problem, at this point.

    1. christophilus · · focus · HN ↗
      I think part of it is that English speakers say: “2 plus 2” not “plus 2 2”, so the infix notation matches our natural language and mental model.
      1. iLemming · · focus · HN ↗

        [dead]

      2. jcranmer · · focus · HN ↗
        Most languages use either subject-object-verb or subject-verb-object word orders, which together account for ~90% of world languages; verb-first word order languages only account for ~10% of world languages.
        1. Jtsummers · · focus · HN ↗
          [delayed]
      3. mike_ivanov · · focus · HN ↗
        - add two and two - compare apples to oranges - use observational skills
  18. boxed · · focus · HN ↗
    I don&#x27;t think it&#x27;s ONLY the parenthesis, it&#x27;s also the lost opportunity to do meaningful things with indent that bothers me. For example: a missing end paren is often obvious where it should end to a human reader because the next definition starts at some set indent level (0 being the most obvious one). But we talk a different language to the compiler and to the human so the error message is far from where it would be useful.

    Significant whitespace is actually a good thing™, even if you only use it to narrow compiler error messages. You can still have your parens but also get way better error messages if you just use the indent!

  19. neilv · · focus · HN ↗
    I have a suspicion that 99.999% of people who say that Lisp syntax is difficult to read haven&#x27;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).

    &gt; 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&#x27;s more a shape, because the it&#x27;s a nicely rounded shape that contains the whole function application&#x2F;call:

        (foo x y z)
    
        foo(x, y, z);
    
    There is a small chance that you&#x27;re doing the following in a Lisp or C, but you&#x27;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&#x27;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&#x27;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&#x2F;dialect extension for square brackets for this, if the Lisp doesn&#x27;t already have comparable syntax:

        [m a b c]
    
    In both references and setters; see my most recent mention of it: <a href="https:&#x2F;&#x2F;mastodon.online&#x2F;@neilvandyke&#x2F;117067069023420085" rel="nofollow">https:&#x2F;&#x2F;mastodon.online&#x2F;@neilvandyke&#x2F;117067069023420085
  20. z5h · · focus · HN ↗
    I think the biggest problem is that expressions are lists, but we build lists with quoting, AND unquoting (or quasiquoting). It takes some effort to look at an expression and be certain of what will be run. Are we displaying the instructions to erase the hard drive, or the output of erasing the hard drive.

    Compare this with Prolog. I like to say &quot;a term is just a term until it&#x27;s a goal&quot;. Assuming we have an erase_hard_drive&#x2F;1 predicate, I know it&#x27;s safe to do `write_term(erase_hard_drive([force,silent,noprompt]), [])` or `EraseCommand = erase_hard_drive([force,silent,noprompt])`.

  21. bcrosby95 · · focus · HN ↗

      because(
        mostly,
        are(
            calls(function(nested)),
            rarely(thing(a, in(c)))
        ),
        of(
            and(
                mutation(the),
                nature(imperative, of(c))
            )
        )
      );
    
    Use more temporary variables. Use whitespace. Use named functions. You need to pay more attention to this because its so easy to just nest one more function call.
  22. adityaathalye · · focus · HN ↗
    What makes Lisp difficult to read is that almost everyone comes to a Lisp, with deeply ingrained writing skills suited for syntax-heavy, non-structurally-editable languages.

    ---

    Now, to die on this hill.

    Speaking as someone who desperately wants people to stop inventing syntax, I want to offer my &quot;inversions&quot; of the author&#x27;s conclusions.

    &gt; prefix notation puts parentheses further apart

    Prefix notation guarantees that I instantly know what the function &#x2F; operator is and what the operands are. I don&#x27;t see (or care) to literally read the parens. The parens are not the point.

    For this reason, when teaching someone a Lisp, I spend almost no time teaching the semantic meaning of syntax rules. All I have to do is show how prefix notation works, and drill that a few times with hand-coding exercises.

    &gt; formatting practices do not help to track parentheses

    Auto-formatters---once again, because of prefix notation---can lay out code in very regular patterns and shapes. Auto-formatting further obviates the visual &#x2F; aesthetic relevance of parens.

    Not to mention smartparens and structural editing and other basic niceties of Lisp text editors.

    &gt; prefix notation results in more left-nesting

    Perhaps. The value for me is that it results in more regular code, because, once again, standard prefix notation, and once again, standard auto-formatting. Nobody reads closing parens, or opening parens, or whatever other parens... we let our text editor take care of that stuff for us.

    &gt; Lisps lacks or discourages features that align the evaluation and reading order

    This depends on whether the Lisp in question is imperative, procedural, or functional. It has nothing to do with S-expressions...

    Essentially, the author makes the usual category error of conflating &quot;Lisp&quot; with &quot;s-expression&quot;.

    May I suggest associating &quot;Lisp&quot; with &quot;Metaprogramming&quot; as the better evil? Die-hard Lisp-2 nerds will balk, but I say any language with an ability to symbolically manipulate itself as its own data is a Lisp. For example, Julia is a kickass Lisp because it enshrined meta-programming as a first-class language design concern. Ditto Elixir. I&#x27;m happy thinking of those as M-Expression Lisp-likes.

    And as a matter of personal taste, having been around lisp nerds, nobody who actively writes s-expression languages---even as hobbyists---reads parens. They&#x2F;we see shapes and we manipulate our code like tetris, without even having to think about &#x27;em parens, and soon enough, nor about the keyboard shortcuts.

    Whether Emacs, or Vim, or VSCode, or IntelliJ or, whatever Lisp-aware editor, we simply slurp and barf and splice and unsplice and convolute-sexp, all of which I do as a normal part of Lisping <a href="https:&#x2F;&#x2F;emacsrocks.com&#x2F;e14.html" rel="nofollow">https:&#x2F;&#x2F;emacsrocks.com&#x2F;e14.html ... And this stuff is so readily possible because of the regularity of prefix-notation s-expr syntax.

  23. iLemming · · focus · HN ↗
    [delayed]
  24. DonaldFisk · · focus · HN ↗
    Some of the Lisp features that people don&#x27;t like are built into the language. If you don&#x27;t like them, there are other languages you can use instead. If you&#x27;re already using a language you prefer, why are you complaining about Lisp?

    Some features are dialect dependent. If you like the idea of a Lisp, but specifically don&#x27;t like e.g. Common Lisp, Scheme and Clojure are alternatives. If you don&#x27;t like these either, nothing is stopping you from writing your own Lisp and using that instead. I have. Lisp is one of the easiest languages to implement and there are two excellent books explaining how to do just that.

    And if your problem is just with formatting or getting the parentheses right, you&#x27;re probably using the wrong editor. You won&#x27;t have these problems with EMACS.

  25. fxj · · focus · HN ↗
    You think Lisp is hard to read? Then try J! And still people use it and are very successful. It is not always the ease of readability but the power of the syntax that makes a good programming language.

    <a href="https:&#x2F;&#x2F;www.jsoftware.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.jsoftware.com&#x2F;

    p.s. R is Lisp with a nice syntax. Much more readable and still very powerful.

    just my 2 ct

  26. fxj · · focus · HN ↗
    R is already a Lisp dialect disguised in algebraic syntax. Here is the first example in R:

      factorial_recursive &lt;- function(n) {
        if (n == 1) {
          return(n)
        } else {
          return(n \* factorial_recursive(n - 1))
        }
      }
    
    <a href="https:&#x2F;&#x2F;cran.r-project.org&#x2F;web&#x2F;packages&#x2F;codetools&#x2F;codetools.pdf" rel="nofollow">https:&#x2F;&#x2F;cran.r-project.org&#x2F;web&#x2F;packages&#x2F;codetools&#x2F;codetools....

    then gives:

      (&lt;- factorial_recursive (function as.pairlist(alist(n = )) (&quot;{&quot; (if (== n 1) (&quot;{&quot; (return n)) (&quot;{&quot; (return (* n (factorial_recursive (- n 1))))))) NULL))
  27. arunix · · focus · HN ↗
    Somewhat related: Readable Lisp S-expressions Project

    <a href="https:&#x2F;&#x2F;sourceforge.net&#x2F;p&#x2F;readable&#x2F;wiki&#x2F;Problem&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sourceforge.net&#x2F;p&#x2F;readable&#x2F;wiki&#x2F;Problem&#x2F;

    (I learned Lisp in the 90&#x27;s and enjoyed it, but I still find it difficult to read.)

  28. juancn · · focus · HN ↗
    It is too uniform, which makes it hard.

    Everything is a list or an atom. There&#x27;s no variety and it doesn&#x27;t take advantage of pre-existing knowledge.

    For example, in most curly braced languages a block is very different from an argument list, not so in Lisp.

    There&#x27;s not many visual cues of what function something does, anything can be anything.

    Even math expressions are weird (because there aren&#x27;t any), you cannot leverage years of training reading simple math notation to make sense of stuff.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.