3 ms·
IIRC, Ruby builds an s-expression tree under the hood (disclaimer: this is going by what I've read and I can't find the article right now, please take with seve
by tomphoolery 13y ago
IIRC, Ruby builds an s-expression tree under the hood (disclaimer: this is going by what I've read and I can't find the article right now, please take with several grains of salt). I do know this, however: In Ruby, everything is an expression. So that's why code like..
foo = if bar?
:bar
else
foo_proxy || :foo
end
..can be expected to work. One thing I love about Ruby is that I feel as though it works "like a Lisp" under the hood, but doesn't look like one at all. The one thing I could never get over with Lisp-like languages was how difficult the syntax was for me to read. Ruby, OTOH, is a very familiar syntax and includes familiar concepts like various OOP encapsulation features, but it's all built around this expression-driven language that's both syntactically powerful and very easy to read.
edit: I still wouldn't consider it part of the Lisp family, only heavily influenced by that kind of programming...
- johnbender 13y ago"Everything as an expression" is concept that exists entirely separate from LISP as a programming language. Eg, in the untyped lambda calculus everything is indeed an expression and it obviously predates LISP. The thing that makes LISPs interesting is that both data and code have the same representation. Manipulating code and data looks the same and that leads to all sorts of interesting meta-programming constructs Also I'm not sure what you mean by "under the hood", but Ruby's internal representation is an abstract syntax tree (as with most languages). That AST bears a resemblance to LISP because LISP is both the language and AST rolled into one, but I would never confuse Ruby for LISP because it has an AST representation.