‹ BackHN Continuity

Thread

What makes Lisp difficult to read?

47 points · 81 comments · ibobev

  1. 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.

    I like extreme parsimony, like I&#x27;d love to write stuff like

       format = lambda: `%1-%2`
    
    but I think as complexity goes up depending on the meaningful order of elements breaks down in many ways and you need to give things meaningful names.
    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.

        One reason why our tools suck is that we are stuck representing programs as trees when they are really graphs.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.