66

Lisp obviously is an advantage for the AI stuff, but it doesn't appear to me that Lisp is any faster than Java, C#, or even C. I am not a master of Lisp, but I find it incredibly difficult to understand the advantage one would get in writing business software in Lisp.

Yet it is considered as a hacker's language.

Why does Paul Graham advocate Lisp? Why did ITA Software choose Lisp over other high-level languages? What value does it have over these languages?

8
  • 21
    The line "I don't think Lisp is any faster than Java, C# or as a matter of fact faster than C" is somewhat confusing. C is typically held up as the standard for "fast code because you're programming close to the metal" -- it's the benchmark to beat for just about everything. Now, Java and other GC'd languages can beat it in some contexts, for example speed of memory allocation / cleanup. But, this sentence seems a little backwards nonetheless.
    – Michael H.
    Oct 4, 2010 at 15:11
  • 2
    Lisp is a higher level language than those you mentioned, thus is generally slower.
    – segfault
    Jan 13, 2011 at 23:23
  • 5
    @Bo Tian: "higher level language" needs an unambiguous definition. Even if it had one, this sounds like a non-sequitur. (thanks @Mark) Jan 14, 2011 at 22:50
  • 5
    @BoTian "higher level" does not equal "slower" by default.
    – user1249
    Jul 15, 2012 at 12:54
  • 28
    Lisp exists to show how wrong every other language designer has been.
    – user7519
    Apr 6, 2013 at 3:54

17 Answers 17

78

There are a few reasons I am working on becoming competent with Common Lisp.

  1. Homoiconic code. This allows structured self-modifying code.
  2. Syntax-aware macros. They allow rewriting of boilerplate code.
  3. Pragmatism. Common Lisp is designed to get stuff done by working professionals. Most functional languages aren't, as a rule.
  4. Flexibility. It can do a lot of different things, all at reasonable speeds.
  5. Wartiness. The real world is messy. Pragmatic coding winds up having to either use or invent messy constructs. Common Lisp has sufficient wartiness that it can get stuff done.

Arguably the only real reasons to choose against Common Lisp is that the standard libraries are dated.

I will go out on a limb and say that in the general case, syntax should not be an issue to a professional software worker.

15
  • 8
    Syntax can be an issue if it significantly affects readability or writeability. I don't think that's the case for Lisp. A good editor or IDE can do good enough syntax highlighting and paren matching to not be a big deal. Oct 4, 2010 at 22:36
  • 4
    Also, I've only used Lisp a little (Common Lisp), and the general feel I got was that #2 was the biggest benefit to Lisp. Maybe I'm thinking in the wrong paradigm, but I don't think I've ever had a situation where self-modifying code was necessary. If you have a specific reason to use it, then yes, but otherwise the macros seem like the real killer feature. Edit: Just realized these are, in fact, the same feature. Oct 4, 2010 at 22:37
  • 3
    @Matt: Yep. FWIW, I recently ran into Nemerle, a C#-ish CLR experimental language with macros. nemerle.org. It's worth poking at some point I think, just for the experience. Oct 5, 2010 at 4:59
  • 2
    "Pragmatism. CL is designed to get stuff done by working professionals. Most functional languages aren't, as a rule.": I do not agree with this statement. I am very interested in Lisp and trying to dedicate some time to learn it. But I find other FP languages also very effective for "getting things done", at least this has been my experience with Scala and Haskell up to now.
    – Giorgio
    Oct 29, 2012 at 13:01
  • 1
    "CL is designed to get stuff done by working professionals. Most functional languages aren't, as a rule.": Can you elaborate on this? Especially on the second part of the sentence. Can you name a few examples?
    – Giorgio
    Nov 25, 2013 at 10:29
25

I like Lisp for its

  • unified, simple and elegant way of representing both code and data.
  • unique point of view, which gives me the crucial 80 bonus IQ points on solving hard problems (with hat tip to Alan Kay)
  • extremely agile, interactive and conversational development environment
  • unprecedented power to create and manipulate abstractions

Programming is fighting complexity. Abstractions are the only effective tool for fighting ever increasing complexity (with our very limited and constant skull size). Managing abstractions with Lisp is like having a genie with n+1 wishes.

3
  • 5
    +1 for "Programming is fighting complexity. Abstractions are the only effective tool for fighting ever increasing complexity (with our very limited and constant skull size)." (I wish I could give a +10.)
    – Giorgio
    Oct 29, 2012 at 13:08
  • What is the "extremely agile, interactive and conversational development environment"?
    – qed
    Nov 18, 2014 at 23:48
  • 6
    Shouldn't that be (+ 1 n) wishes, or even more better practicality wise (incf n)?
    – Reb.Cabin
    Jan 25, 2016 at 4:37
21

I believe the correct Lisp answer is more gnomic. Something like: "If you have to ask, you are not ready."

Then if anyone questions further, the correct answer is either "yes" if it's an either/or question or "You are not ready."

3
  • 5
    Paul Graham quotes Louis Armstrong: “If you have to ask what jazz is, you'll never know.” Jan 30, 2011 at 20:31
  • 26
    +1. Though sometimes phrases like "If you have to ask, you are not ready" make me think that the one who says so simply cannot explain
    – superM
    Aug 24, 2012 at 11:13
  • 5
    @superM Lisp and Lisp-like functional languages have the property that once one learns them, one can no longer explain them!
    – esoterik
    May 7, 2015 at 23:03
19

I think that the Lisp advantage in the artificial intelligence (AI) field that everyone mentions is somewhat a historical accident... Lisp started for/in AI, but it's a general-purpose language.

I believe execution speed is not the only important aspect of a language (I did once, though). However, one of the aspects I like about Lisp is that for me, it combines Python and C in one. I can start to code with no declarations and prototype immediately and very quickly (the runtime and the REPL are very important for this). After I have something running, I add type declarations and "optimize" my code, little by little. It is a wonder to press a key in SLIME and watch the machine language generated for the function I'm interested in. In Python, there are no type declarations, so I cannot get more speed, but in C, getting anything done quickly is much more painful. Lisp is very useful in this case.

Having said that, I like Lisp mainly because of macros. When you finally understand what macros can achieve, I think you put up with parentheses easily. Also, editors like Emacs manage parentheses themselves so you don't have to. I admit, however, that I didn't find parentheses all that bad at the beginning, and I know some people just can't stand them. But since the whole purpose of macros is to generate code at compile time, code in Lisp uses a standard data structure, and the parentheses simply are a representation of code as lists, which is necessary to make macros simple to write.

I don't know any other language in which you can write little sublanguages to describe your problem better with the ease of Lisp. That is the advantage Paul Graham talks about in Beating the Averages. It is extreme modularity and conciseness. In Java I have to write a lot of raw text to express a single idea. In Lisp I could write some macros that generate that code automatically, and afterwards just use those. Anyway, you have to understand some examples of this and then judge for yourself. When I "saw" it, I was blown away, and I still think Lisp is the greatest language for this reason alone. I always look for macros in mainstream languages to see if they match the power of Lisp macros, but to date I didn't find any. Forth is a close second.

I'll finish with a couple of criticisms, in relation to business software:

  1. Business software needs libraries, and good ones, and Lisp is not good at this. I usually don't need them, but when I do, I have to choose from a little selection of incomplete software that a few people uses. I should contribute to fix this, I guess...

  2. Business software is usually built by large groups of people, and I think communication can be impeded with macros, since they basically change the language. A lot of programmers are more comfortable detecting certain patterns in code, even if the program text is longer and more repetitive. I suppose at ITA they have some rules regarding macros or they have a huge macro library that makes collaboration easy (or, more simply, all programmers are Lisp experts).

3
  • 7
    Try clojure, it is a lisp on the JVM. So by using the JVM you can use all the java stuff.
    – Zachary K
    Feb 15, 2011 at 12:37
  • @zachary: There are at least 2 Common Lisp implementations on the JVM. ABCL is relatively mature. Feb 15, 2011 at 16:34
  • Clojure is 100% Java-compatible (at least I have never found anything in Java that Clojure can't improve, and in such a way that the Javaists can't complain). Clojure is heavily influenced by the best of Common Lisp and the best of FP. With that and SBCL and CLisp and Emacs, any Lisper should feel like a king nowadays.
    – Reb.Cabin
    Jan 25, 2016 at 4:42
13

I don't like Lisp.

(I do like many of the concepts it uses, how it makes powerful techniques available natively, and so on.

But I've never been convinced to actually go use it, ((even though several people have tried) because the benefits of the language can be achieved with other programming languages (some directly, some indirectly), so there isn't enough benefit to get me to spend the time learning it and putting up with the horrific syntax.)))

But yeah, for reasons that some people like it, check these Stack Overflow questions:

There's probably a few more in the related questions for those too.

14
  • 26
    "Putting up with the horrific syntax". Maybe it's just too long since I was a Lisp newbie, but the simplicity and regularity of Lisp syntax is a huge feature, since that's what it makes it possible for me to extend Lisp in itself. I can add custom iterators, I can add new "with-xxx" scope constructs which automatically clean up after themselves so the developer doesn't have to, etc. The syntax is a feature, not a bug.
    – Michael H.
    Oct 4, 2010 at 14:18
  • 5
    The ability to extend a language with itself does not require a syntax limited to half a dozen characters. Also: "The syntax is a feature, not a bug" ? - I know. I didn't call it a bug. Oct 4, 2010 at 14:31
  • 8
    Okay, how do you get the benefits of the macro system? How many languages allow you to build an object-oriented extension to them in one reasonably short chapter (Paul Graham, "On Lisp"). Oct 14, 2010 at 19:37
  • 6
    The syntax isn't any more horrific than other languages. I've found that the parentheses just visually "disappear" after a while. With good indentation, the code is easily readable. Nov 12, 2010 at 19:46
  • 8
    But having the ability to easily move between S-exps seems huge... Then on the subject of parentheses, I like the following quote: Parentheses? What parentheses? I haven't noticed any parentheses since my first month of Lisp programming. I like to ask people who complain about parentheses in Lisp if they are bothered by all the spaces between words in a newspaper" - Ken Tilton Oct 26, 2011 at 23:32
9

I'll interpret "Lisp" as "Common Lisp"; I've no doubt other answers will say "Scheme". (Hint: Lisp's a family of languages.)

What does "faster" mean? In terms of time taken to run a benchmark, no, it's not faster than C (but it can be).

"Fast" in terms of how long does it take Joe Random Hacker to write up a working program, or fix a bug in large software system? Almost certainly.

As for this hacker, I use it because I want to write code, not boilerplate. I want to write something once, and not continually repeat myself. And I want to interact with the program while I write it.

6
  • Wouldn't that be awesome if you could write a little function inside your editor that would immediately do something to the rest of your code? Or can you do that already?
    – Mark C
    Dec 1, 2010 at 15:20
  • 4
    @Mark: I think you're describing Emacs.
    – Ferruccio
    Jan 30, 2011 at 20:52
  • @Ferruccio I thought you have to run your code first, though.
    – Mark C
    Jan 30, 2011 at 23:25
  • 2
    @Mark C: Well, you do have to highlight the region and then M-x eval-region (or eval-buffer), but that's all. Jan 31, 2011 at 9:39
  • 1
    @MarkC: Also, if you're in the scratch buffer, you can just write your function and press C-j (which is morally equivalent to enter) and it will take effect immediately. Dec 23, 2011 at 9:43
8

I like Lisp because it's an excellent medium for expressing my thoughts. The predicate for my favorite language is "If I could pick anything to express ideas in, what would it be?". Currently it's Lisp* (Scheme to be specific), to the point that I find myself writing out programming notes in it. As IRL, paper and pen notes. Even when I'm thinking about programs I need to implement in PHP or Ruby or Python.

This isn't a trick I taught myself, or something I do for nerd credibility (no one gets to see the inside my notebook anyway); it's just that Lisp is so much more natural for me to think in than any of the alternatives, and any language that resonates with you that deeply is one you treasure.

*Just as a footnote though, Haskell is closing the gap pretty quickly as I learn more of it.

6

The issue is power. Power = Work (program functionality) / Time

"We were not out to win over the Lisp programmers; we were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp."

-- Guy Steele, Java spec co-author

Plot some kind of curve between C++ and Java. Keep going, and at some point along the line you'll find Lisp.

6
  • 2
    The problem here is that you lose a lot of C++ functionality going to Java, but pick it up again (often in improved form) when going to Lisp. Jan 13, 2011 at 23:02
  • @DavidT The SO question on that exact quote has a link to the source (search for "cite"). The quote should not be taken so seriously.
    – Mark C
    Jan 14, 2011 at 3:17
  • @David: Like macros. It's not just that they left them out in going to Java (and hence C#) but they made the lack of them a "virtue". Macros are really handy if I'm building a DSL on top of the base language. Jan 14, 2011 at 15:50
  • @Mike Dunlavey: I really dislike macros in C++ (heck, I dislike them in C, but I don't have much of a choice there). I really like macros in Common Lisp. You know, I think my problem with that comment is that I like both C++ and Common Lisp a whole lot more than I like Java. Jan 14, 2011 at 16:12
  • @David: I'm with you 100% on macros in Lisp. In C/C++ they are ugly and prone to abuse, but for the kind of ( admittedly fringe ) stuff I do, they're so much better than nothing. Of course, when I do it in C++ it can very well be regarded as abuse, but in Lisp it is regarded warmly as clever. Go figure. Jan 14, 2011 at 21:29
6

Paul Graham sort of answers this question himself in What Made Lisp Different.

Keep in mind he used it for his startup during the mid 1990s, so Python and Ruby weren't really mature at that point (or maybe not even born).

Lisp basically has all the advantages of dynamic languages, and I think for most of today's web applications, Python and Ruby are pretty awesome, and they have the advantage of frameworks and documentation and vibrant communities.

The killer feature is probably that the entire program is made of expressions. This means you can sort of pass around blocks of code to functions (or macros...), because a block of code is nothing more than an expression.

Python doesn't exactly have this feature; you'd have to define functions and pass them around. Ruby seems to have blocks, perhaps it's somewhat limited compared to what Lisp can do (I'm not sure).

2
  • The article by Paul Graham is interesting because, save for a couple of items, most languages these days seem to have the features he lists. So maybe Lisp was more compelling back in those days; nowadays it's more valuable as the language that introduced those features?
    – Andres F.
    May 6, 2015 at 20:59
  • AST as language syntax is still domain of Lisp. I'm not aware of non-lisp language where macros have whole language available, during compilation time (Yes compiler basically hand macro call to macro definition which is Lisp program on it's own. You want to do http and db in macro at compilation time?)
    – przemo_li
    Jun 27, 2017 at 9:50
6

I have had a knee-jerk reaction to Scheme in the past, but now I am ready to give Lisp (Clojure, actually) a shot.

You see, over the years I picked up bits of languages like Java, C#, C++, Python, and things are no longer challenging.

Clojure has many promises, appears to be very clean, and can solve many real-world problems. A strong case for a clean language like Clojure is the advent of multi-core computers.

Yay LISP!

EDIT: ITA Software was founded by MIT grads, and Scheme/Lisp was the only language that many of the MIT grads learned. To be fair though, one can hot-swap Lisp algorithms on a running production system, which is a huge plus.

5
  • 8
    Re: Things are no longer challenging---give Haskell a go and let us know what you think. Also, you can always try to learn some INTERCAL for a change!
    – Mark C
    Oct 4, 2010 at 15:25
  • 3
    @Mark C, sorry but I am not touching INTERCAL. Challenge is not the only criteria; it has to be able to solve real problems fast as well. At least Haskell is used and loved by many.
    – Job
    Oct 14, 2010 at 18:21
  • That was in jest, of course.
    – Mark C
    Oct 14, 2010 at 18:29
  • 1
    Updating running code (carefully!) on a production server is one of the joys of Lisp, yes. Python, at least when I was playing with it, did not do this well; you'd have to manually recompile all functions/methods which referred to your changes, while all Common Lisp implementations handle that for you. I use that same power for development: write, test something, edit, test -- no compile loop, and you can take your interactive tests & turn them into unit tests if you wish.
    – Michael H.
    Nov 28, 2011 at 20:58
  • @Job I forgot...PLEASE?
    – Mark C
    Jan 30, 2012 at 5:47
6

The thing that I like about Lisp is that it transcends paradigms. Some people will say that Lisp is functional, others will say it's declarative, and others will say it's multiparadigm. I think all of these miss the point. When you use Lisp, paradigm is no longer a constraint.

Want objects? You can have them. Want functional programming? You can have it. Want Prolog-style logic programming? Write some macros. Want SQL-style declarative programming? Go for it. Want to use some paradigm that hasn't been invented yet? I'm confident it can be done in Lisp.

Aside from Forth-like languages, I have yet to see another language offer this level of flexibility.

2
  • +1 Multi-paradigm programming, decades in advance of F#, very good point.
    – Orbling
    Jan 31, 2011 at 0:55
  • I wish I could upvote this ten times. There is no spoon ... there is no paradigm ... It describes my feeling about Common Lisp with great accuracy :) Apr 6, 2018 at 19:46
5

"Faster" isn't a simple thing to measure -- it really depends on which aspect you're benchmarking. Depending on the task and the Lisp implementation, speeds can approach C. Look at the Great Benchmarking Shoot-Out to dive in for details. The SBCL implementation of Lisp is on par with Java 6 Server and is significantly faster than Ruby or Python.

But, pure speed isn't the main reason to choose a programming language -- if it was, we'd all be programming in assembly language still, right? For me, the daily joy of Lisp is that the code is compiled, but I don't have to take down the application, recompile everything, and then start running from scratch. Instead, I can change a single function and that change will take effect everywhere, and I can immediately see the effect in my application. Moreover, that very quick "write, test, write more, test more" approach makes it much easier to test immediately up front while writing the code (and then you can turn those interactive probes into unit tests later on).

Imagine writing email where after every line, you had to hit a button to compile your email output to the screen before continuing your thought. That's what writing in Java or another language like that is for me. Sometimes there's a reason to do that, and I like Java fine, but Lisp is just more responsive, and it's easier to get work done.

2
  • If I were starting out fresh today, I'd probably pick Ruby -- it's inherited much of the Lisp nature, but it has more modern libraries and a single benevolent dictator driving it forward. But, that wasn't the question the OP asked.
    – Michael H.
    Oct 4, 2010 at 14:47
  • I actually did pick ruby to start out, and now I'm trying to learn newLisp.
    – philosodad
    Jan 30, 2011 at 19:39
5

I'm learning Lisp (newLisp) for a couple of reasons.

Reason number one: Lisp makes me think differently, which makes me a better Ruby coder.

It seems very awkward to do things certain ways in Lisp, for example nested iteration to go through multiple lists. So it forces me to use other things, like map. My favorite language, Ruby, has the same map method, but I don't always use it, because it's unfamiliar: I learned to do things using a poor technique, and when the language supports that technique I continue to use it.

Reason number two: Lisp is practical and has good modern libraries.

There's a very nice, lightweight web framework for newLisp called dragonfly. This allows me to use newLisp code instead of PHP for some tasks. I don't really like PHP, and newLisp seems more fun for this specific task than Ruby.

Reason number three: Lisp is syntactically and conceptually consistent.

For me, this is the big difference between Ruby and Python, consistency.

1
  • +1: "Lisp is syntactically and conceptually consistent." This is a very important feature of a language. Some badly designed languages lack consistency, they are like a big collection of idioms thrown together in some order (I have one language in mind, but I won't name it :-) ). Lisp is in this respect very consistent. As soon as I have some time I will definitely try to learn it.
    – Giorgio
    Oct 29, 2012 at 13:11
4

Can you say "Brand Loyalty"?

I started in Fortran. I loved it.

I switched to Lisp. At first I hated it. Then I learned to love it, and hate Fortran.

Later Pascal, C, C++, various assemblers, C#. (Actually I don't love C#.)

I guess I'm fickle?

0
4

When Lisp was created they started from math, not computer science (which didn't really exist yet). And the Lisp team got some things REALLY right. Lisp had garbage collection in 1960 or so! They really did a great job.

I think the The Eternal Flame song covers it.

1
  • Yeah apparently Lisp was the first GCed language.
    – Mark C
    May 18, 2017 at 20:21
2

A big draw is the community. Lisp has had a draw for the most ambitious and bright developers since the language was invented. Wherever researchers are trying to solve problems that have never been solved you are likely to find Lisp, as in artificial intelligence (AI) research, computer vision, planning, knowlege representation, and complex heuristic optimization. The language lends itself to solving problems both from the bottom up and the top down at the same time, which seems to help in confronting the hairiest challenges.

The exensible syntax via macros means that there is seldom a need to extend the language definition. Much of what would require a language extension in a more restricted language is just a macro away with Lisp. So Lisp programmers are free to make use of newly invented language concepts without a new language standard and without necessarily a real speed penalty. On a basic level, reams of boilerplate code are made unnecessary by small extensions. Whole new ideas in control flow, like Prolog style unification, are implemented efficiently and compactly as extensions.

The OOP system, CLOS, is in a class of its own in terms of flexibility. It is very difficult to go back to rudimentary C++/Java/C# OOP after getting a taste. GoF 5 design patterns become unnecessary as they can be expressed simply and directly.

The language has had no single corporate owner and no single definitive implementation, though it does have an ANSI standard with many conforming implementations. Major new implementations come along every decade and the old ones are still quite active. Experts can plan to use their specialized knowledge for a long time to come. This does cause some anarchistic friction and community fragmentation, but it also means the carpet cannot be pulled out and the language can't become moribund for corporate or project political reasons. There are always multiple commercial and open source implementations being worked on. The more performance focused ones regularly benchmark within a 2x factor of the very fastest, heavily funded imperative language implementations.

The Achilles heel of early Lisp commercialization was memory footprint to accomodate both the type safety features of the language and the advanced software development environments they included, with incredible features like full online documentation including graphics. A 64 MB Symbolics Lisp Machine was not viable cost-wise against an 8 MB Sun workstation. Today, RAM prices have collapsed and there is tremendous interest in the Lisp languages especially considering that the mainstream Java, C#, PHP languages today have advanced only minimally over those of 30 years ago.

There are modern languages now in competition with Lisp for mindshare with intelligent developers: Python, Lua, Erlang, Haskell, and OCaml. But none offers the same mix of maturity, adaptibility, multiple standards-compliant implementations and speed.

1

I don't actually do Lisp. But the place I work at does finite elements with millions of lines of mainly Fortran. The guy here whom I most respect about computing stuff (codes computational fluid mechanics) thinks the ideal combination is Lisp on the outside (mainly because you avoid messy problems with memory management), and Fortran for the low level algorithms (Fortran is best for exploiting the vector capabilities of SSE/AVX, and we think this lead is unlikely to close).

Not the answer you're looking for? Browse other questions tagged or ask your own question.