Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've read recently that macro support in Scala is now official. I checked the documentation page and they are reminiscent to the LISP ones. In one of his essays Paul Graham writes that when "you add this final increment of power" to a language it is no longer a new one but a lisp dialect.

Is this the case with Scala? It does not seem like a LISP dialect to me and the macro support in Scala is somewhat awkward for me.

share|improve this question
2  
wow it looks like C having macro makes it a dialect of LISP –  gnat Aug 30 '13 at 12:43
5  
It's best to take anything Paul Graham writes--particularly on the subject of programming--with a grain of salt, if not an entire shaker. A lot of the ideas he pushes are wrong, and some of them are harmfully so. –  Mason Wheeler Aug 30 '13 at 12:45
3  
Says someone who is still using Delphi. Ok. I take your word for granted. –  Adam Arold Aug 30 '13 at 12:46
3  
@gnat Lexical macros are not at all the same thing. Lisp/Scheme/Scala macros work on the AST –  itsbruce Aug 30 '13 at 14:41
3  
@Mason Wheeler: Paul Graham's ideas may be biased towards Lisp, but ... wrong? Can you give an example? (BTW, Lisp is not my favourite language.) –  Giorgio Aug 30 '13 at 14:57

3 Answers 3

The Lisp family of languages is a fuzzy concept. The key aspects seems to be

  1. Support for functional programming
  2. Macros
  3. Homoiconic (The text <=> The AST, eg Lisp's love of parens)
  4. Dynamically typed
  5. Garbage Collected

The big place where Scala falls down in is 3. Scala is hilariously not homoiconic and this is not a bad thing necessarily.

It does have one major effect though: in Lisps, part of what makes macros so powerful is that they're so easy. In common lisp a macro is literally a function that returns a list. That's it.

In Scala or Haskell (Template Haskell), compile time meta programming is something that experts do, in Lisp, macros are what everyone does.

Scala also fails 4 being very strongly statically typed. There are pragmatic ways that you can convince the compiler to accept some level of dynamic typing, but you're definitely fighting the language then.

My thought is that Scala, like many, is influenced by Lisp, but it isn't a dialect.

share|improve this answer
3  
Agreed. I tend to see the homoiconic aspect as being the clearest differentiator. In all Lisps (Common Lisp, Scheme, Clojure), the code is written in the data structures of the language, and this is clearly not the case with Scala. –  Danny Woods Aug 30 '13 at 14:18
    
Trying to find counter examples, I think Julia have all these features but I don't think it's considered a LISP dialect. Io may also have all these features (not sure about macros). –  Joan Charmant Aug 30 '13 at 16:43
    
@JoanCharmant I suppose you could also add Axiomatic, in the sense that Lisp's tend to have a small core of primitives, but then Clojure's not Lisp anymore.. As I've said, once you leave behind parens, defining Lisp gets fuzzy –  jozefg Aug 30 '13 at 16:55
    
Incidentally, Julia was designed to be very lispy –  jozefg Aug 30 '13 at 16:56
    
@jozefg I'd wholeheartedly support any definition of LISP that keeps Clojure out. –  Javier Aug 30 '13 at 21:21

No, Scala is obviously not a Lisp dialect in any meaningful sense. If you look at what he says:

I mention this mostly as a joke, but it is quite true. If you define a language that has car, cdr, cons, quote, cond, atom, eq, and a notation for functions expressed as lists, then you can build all the rest of Lisp out of it.

So, you can write a dialect of Lisp based on Scala, perhaps even as an internal DSL, but that doesn't mean that all Scala programs will belong to this dialect.

share|improve this answer

Not in any way that one would normally identify a Lisp. I believe Paul Graham is hyperbolizing here a bit. He's an extremely big proponent of Lisp-family languages (having written one himself).

As far as I know, these are some of the general traits all Lisps share:

  • Homoiconicity (Code is data, data is code - this is visually obvious from the structure of a Lisp program)
  • Dynamic Typing (Possibly with optional type annotations)
  • Polish Notation for all function calls (Prefix only, not infix operators)

You might be able to remove one element or so from those and still argue that your language is close enough to the Lisp family to be considered a Lisp. Scala, on the other hand:

  • Is not homoiconic (With a syntax more similar to Java)
  • Is heavily statically typed
  • Supports prefix, infix and postfix "operators" (functions)

Unless you define a Lisp simply to be "A language with Macros", Scala doesn't fit the bill.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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