14

I want to learn new language and I thought to start with Lisp. I want to know if I learn Lisp do I also know Clojure ( with minimal effort ), is there big syntax differences between Lisp and Clojure ?

DayannaNZ
  • 143
  • 1
  • 4

5 Answers5

12

There are not big syntax differences (mostly because Lisp family languages have almost no syntax), but there are certainly differences in other areas. Clojure has a lot of modern programming features particularly suited to high scalability (actors, references, etc) that are not present as such in a "classic" Lisp (such as Common Lisp).

Clojure is an active, well supported dialect of Lisp. If you want to learn a Lisp, you can't really go wrong with Clojure.

You may find more information in the answers to Which Lisp should I learn? .

Community
  • 1
  • 1
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 5
    That's wrong. Lisp has a lot of syntax. Tons. Check as an example the syntax of DEFCLASS, DEFSTRUCT, LOOP and others in CL. Underneath is the syntax for s-expressions - which is also not trivial. – Rainer Joswig Jan 14 '11 at 00:02
  • 4
    Small point for clarity's sake, Rainer. He said "Lisp family". All the examples you've used were Common Lisp and I'd argue that the only valid example you gave is LOOP, the only of those forms that mixes syntax (key words) other than lists. Even so, contrast all of your examples against Scheme, where nearly everything is a DEFINE and none of the structures you mentioned exist. – Shaun Jan 14 '11 at 17:02
  • @Shaun: Scheme has builtin syntactic keywords and macros. See the Scheme reports. It starts with LET, LAMBDA, IF, ... Don't confuse s-expression being Lisp syntax. Lisp syntax is on top of s-expresssions. Lisp in general has a simple form for function calls. But every Lisp has some kind of special syntactic forms AND some kind of macros. EVERY macro already present in the language implements SYNTAX. Syntax is the structure of a language. User defined macros are a way in every Lisp to have user extensible syntax. The 'no syntax' idea is just an often repeated myth. The opposite is true. – Rainer Joswig Jan 14 '11 at 21:54
  • I disagree. It's actually harder to separate syntax from semantics than is generally appreciated and Clojure's semantics are really very different from CLs. But even if we talk only about places where it makes sense to compare the syntax- well, imagine two hypothetical languages that each have 10 pieces of syntax. Now imagine that they differ in 9 of them. The fact that they only differ on nine points because they have little syntax to begin with doesn't mean that they do not differ in syntax- the less (important) syntax you have the more the differences matter. – Tagore Smith Jan 16 '11 at 06:43
  • My opinion, which may be less than informed, is that where you can meaningfully compare Clojure's syntax to CL's Clojure tends to win. This is complicated by the fact that Lisps tend to give you a fair bit of control over syntax, and CL gives you more control over it than Clojure does. Both Clojure and CL have good-enough syntax that how well their semantics fit what you want should be the overriding concern. I wish CL had Clojure's literal syntax for maps/hash-tables, but that's not a big enough concern that it would make me choose Clojure over CL for something where CL was clearly better. – Tagore Smith Jan 16 '11 at 06:52
6

90% of what you learn while studying your first Lisp will carry over to your next.

Psyllo
  • 674
  • 5
  • 8
3

I think it's fair to say that if you learn the principles of LISP you will also know the principles of Clojure and vice-versa. They are all rooted in the same philosophy, emphasising things such as:

  • Code is data. Macros are just normal functions that manipulate code.

  • Use of S-expressions to represent data and code.

  • The concept of a list / sequence as a fundamental structure.

  • Functional programming with first-class functions.

Apart from that, there are lots of differences in syntax, libraries, runtime environments etc. The difference in my view is probably about the same as C# vs. C++ - if you know one well, then the core concepts will be familiar but there are still a lot of fundamental differences.

See this list of ways that Clojure is different from other Lisps

mikera
  • 105,238
  • 25
  • 256
  • 415
  • There is a "little" difference between functions and macros. Function are first class. Macros are not. – boucekv Dec 10 '13 at 09:44
2

I'm assuming by Lisp you mean Common Lisp, since 'Lisp' itself is more of a family of languages (that includes Clojure) than a single specific language. There are some syntactical changes in that Clojure was intended to be a more modern Lisp. For instance you can create vectors with []s, maps with {}s, which are not part of Common Lisp. And of course the Java interop inevitably becomes a significant part of Clojure.

Nick
  • 393
  • 2
  • 5
  • 5
    [] and {} are reserved for user extension in CL. Vectors are written as #(...). Character syntax on that level can be provided by libraries - and actually is. Maybe CL is the more modern Lisp, because the syntax is user extensible and uses of [] and {} can be used by libraries? – Rainer Joswig Jan 14 '11 at 00:10
  • Common Lisp is commonly called just Lisp. Likewise, Lisp usually means Common Lisp. Lisp family is usually denoted as lisp, or lisps. – Marko Feb 01 '11 at 15:41
1

Clojure uses vectors as lambda parameters (arguments values), but you can use a macro to write versions of defun and lambda in Common lisp that will look similar . Clojure also has access to Java Object methods and fields using a period (i.e. ".") and the name of the method or field which looks like a normal function call.

(.toString 10) - will call the method toString on number 10 but .toString is not a function. if you try to check the value of .toString it throws an exception that .toString is not a defined symbol.

And also with quasi-quotation (mostly in macros) instead of using a coma for unquote as in Common lisp, Clojure use a tilde.

Kyuvi
  • 360
  • 3
  • 13
jcubic
  • 61,973
  • 54
  • 229
  • 402