What's With All These Parentheses?
Join the DZone community and get the full member experience.Join For Free
I’m fairly certain that every programmer will, at some point in his career, say something along the lines of:
I don’t know, what’s with all these parentheses?
And he will be talking about Lisp. I certainly did a few years ago. It’s quite strange when you’re used to other languages, why would anyone want all these parentheses?
Why have something like this:
(filter (lambda (price) (< price 10)) prices)
When you can have it like this:
prices.select do |price| price < 10 end
[filter, [lambda, [price], [lt, price, 10]], prices]
Not that much different, eh? That’s what Lisp is. And that’s why Lisp macros are so powerful: You can easily transform these data structures into something else, changing your code. I can’t think of a single other language that lets me do that. Another benefit is that when looking at Lisp code, you normally don’t have to wonder about things like operator precedence and strange literals you didn’t know, the syntax is unambiguous.
So if the parentheses are what’s separating you and Lisp, give it a chance. No one I know who gave Lisp the chance it deserves ever regretted it, whether or not it became their main language.
Published at DZone with permission of Felix Dahlke, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.