5 ms·
This was the page that made me finally grasp why Lisp and s-expressions are relevant. After reading this about a year ago, I ended up picking up a Clojure book
by Slackwise 11y ago
This was the page that made me finally grasp why Lisp and s-expressions are relevant. After reading this about a year ago, I ended up picking up a Clojure book and now I'm enamored with s-expressions. I feel late to the party.
The last time I tried to learn Lisp (prior to reading this) was in like 2003/4 from some CLISP tutorial that scared me away from having nothing but math examples and zero explanation of the philosophy or design. It felt like an esoteric and purely academic language, and I brushed it off as not worth my time. (I was never really put off by the parens, and now I love them. Never understood that aspect of Lisp discourse. Once you learn ParEdit[1] you don't want to go back.)
Now I link this page whenever I want to explain to someone why there are "all these parens". It's dated, though, and associating s-expressions with JSON and JavaScript would probably be a more contemporary approach. Maybe I should rewrite this article for a modern developer audience.
[1]: http://danmidwood.com/content/2014/11/21/animated-paredit.html http://danmidwood.com/content/2014/11/21/animated-paredit.ht... "GIFs of ParEdit in action"
- frou_dh 11y agoThere's a "lisp parens lol" thing among programmers that's so intellectually lazy. I once interviewed someone who I noticed had explicitly mentioned Lisp on their resume, and when as an aside I asked what their thoughts on Lisp development were, all they could muster was "Oh god the parens hyuck hyuck".
- mbrock 11y agoOther languages tend to get a free pass, but I take every chance I get to whine about JavaScript's three kinds of parens that I have to keep track of manually, and the convention of putting nearly every closing paren on its own line, wasting kilometers of space.
- chucksmash 11y agoTruer for some languages than it is for others... "Oh god, syntactically significant white space!"
- acc54321 11y agoI'm more bothered by Python's lack of homoiconicity (thus no good macro facility) and poor performance when compared to Common Lisp. Python feels a bit like a toy Lisp with all the adult parts hidden.
- oldmanjay 11y agoYeah that screen space, truly a limited resource. You should cram everything together and don't forget to be extra clever in the middle of the dense unreadable forest of sigils as well. It was hard to write, it should be hard to read.
- mbrock 11y agoWhile your sarcasm is mildly amusing, your point doesn't apply. I don't advocate writing cryptic code. Of course I prefer code that is easy to read. That's a major basis for my opinions on syntax. Do you think Python's syntax is cryptic and hard to read, because of the lack of end parens? Or did you just misunderstand my point completely?
- bad_user 11y agoWhile I agree that in programming we should break our code in logical paragraphs, just like in prose, such conventions (placing closing brackets on their own line) are detrimental for that purpose. For me this doesn't have anything to do with wasting vertical space, as it has to do with aesthetics. I'm not really speaking for LISP, but in my projects what really bothers me are people that don't have common sense when indenting / formatting their code and so they start using IDE or build plugins, using common conventions and formatters that will never be able to understand the meaning of the code being formatted, making a total mess of other people' carefully crafted code. And we go round and round on this.
- agumonkey 11y agoThe mainstream may realize how syntax doesn't really matter. The FP push helps a lot already (map,filter,streamfusion instead of crazy for/while statements).
- AnimalMuppet 11y agoWhy do you call for and while statements "crazy"? Because it's possible to write them wrong? Because you think it's crazy to have to write them at all? Why?
- agumonkey 11y ago> it's possible to write them wrong too easy languages to conflate a lot of logic into large side effectful statements. FP forces you to separate layers, and deforestation (when available) helps reclaiming space/time costs.
- AnimalMuppet 11y agoAll right, but "can be misused" is not the same as "crazy".
- agumonkey 11y agoAlright, that was my own misunderstanding of loop invariants and scope showing. That gave opportunity for traumas when I started reading imperative code.
- spacemanmatt 11y agoSeems fair to assume pp calls them crazy because they don't compose.
- aaron-lebo 11y agoI don't know that it is intellectually lazy. It makes a lot of sense. If a lisp dialect had a large, vibrant ecosystem on the scale of Python or Javascript, then a lot of people would see the parens, see the advantage of having them, work their way through it and eventually get used to them and even embrace them because they see a real payoff. That's not the case with lisp dialects. The major payoff with lisp dialects is macros. But for most people, it isn't obvious why they are important. They are something you have to use to really get. So the intellectually reasonable position for most people is to either ignore lisp or laugh at it. Meanwhile, you see endless articles like this posted over the years (not knocking the article itself), trying to explain lisp in a kind of reverence and terminology usually associated with religious texts. "Hey, brother, you just need to see the light". I've been doing quite a bit of Clojure coding lately and I love it. I just can't see a lisp ever catching on. Actually, the project I'm working on is a lisp that does not look like a lisp but compiles down to Clojure. The parens aren't really necessary for lisp's best feature, as seen by Elixir. Here's a bit of my language: " " join([1, 2, 3]) count println
- mbrock 11y agoTo "ignore or laugh at" a whole family of important and interesting languages because they aren't as popular as Python or JavaScript is exactly laziness, or at best pragmatic, but has nothing to do with intellectual reasonableness.
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- aaron-lebo 11y agoWhy is being pragmatic not intellectually reasonable?
- 11y ago
- j_m_b 11y agoI really like the Clojure's minimalistic EDN format syntax. In comparison, Scheme and Common Lisp seem like they have superfluous parens.
- breuleux 11y agoI think most people have an irrational dislike of s-expressions, but that at the same time, s-expressions are not as good as their proponents think they are. There's a certain aesthetic "purity" to them that's seductive, but from a practical standpoint, it is quite reasonable to adapt syntax to common patterns. The issue with mainstream languages isn't that they do that, it's that they do it too much. But there are syntactic schemes besides s-expressions that allow for good flexibility. For instance, in my programming language Earl Grey[1], I use this very simple sugar: `a b: c` <=> `a(b, c)`. So you can use this todo syntax if you want, and it will just work: todo "housework": item priority(high): "Clean the house." item priority(medium): "Wash the dishes." item priority(medium): "Buy more soap." Interestingly this has one advantage over s-expressions: whereas Lisp editors usually need to specify a special highlighting/indent policy for keywords like `let`, here editors can just highlight/indent `a b: c` indiscriminately. I also think a limited number of infix operators are worth defining in most languages, and I don't mean arithmetic operators (although I'm okay with them). I mean ubiquitous or easily repurposed operators like assignment/declaration, lambda, pairing, or commas. In my view, Lisp-like languages hold to standards of purity that are unreasonable (don't get me wrong, they are quite usable, just not optimal according to any useful metric). [1]: http://breuleux.github.io/earl-grey/ http://breuleux.github.io/earl-grey/
- drakecoffeecake 11y agoI don't think that's much clearer than a lisp equivalent: (todo "housework" (item (priority high) "Clean the house.") (item (priority medium) "Wash the dishes.") (item (priority medium) "Buy more soap.")) Yours looks nicer, but if I wanted to operate on your todo there, it's not obvious how just by looking. With the lisp, it's obvious: There's a list of 5 elements. The last three are 'items', each of which is a list of 3 elements. The benefit of s-expressions isn't just that they're flexible in what you can write with them, but that they're easy to manipulate programmatically, and their structure is immediately obvious.
- kazinator 11y agoI would say there are too many distracting "tags" in that which may be unnecessary ("XML disease"). For instance, look how you just indicated with a tag that the elements of a list are "items". In Lisp! (todo "name" (item ...) (item ...) (item ...)). Basically the symbol todo is enough of a clue about the structure, and the pure syntax can determine most of the rest, with possibly a modicum of keywords here and there. (todo housework ;; symbols for naming! (:high "Clean the house") (:medium "Wash the dishes") (:medium "Buy more soap"))