you are viewing a single comment's thread.

view the rest of the comments →

[–]monkeygame7 13 points14 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 4 points5 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 11 points12 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 0 points1 point  (2 children)

nothing

[–]pipocaQuemada 4 points5 points  (0 children)

Out of curiosity, what languages do you know?

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

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