4 ms·
> I've almost never seen someone learning the s-expression syntax and afterwards not liking it. I don't particularly like s-expression syntax - I think s-expre
by chrisseaton 7y ago
> I've almost never seen someone learning the s-expression syntax and afterwards not liking it.
I don't particularly like s-expression syntax - I think s-expressions suit the computer at the expense of the programmer, which I think is backwards. I think they're verbose and noisy and that obscures the meaning I want to see in the text as a person. Yes they're easier to parse, but I want to make my life easier, not the computers. And yes they're convenient for metaprogramming but I don't want to optimise for the meta case.
A concrete example - I'm very happy working with precedence. I've been doing it since I started school. My five-year-old can understand precedence. Using precedence I can reduce ceremony and noise in my code and allows me to more naturally look at an expression and take in its meaning. But s-expressions don't like using precedence.
- DonaldFisk 7y agoYou might argue that s-expression syntax is "worse is better" but I'd argue that more complex syntaxes are "accidental complexity." You need a parser, you need a more complex prettyprinter. Without s-expressions you also lose programmer access to the parse tree. For the usual arithmetic operators I've never had any problem, but I was once caught out when programming in C by getting the precedence of << and >> wrong (at least to me, it's counterintuitive), and it took a few hours to find the bug, because my code looked correct. Had I just parenthesized everything, that bug wouldn't have happened.
- lioeters 7y ago> s-expressions don't like using precedence I'd rather say that in s-expressions, precedence is regular and explicit. To me that's a strong argument in favor of it being more widely accepted as the standard. With infix notation, operators have implicit precedences, which feel natural to us only because it's what we were taught from an early age. I'm with the parent comment, that s-expressions ought to be advocated and evangelized (haha), as a foundational approach - even with arithmetic in basic school. If we had started thinking with it as a child, or at least later able to shed the legacy of infix notation, s-expressions are objectively simpler to understand, with fewer things to keep in mind. Well, that sounds stronger than I meant to. I mostly write in infix-style languages, and they flow fine. But I ideologically align with Lisps - there's a conceptual simplicity and beauty that really should have been the mainstream, and still may in the future.
- didibus 7y agoDo you mean precedence or infix? The choice of infix vs prefix vs postfix is semantic. What s-expression syntax imposes is to have everything balanced between brackets. For example, nothing prevents an S-expression based language to allow: (2 + 3) The only thing is there are no precedence rules, you must have parenthesis always: ((3 * 2) + 5)
- chrisseaton 7y agoWhy are you trying to explain s-expressions to me like I’ve never heard of them when I’m already in a thread debating their pros and cons for language design and implementation?
- didibus 7y agoI'm sorry that you are getting defensive and feeling like I'm attacking your expertise. But there's all kind of people with different experience levels on HN, so I prefer asking for clarification when I can instead of assuming things and talking over each other. If you truly meant precedence, well, I guess I disagree with you. Even in math, I prefer explicit parenthesised expressions for readability. If you meant infix, that's not a concern of s-expression so it's irrelevant to the syntax question. I know that personal preference is basically the reason for various syntaxes off course. But I think similar to how there's a movement that a common standard code formatting is better than everyone having their own custom formats, you could argue that having a common syntax which I think s-expression would make a great common syntax, could also yield an overall better outcome. And that's my argument here. Most languages have a: here's an s-expression based version of it. Like Python has Hy, Lua has Fennel, etc. So you already see a trend in how s-expression could easily cover all those languages, which is normal since they get closer to the parse tree anyways.