What are the differences between Clojure, Scheme/Racket and Common Lisp?
Asked Answered
L

4

149

I know they are dialects of the same family of language called lisp, but what exactly are the differences? Could you give an overview, if possible, covering topics such as syntax, characteristics, features and resources.

Larainelarboard answered 27/6, 2012 at 9:44 Comment(6)
I'm asking for a more general overview of the differences because I fell like this question can be useful for many other people, sorry if it is sounds abusive.Larainelarboard
I always get confused about which post should go where. This is a discussion of tools, so is it a question for here or programmers? Logically, I'd say move it to programmers, because it's not asking to solve a particular problem, but it's a good post with a good answer IMHO.Crenelation
@octopusgrabbus: the question is much too broad. Comparing three programming languages on 'syntax, characteristics, features and resources' can easily fill a book or a web site. Stackoverflow is for people who have programming problems, it is not an encyclopedia (Wikipedia), it is not a general discussion forum ( Usenet ), it is not a language comparison site ( rosettacode.org ). It is best for real programming problem where the question has code and the answers have code, too. Plus: Don't make up problems just because someone is bored or that's a hobby.Juba
Just because the question is broad does not mean that it does not belong here. It's a perfectly clear question, and it is certainly a "real programming question". StackOverflow is meant primarily to be a [googleable] community resource for sharing knowledge about programming via Q&A format.Olva
@RainerJoswig, I could just write everything I learned about those languages on the past days I've been studying them, but that would make the thread big. That is really bad when you realize people will be googling that kind of short sentence and won't be able to get the answer because a big text hinders them from understanding fastly what is being asked. Doing this way ensures many more people will be helped by a good answer.Larainelarboard
@MaiaVictor: looking back there has no useful answer posted. People mostly only knew one language and were not in a position to compare them usefully.Juba
M
121

They all have a lot in common:

  • Dynamic languages
  • Strongly typed
  • Compiled
  • Lisp-style syntax, i.e. code is written as a Lisp data structures (forms) with the most common pattern being function calls like: (function-name arg1 arg2)
  • Powerful macro systems that allow you to treat code as data and generate arbitrary code at runtime (often used to either "extend the language" with new syntax or create DSLs)
  • Often used in functional programming style, although have the ability to accommodate other paradigms
  • Emphasis in interactive development with a REPL (i.e. you interactively develop in a running instance of the code)

Common Lisp distinctive features:

Clojure distinctive features:

  • Largest library ecosystem, since you can directly use any Java libraries
  • Vectors [] and maps {} used as standard in addition to the standard lists () - in addition to the general usefullness of vectors and maps some believe this is a innovation which makes generally more readable
  • Greater emphasis on immutability and lazy functional programming, somewhat inspired by Haskell
  • Strong concurrency capabilities supported by software transactional memory at the language level (worth watching: http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey)

Scheme distinctive features:

Muricate answered 27/6, 2012 at 10:7 Comment(7)
this is good, but perhaps you should mention that racket is more than "just" scheme; it's a system that supports multiple (but related) languages (you can even define your own). also, clojure has various ways of doing oo-like programming (both a multiple dispatch approach vaguely similar to clos and something closer to java that is more efficient on the jvm). and scheme is edging towards more standard libraries (that also include oo) with r6rs, which racket supports.Corrinnecorrival
"Strongly typed dynamic language" is marketing. In this sense even Python is strongly typed.Burrussburry
@ron: Python is strongly typed, just like Lisp (unlike say Javascript or VB). You are thinking "static typing" vs "dynamic typing" instead, see en.wikipedia.org/wiki/Type_system for all the varieties. But yes, it's marketingWeepy
I would also think Racket would be good to be added to this answer. I would think Racket is even easier to learn than Scheme due to the community and focus of the language. Racket (formerly named PLT Scheme) is a general purpose, multi-paradigm programming language in the Lisp/Scheme family. One of its design goals is to serve as a platform for language creation, design, and implementation.Sportscast
Clojure has hygienic macros. More info here: xivilization.net/~marek/blog/2013/09/17/…Prau
I believe continuation as a first class object is a distinct (but rather technical) feature of scheme that should be noted. I would also add the condition system as another distinct feature of common lisp.Ant
Just wanted to point out that Common Lisp also has "built-in" vectors and maps (hash-tables), and that all recent implementations support concurrency with threads and with some nice libraries like lparallel.Solmization
G
62

The people above missed a few things

  1. Common Lisp has vectors and hash tables as well. The difference is that Common Lisp uses #() for vectors and no syntax for hash tables. Scheme has vectors, I believe

  2. Common Lisp has reader macros, which allow you to use new brackets (as does Racket, a descendant of Scheme).

  3. Scheme and Clojure have hygienic macros, as opposed to Common Lisp's unhygienic ones

  4. All of the languages are either modern or have extensive renovation projects. Common Lisp has gotten extensive libraries in the past five years (thanks mostly to Quicklisp), Scheme has some modern implementations (Racket, Chicken, Chez Scheme, etc.), and Clojure was created relatively recently

  5. Common Lisp has a built-in OO system, though it's quite different from other OO systems you might have used. Notably, it is not enforced--you don't have to write OO code.

  6. The languages have somewhat different design philosophies. Scheme was designed as a minimal dialect for understanding the Actor Model; it later became used for pedagogy. Common Lisp was designed to unify the myriad Lisp dialects that had sprung up. Clojure was designed for concurrency. As a result, Scheme has a reputation of being minimal and elegant, Common Lisp of being powerful and paradigm-agnostic (functional, OO, whatever), and Clojure of favoring functional programming.

Guntar answered 16/9, 2012 at 5:48 Comment(2)
Racket is not an implementation of Scheme, barring compatibility modes. See stackoverflow.com/questions/3345397Unswear
Clojure does not have hygienic macros, as I have found the hard way.Brimful
D
45

Don't forget about Lisp-1 and Lisp-2 differences.

Scheme and Clojure are Lisp-1:
That means both variables and functions names resides in same namespace.

Common Lisp is Lisp-2:
Function and variables has different namespaces (in fact, CL has many namespaces).

Daedal answered 28/6, 2012 at 10:41 Comment(0)
T
-8

Gimp is written in Scheme :)

In fact allot of software some folks think might be written in C++ was probably done under the Lisp umbrella, its hard to pick out the golden apples out of the bunch. The fact is C++ was not always popular, it only seems to be popular today because of a history of updates. For the lesser half of the century C++ didn't even utilize multithreading, it was where Python is today a cesspool of useless untested buggy glue code. Fasterforward a little and now we are seeing a rise in functional programming, its more like adapt or die. I think Java has it right as far as the adapt part is concerned.

Scheme was designed to simplify the Lisp language, that was its only intent except it never really caught on. I think Clojure does something similar its meant to simplify Scheme for the JVM nothing more. Its just like every other JVM language just there to inflate the user experience, only to simplify writting boilerplate in Java land.

Titanite answered 24/2, 2016 at 3:41 Comment(2)
"meant to simplify Scheme for the JVM nothing more" "just like every other JVM language" Yeah, right.Asbestosis
Gimp is written in C, and it supports Scheme, Python and Perl as scripting languages.Ransom

© 2022 - 2024 — McMap. All rights reserved.