News for hackers. Stuff that matters.
Re:What's Special About Lisp? by saurik on Wednesday August 03, 2011 @01:46AM (#2839974)
A ton of responses and no one mentions the one-word answer?

"homoiconicity": the property of a language whereby code written in said language is stored, in a natural and immediate fashion, as a data structure of the same language

What this means for Lisp is that if you want to manipulate Lisp code, you aren't dealing with some crazy complex AST: you can actually /see/ how the code is parsed by looking at the code itself, as the code is actually typed using the serialization format for the primary data structure of the language: S-expressions.

So, you aren't just creating a little "DSL" by using some built-in syntax tricks like "implicit last argument block", but instead are able to write code that modifies code and generates code as easily as if you were writing the original code in the first place: the comparison to Ruby is therefore fundamentally flawed.

(Finally, as an unrelated bonus: the parser for Lisp is also written in Lisp and available during the execution of Lisp, so you can have code that modifies and extends the parser itself allowing you to fundamentally alter the syntax to, for example, look like Ruby; this mechanism is called "reader macros", for the record.)

Re:What's Special About Lisp? by aaco on Wednesday August 03, 2011 @10:24AM (#2841271)
"... but instead are able to write code that modifies code and generates code as easily as if you were writing the original code in the first place: the comparison to Ruby is therefore fundamentally flawed."

This. The ability to easily reason about the code and manipulate it because its syntax is simple and predictable is the big deal to me.

I think this is analog to switching from Roman to Arabic numerals. The syntax is regular. No matter how big the number is the rules are the same. There are no exceptions. Hence doing calculations with the former is a lot clumsier than with the latter.

That's the ideal scenario at least. I do realize that math might not be as simple as it could be, but I'm not really qualified to argue about that. But what if we were still using Roman numerals today? Would we be at the level of understanding we are at right now? It seems to me that it's more or less the same thing when you start understanding Lisp and why it is the way it is.

This is just too big of a tradeoff to be ignored. In my experience choosing the simple and regular solutions paves the way to progress, in which useful things that look trivial now would be rightly discarded or would be viewed as too complex if our mental model were grounded on the previous clumsy framework.

Now, I'm not saying "just drop all your clumsy languages right now, because today we have a better idea, and start using Lisp". I certainly don't do that. I don't even work with Lisp. But my point is that not realizing that Lisp has some properties that make it special is perhaps hindering yourself of being able to see that some things can be a lot simpler than you thought they could be.

Re:What's Special About Lisp? by adobriyan on Wednesday August 03, 2011 @07:19AM (#2840652)
> A ton of responses and no one mentions the one-word answer?

Statements like "You can easily do this is Ruby" hint that author understood exactly nothing and focused on some random uninteresting example code while missing big picture.

Does Ruby have COND?

If it doesn't, can one implement it using existing Ruby constructs?

If it does, can one implement it using existing Ruby constructs except COND?

Re:What's Special About Lisp? by lattepiu on Wednesday August 03, 2011 @08:49AM (#2840912)
I don't believe this is a good example. Ruby has case..when instead of COND, though it's a language construct, not a function; but I think COND can be trivially implemented in any language that has anonymous functions. In Ruby:

  def COND(*args)
      args.each_slice(2){ |s| return s[1].call if s[0].call }
  end

  COND(lambda{ false }, lambda{ "not this"}, lambda{ true }, lambda{ "this" })
(not a lisper, though, so I might be missing something).
Re:What's Special About Lisp? by probably on Wednesday August 03, 2011 @02:33AM (#2840065)
Please excuse my ignorance here --

> instead are able to write code that modifies code and generates code as easily as if you were writing the original code in the first place

Is this often done? I know it is conceptually possible with the advantage being that the same functions used to manipulate lists and data are available for this task, but I got the impression that not many people actually do this? For instance...

http://stackoverflow.com/questions/6480053/modifying-functio...

Re:What's Special About Lisp? by saurik on Wednesday August 03, 2011 @02:40AM (#2840076)
AFAIK this is actually incredibly common. The example that springs to my mind is people writing matrix libraries that manipulate the code to "compile" it to use more efficient algorithms. People do this kind of thing in C++, such as in Blitz++, but you end up having to pull heroics with the type system (and end up with some pretty abused syntax at times) to accomplish what is much easier in a homoiconic language like Lisp.
Re:What's Special About Lisp? by aerique on Wednesday August 03, 2011 @02:41AM (#2840079)
I've been using Common Lisp for quite a few years now yet I have written very few macros (although I have used a great many written by others!), however there's times when you need their power when nothing else will do.

Also because you can modify the syntax with them they can really clean and clear up your code.

Re:What's Special About Lisp? by aerique on Wednesday August 03, 2011 @02:35AM (#2840069)
Here's a hopefully fun example of a reader macro: http://paste.lisp.org/display/122860