-4

As the title says, what's the appeal of LISP?

I've seen it raised to high heavens and back and then put on a pedestal over an over. I've seen it done by by people here, by actual programmers that I know, by university professors that try to look like the kind of enlightened guys who have obviously transcended the plebeian language-war and would rather die than commit the heresy of saying that one language is better than another.

I tried to learn it, I looked at a few tutorials, at the "learn x in y minutes" page for both lisp and clojure(since from what I understand it's lisp running on the jvm with more FP thrown in), and I understand the syntax and how to do stuff in it. And I went back to tutorials about it several times over the last few months but every time the syntax made me want to look for a high-school kid and yell at him for messy code because looks like a C-style if-condition gone wild with all the nested parentheses and simple things seem to become a chore. What lisp seems to do in a few lines, other FP languages like Haskell or F# or even non FP languages like C# who just discovered that map and filter are a thing seem to do in much less in a much more expressive way.

Am I looking at this wrong? Is there some click that needs to happen? Did I only find crappy resources?(if yes please give me some good resources for learning lisp/clojure, preferably with some exercises)

What in the ... is the appeal of lisp? Honest to God question here.

Thank you in advance!

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
Rares Dima
  • 1,575
  • 1
  • 15
  • 38
  • Related: https://stackoverflow.com/q/172798/3303195 – faintsignal May 08 '18 at 08:53
  • What Lisp dialects do in a few lines, other languages like Haskell, F# or C# do with a convoluted syntax that is full of ambiguities which are resolved by grammar rules. Before that syntax is available, the programmers have to wait for some committee to design it, and someone to stick it into the compiler; the Lisp hacker just bangs out a few macros. Before the committee designs it, they first decide what is important enough to be designed in; you're in luck if that is what you wanted, otherwise not. – Kaz May 10 '18 at 02:09
  • In short, the appeal of the Lisp approach to designing programming languages is: knocking down the barrier between the programmer and language in constructive, disciplined ways. – Kaz May 10 '18 at 02:13
  • @Kaz not to start a flame war or anything, which I am the least qualified for, but by the same token Lisp's convoluted syntax is full of ambiguities which are resolved by the semantics of this or that special form. Haskell has its macros too, aka Template Haskell. And some actually regard Haskell (MLs, ...) as kind of a Lisp in disguise, too. It's got `cons`, `car` and `cdr`, after all. :) And `destructuring-bind` aka pattern-matching. – Will Ness May 10 '18 at 11:07
  • Lisp expresses program structures as data literals: lists or, in Clojure's case, sequences in general. The escape convention is that such literals are interpreted as operator + operands. You (usually) lose infix operators, operator priorities, and all the other comforts of conventional algebraic notation. You gain regular (essentially absent) syntax, clear meaning, and the power to manipulate programs as data structures. Is it worth it? I think so. YMMV. – Thumbnail May 10 '18 at 12:51

1 Answers1

13

When I first heard about Clojure in 2009, I wrote a blog post titled "Clojure: Where's the Elegance?" I was a big fan of Python's style of elegance at the time ("executable pseudo-code"), and Lisp was deeply unfamiliar. I continued wrestling with Clojure, though, because "list processing" seemed like an important programming paradigm to have in my toolset. I used a lot of JavaScript, Ruby, and C# for a while, and on my own time played with ClojureScript. When I finally came back to Python in 2017 to do some data-munging, I discovered I was writing a lot of Clojure-inspired functions to help. Finally, I just started writing the data-processing in Clojure, and I wouldn't go back. So while you've asked a question that may not be answerable, perhaps I can shed some light on what accounts for the difference between your perspective and the enthusiasm of the Lisp community.

First, while Lisp is very alien coming from the rich grammars of C, Python, and Ruby, the lightness of Lisp's syntax turns out to be a tremendous blessing. It relieves a lot of cognitive burden. Many kinds of syntax errors completely disappear. But by far the most good I get out of Lisp's consistent grammar is how easily it can be transformed. What I miss most when working in other languages is the ability to rearrange the AST without having to fiddle with the actual text of the code. Working with Lisp is far more fluid than any other language I've experienced.

Second, it's trivial to control how code is evaluated. A lot has been written about the glory of macros, but to me the fundamental superpower is that you can prevent code from being evaluated, evaluate it in a specific order, or evaluate it multiple times, all without the syntactic overhead of wrapping that code in a function. That said, I don't write macros very much, but when I do, a function is a poor substitute.

Third, most languages don't have very good support for live coding. I typically don't use the REPL itself, but rely on an editor integration to evaluate code. Clojure's tooling is good enough that I can mold an entire codebase with dozens of namespaces without ever having to restart the JVM process or split a single big code file into separate modules.

Fourth, Lisp code tends to compose extremely well. Between everything being an expression that returns a value and the language being built on a relatively small set of data structures, you can mix and match language constructs with great liberty. That opens up a lot of possibilities where other languages put up walls.

The common factor of all these is that the language does its best to get out of your way. When I was a novice programmer, the complex grammars of C and Python and Ruby was an aid to programming. It kept me on the straight and narrow. The language constructs were like landmarks to navigate by. Lisp, without those landmarks, can feel like a foreign country. But as you get more familiar with Lisp, other languages feel artificially constraining and hard to move around in, like driving on roads when you could be flying. Lisp is very freeing, but from my personal experience, I can tell you that, like flying, it takes practice before the strangeness of it turns from fear to freedom.

exupero
  • 9,136
  • 8
  • 47
  • 63
  • 1
    I totally like your last sentence :-) – Stefan Kamphausen May 08 '18 at 16:19
  • Thank you. I see how the first point that might motivate people. But as for the others... For the second, that may have been true in the past but this becomes easier and easier in new languages, language designers are starting to realize that lazy might be good. I dont really agree with the third in the sense that... you gain what exactly. You do not have to restart the jvm but what advantage does that give you aside from a good feeling? How is it functionally any better from any other interpreted language with no compilation step where restarting the execution is basically instant? – Rares Dima May 10 '18 at 22:57
  • As for the fourth... while I understand that, I tend to affirm that more and more languages give you freedom nowadays, and the freedom lisp gives... comes at a grave price of expressiveness. But regardless of our opinions, thank you for putting the effort in to explain it. After learning lisp multiple times I understand why people say it is freeing and comparing it to flying, while something like C would be like "walking", but I find that from my own experience, while other languages do not give the same freedom, they give much more in the way of expressiveness. – Rares Dima May 10 '18 at 23:03
  • The thing that comes most naturally to me when I hear the "lisp is like flying" idea(that i consider 100% accurate) is something along the lines of "it might let you fly at will but a well-designed language will feel like riding a rocket, harder to steer but magnitudes more powerful" – Rares Dima May 10 '18 at 23:07
  • @RaresDima That's clearly false: if there is a feature some other language has then that feature can be added to Lisp since Lisp is extensible. The whole approach to programming in Lisp is *building a language to express the solution to your problem*. –  May 15 '18 at 11:38
  • @tfb I do not know lisp so I will just ask: 1. Can you create new *infix* functions, not just operators, but functions? 2. Can you get rid of the "logical expression gone wild" look(remove parenthesis)? 4. Can you do that without first spending a considerable amount of time working with the language as it is, which quite simply would be unpleasant? – Rares Dima May 16 '18 at 10:44
  • 1
    @RaresDima Yes, yes, and I am sure in your case, no. –  May 16 '18 at 15:53
  • @tfb Thank you for your answer, pretty reassuring actualy. I am curious about the "in your case", is there something special about me? – Rares Dima May 17 '18 at 09:03
  • 1
    @RaresDima you've made it pretty clear you're not going to like Lisp and aren't really interested in understanding what makes it interesting. Which is fine: not everyone likes Lisp the same way not everyone likes The Fall, say. –  May 17 '18 at 12:00
  • @tfb I do not dislike it, I don't hate it though, but I *want* to like it and am interested in understanding it's appeal. That's the entire point of my question. I've decided to give clojure a try due to (much)better ide support. – Rares Dima May 17 '18 at 12:37
  • Note that Clojure is quite alien to users of actual Lisp. – Kaz May 06 '19 at 22:32