Why Racket? Why Lisp? listed 10 features of Racket, and concluded that:
with Racket I’ve been able to render bigger ideas into programs more quickly, and with fewer bugs, than any language I’ve used before (and there have been many— Basic, C, C++, Perl, Java, JavaScript, Python, and others).
I checked the list against Ruby, and it turned out that, generally speaking, Ruby also fit into the feature list.
-
Everything is an expression.
In Ruby, almost everything is an expression. For example,
result = if a then b else c end
. -
Every expression is either a single value or a list.
In Ruby, everything is an object. Thus mostly the Ruby syntax can be reduced to object.method(parameters) For example,
(+ 1 1)
can be expressed as1.+(1)
in Ruby, where+
is a method of1
. (Well it is usually written as1 + 1
, but this is just a syntax sugar.) -
Functional programming.
Ruby supports higher order functions, closures (lambda or define_method) and you can write Ruby code that does not relying on state and without data mutation.
-
Libraries and documentation
Ruby has good documentation and a huge number of gems.
-
DrRacket
RubyMine
-
X-expression
a special native data structure that Lisps use to represent HTML and other XML-ish data.
n/a in Ruby
-
Scribble
- docco (written in Node.js, supporting a lot of languages including Ruby)
- rocco (written in Ruby)
-
Syntax transformations.
Ruby has powerful meta programming support. Though nothing can beat Lisp in this area. But if abused, macros / meta-programming will become a big trouble.
-
New language
Ruby are famous for creating (internal) DSLs. Though it seems racket is more powerful for implementing new language on it.
-
Opportunities to participate.
Ruby are open to contributions. And there are several implementations to contribute: MRI, JRuby, Rubinius, mruby, etc.
This is not a surprise since Matz, the creator of Ruby, said that Emacs Lisp changed his life.
And there are two features of Racket that are absent in Ruby:
-
Simple, consistent, and predictable syntax
-
Typed Racket