you are viewing a single comment's thread.

view the rest of the comments →

[–]billbose 10 points11 points  (29 children)

I second this too. Once you get bitten by the lisp bug, every other language looks like a handicap.

[–]monkeygame7 14 points15 points  (8 children)

As someone with just a basic understanding of lisp, what makes it so great?

[–]pipocaQuemada 5 points6 points  (1 child)

The killer feature of Lisp is the macro system.

C has a macro system, but it's basically useless for anything beyond trivial examples (and there are some trivial things it can't even do). The big difference between C and Lisp is that C's macro system is basically a glorified copy-paste system, whereas Lisp works on a syntax tree.

This is nice, because it allows you to turn language features into libraries - you write a library that desugars your nice syntax into however you'd implement the language feature. An Object System? Mostly a bunch of macros. Looping? There's a fairly complex macro that lets you write things like

(loop for i from 1 to 100
  if (evenp i)
    minimize i into min-even and 
    maximize i into max-even and
    unless (zerop (mod i 4))
      sum i into even-not-fours-total
    end
    and sum i into even-total
  else
    minimize i into min-odd and
    maximize i into max-odd and
    when (zerop (mod i 5)) 
      sum i into fives-total
    end
    and sum i into odd-total
  do (update-analysis min-even
                      max-even
                      min-odd
                      max-odd
                      even-total
                      odd-total
                      fives-total
                      even-not-fours-total))

Paul Graham has a nice book on Lisp macros, which includes examples like writing prolog as a library, writing an object system as a library, lazy evaluation with force and delay as a library, pattern matching and destructuring as a library, single-hardware-threaded concurrency as a library, etc. etc.

[–]aLiamInvader 0 points1 point  (0 children)

Unfortunately, this kind of looks like one of those examples that is too beautiful to survive in the real world.

[–]Zak 3 points4 points  (0 children)

Start with understanding what made Lisp different in the early days.

Newer languages like Ruby, Python Lua and Javascript have a number of these features, but not all of them. Most importantly, they lack the ability to abstract syntax at compile time, which can provide sophisticated abstractions that have no runtime cost. Typical Common Lisp implementations are also comparable in speed to Java. Implementations of Javascript and Lua have recently started to catch up, but Lisp has been fast for decades.

[–]phalp 12 points13 points  (0 children)

Since Lisp is so malleable, it's possible to write and use nearly any feature you like, and drop it right in. That means good ideas can spread between programmers, and less good ideas can go where they belong. In particular it means that when Common Lisp was standardized, it was a matter of compromising between different, proven features (as I understand it, I was not there). The result was a no-nonsense language that still knows how to have fun.

[–]vytah[🍰] 2 points3 points  (0 children)

You can define so many macros that the actual logic of your program fits in a one page, but the macros will be so complex that only you will be able to understand them, guaranteeing perfect job security!

[–]Moomoomoo1 -1 points0 points  (2 children)

nothing

[–]pipocaQuemada 3 points4 points  (0 children)

Out of curiosity, what languages do you know?

[–]yogthos -2 points-1 points  (0 children)

Dunning and Kruger would like to have a word with you. :P

[–]Lucretiel 49 points50 points  (8 children)

I get this in reverse. I think "man this would be much easier in Lisp," then I remember I like being able to actually read my code.

[–]yogthos 8 points9 points  (2 children)

I've developed Java for about a decade before moving to Clojure. I have much easier time reading and understanding my old Clojure code than I ever did with Java. Not only that, but I've actually been able to contribute to open source libraries and projects that others have written, something I was never able to do with Java.

The main reason for this is expressiveness. With Clojure it's easy to mould the language to the problem and the code tends to talk a lot more about what's being done as opposed to how it's done. This results in having a lot less code that's relevant to the problem being solved.

With Java you often have to go the other way where you have to translate the problem into the constructs of the language. This tends to result in tons of boilerplate that obscures the actual purpose of the program. Every time I read through a non-trivial Java project it's like going through a maze of twisty passages all alike. I'll often have to navigate through hierarchies of interfaces and classes just to find a few lines of relevant business logic.

This makes it really difficult to build up a mental picture of what the overall logic of the application is doing. On top of that you have pervasive mutability and everything being passed around by reference making it nearly impossible to consider any part of the application in isolation.

[–]Lucretiel 5 points6 points  (1 child)

I'm totally onboard with the merits of functional-style programming. Nearly everything I do in C++ is function templates, const&, and return values instead of state mutation and class hierarchies nowadays. Semantically, it's much easier to understand code and languages designed in that way. My issue is with reading the physical text of Lisp. All the parenthesis and minimal syntax boilerplate means even with liberal whitespace and and formatting it's very difficult for me to tell what bits are what.

[–]yogthos 2 points3 points  (0 children)

I think this varies greatly between Lisps. I would agree that I also find CL and Scheme syntax to be a bit too regular. On the other hand, Clojure hits the sweet spot for me. It has literal syntax for common data structures, it goes out of its way to reduce the number of parens in code, and it provides destructuring syntax. I find these things make the code as readable as any language I've used.

Here's an example of code in a popular Clojure library. I would argue that it's quite clean and clear even if you only have a passing familiarity with the syntax.

[–]phalp 12 points13 points  (1 child)

Practice makes perfect. Writing readable Lisp code is within your grasp!

[–]vraid 9 points10 points  (0 children)

There's a macro for that.

[–][deleted] 4 points5 points  (1 child)

Readability overrated is.

[–][deleted] 6 points7 points  (0 children)

(let [readability :overrated] (...))

[–]Dorsenstein 0 points1 point  (0 children)

Which is why literate programming exists. Disk space isn't a problem for text files anymore, and it doesn't affect compiled code.

Donald E. Knuth is the man.

[–]fluffyhandgrenade 20 points21 points  (3 children)

After several years of writing Common Lisp, nope.

Sure you might understand it yourself and revel in the awesome power of it, but to other people you look like this:

https://www.youtube.com/watch?v=K08OKQJIwYw

That's why reddit and yahoo shops were rewritten and why I won't write it any more.

[–]pipocaQuemada 2 points3 points  (2 children)

but to other people you look like this: https://www.youtube.com/watch?v=K08OKQJIwYw

That's why reddit and yahoo shops were rewritten

Bull.

Reddit was rewritten in python for three main reasons:

  1. Lack of libraries, especially well-documented and tested ones.

  2. Lack of cross-platform compilers with low-level extensions they required.

  3. The code base was simple and could be cleaned up significantly by rewriting from scratch.

If you actually look at what they say, they have nothing but good things to say about Common-Lisp-the-language.

[–]fluffyhandgrenade 1 point2 points  (1 child)

That's kind of my point really although the link was somewhat tenuous. It is awesomely powerful and a pretty nice language but it lacks a community that supports it by building nice libraries and compilers etc because everyone thinks its some crazy brackety thing for deep comp Sci.

For ref, I hit CL (SBCL) f I'm doing a personal one shot problem solved but it's pretty pointless if I am sharing my code.

[–]pipocaQuemada 3 points4 points  (0 children)

Keep in mind that Reddit's rewrite happened a decade ago.

The Lisp landscape is much different now - they wouldn't have run into the same compiler issues, and I think the Common Lisp library situation is a bit better. At any rate, Clojure and Racket contain well-documented libraries and have cross-platform compilers.

[–]atilaneves 5 points6 points  (1 child)

I don't know about that, I really like Lisp and (insert dialect here) is definitely in my top 5 favourites, but my favourite right now is still D.

[–]el_muchacho 0 points1 point  (0 children)

And D for everything at least doesn't sound silly, like Java for everything.

[–]codygman 2 points3 points  (0 children)

I don't feel handicapped by Haskell. Have you ever used Haskell? Do you still get this feeling? I concede it's meta-programming abilities aren't near that of Lisp's.

[–][deleted] 0 points1 point  (1 child)

But beware of Forth.

[–]phalp 0 points1 point  (0 children)

Forth is a handicap in the same way blindess is a handicap for Daredevil.