Tuesday, December 2, 2008

Clojure. Wow.

Someone finally did it. They created a LISP that I want to use. Too bad it's for the JVM. :-)

Most of my complaints about LISPs are the same as everyone else's. Few libraries, less documentation, and poor interoperability. I never found a LISP that had everything I wanted. I'm repelled by the complexity of Common Lisp and vexed by Scheme's completely avoidable verbosity. It also find that languages like F# and Haskell do a better job of encouraging practices that minimize mutable state. Putting all that aside, even if a free Lisp with standard libraries as extensive as that of .NET or Java existed I just don't have time to relearn how to print "Hello word," nor should I have to.

Enter Clojure. It runs on the JVM and as such can use any Java library. As for syntax it takes a very conservative approach, adding just enough to make a big difference in readability. Clojure has tremendous potential. Its encourages the use of sequences, has lots of handy immutable data structures, and some nice syntax for creating them. It's weird but Clojure programming feels almost as much like F# as it does Scheme.

I have to call one particular syntactical decision out in particular. The choice of lambda syntax is brilliant:

(reduce #(+ %1 %2) (range 100))

Clojure's got macros (of course), optional type annotations, even a working Software Transactional Memory implementation(!). Having done some simple benchmarking I was pleasantly surprised to find that it's no slouch either.

I have a minor complaint which is that I wish Clojure had adopted JScheme's dot notation for referencing Java class members. I don't find Clojure's approach nearly as readable or natural to a Java programmer. Also there's no way to write mutually recursive functions but that's the JVM's fault.

It's too early to predict whether Clojure will get adopted. My concern is that it will lose out to more syntactically approachable dynamic JVM languages like Jython and JRuby. Frankly I'm not sure I can deal with any more disappointment. I got really excited about Arc. Of course you remember Arc. Paul Grahm's LISP flavor which, after years in the making, took the software development industry by storm. Not.

I don't want to pile on Paul Grahm. He's gotten enough flack over the Arc debacle. There is a lesson here though. If your language doesn't target one of the major VM's you might as well just write a paper and submit it to LtU.

There's no good reason that Clojure couldn't be ported more or less faithfully to .NET. Take the DLR and add some of the classes in F#'s standard library and you're 70% there. It's not like Lisp parsers are hard to write after all. Any takers? I'd do it my self if I wasn't consumed by charting :-).


Anonymous said...

try this: http://www.ikvm.net/userguide/ikvmc.html

Silverlight Travel said...

Great! I will send this link to my friend Bernd. He is a big fan of Lisp

Jeff Klawiter said...

Have you checked out Arc? It is an awesome dialect that runs on Scheme. It is all about removing the syntactical bloat.

I haven't heard if anyone's done it but it's possible it could be run on IronScheme.

Judah Himango said...

Jafar, I think MS has you working in the wrong department. Silverlight is great, but you're a language geek. They should move you to MSR.

Erik said...

in your example of lambda notation you probably meant:

(reduce #(+ %1 %2) (range 100))

Stephan said...

The capability to do mutual recursion was recently added with the "trampoline" function: see announcement in the Clojure Google group

Anonymous said...

Your example of the lambda notation should just be:

(reduce + (range 100))

Jafar Husain said...

Jeff: I have checked out Arc. I was unmoved. Clojure is much better suited for a fundamentalist functional programmer such as myself.

Erik: How embarassing. Syntax is hard for me give up apparently.

Judah: My love for controls runs deep. Just don't wear it on my sleeve. Wait until the Silverlight charting control stabilizes. Then I'll unleash quite a few SL posts.

Anonymous: Thanks. Although I was aware that I could've shortened that example I expanded it on purpose to show off the %# syntax.

wowgoldworld said...

Greeting! What do you think of wow gold? I always lack of wow gold to buy some great item for my char before the wow patch 3.1 and I need to do wow power leveling for the cheapest wow gold or I have to search cheap wow gold on google search. The world changed since the 3.1 patch released. Short of buy wow gold for me wasn't so high frequency now. And I’m curious why this situation happened? The items became cheap? Or we can farm wow gold much easy? Hope someone can give me an answer.

Affordable Luxurious Wedding Dress Blog said...

cheap wedding gowns,
discount bridal gowns,
China wedding dresses,
discount designer wedding dresses,
China wedding online store,
plus size wedding dresses,
cheap informal wedding dresses,
junior bridesmaid dresses,
cheap bridesmaid dresses,
maternity bridesmaid dresses,
discount flower girl gowns,
cheap prom dresses,
party dresses,
evening dresses,
mother of the bride dresses,
special occasion dresses,
cheap quinceanera dresses,
hot red wedding dresses

asdfsadf said...

nike shoes, jordan shoes, nike dunks, nike air force 1, nike shox, nike shoes, nike shox, nike dunks, nike air force 1, nike shox, nike shoes, nike shox oz, nike shox nz, nike shox r3, nike shox r4, nike shox r5, nike shox tl
nike air force 1

nike Air Force 1, nike shoes, Jordan shoes, nike sb dunks, cheap nike Air Force 1, cheap nike shoes, cheap Jordan shoes, cheap nike sb dunks, discount nike Air Force 1, discount nike shoes, discount Jordan shoes, discount nike sb dunks, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes

nike shoes, nike shox, jordan shoes, puma shoes, nike dunks, nike air max, nike air force one, timberland boots, ugg boots, nike shoes, nike shox, nike air force 1, nike sb dunks, puma shoes, nike air max, jordan shoes, ugg boot, jordan sneakers, timberland shoes, bape shoes, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes

products said...

China Wholesale has been described as the world’s factory. This phenomenom is typified by the rise ofbusiness. Incredible range of products available with China Wholesalers “Low Price and High Quality” not only reaches directly to their target clients worldwide but also ensures that wholesale from china from China means margins you cannot find elsewhere and buy products wholesaleChina Wholesale will skyroket your profits.

products said...

Women’s nike tn Shox Rivalry est le modèle féminin le plus tendance de baskets pour le sport. tn chaussuresConcernant la semelle :Cheap Brand Jeans ShopMen Jeans - True Religion Jeans nike shoes & Puma Shoes Online- tn nike, le caoutchouc extérieur, l’EVA intermédiaire et le textile intérieur s’associent pour attribuer à la.ed hardy shirts pretty fitCharlestoncheap columbia jackets. turned a pair of double plays to do the trick.Lacoste Polo Shirts, , Burberry Polo Shirts.wholesale Lacoste polo shirts and cheap polo shirtswith great price.Thank you so much!!cheap polo shirts men'ssweate,gillette mach3 razor bladesfor men.As for

Anonymous said...


About Me

My photo
I'm a software developer who started programming at age 16 and never saw any reason to stop. I'm working on the Presentation Platform Controls team at Microsoft. My primary interests are functional programming, and Rich Internet Applications.