How Tim Burks and Nu Stole the Show at C4[1]
August 12, 2007
Edit: Fixed some factual inaccuracies about the language itself.
Tim Burks, noted contributor to RubyCocoa and creator of RubyObjC, gave a talk at C4[1] about his experiences with creating a Ruby <-> ObjectiveC bridge, and the problems he overcame in doing so. It was an interesting presentation, and we were all suitably appreciative when he showed his custom visual chip-design software written in Ruby with a Cocoa interface.
And then he dropped a bombshell.
For the past year, Tim’s been working on a new dialect of Lisp - written in Objective-C - called Nu. Here are its features (more precisely, here are the ones that I remember; I was so awestruck that many went over my head):
- Interpreted, running on top of Objective-C.
- Scheme-y syntax. Everything is an s-expression (data is code, code is data). Variable assignment was done without let-clauses (which are a pain in the ass) - all one has to do was
(set varname value). - Variable sigils to indicate variable scope.
- True object-orientation - everything is an object.
- True closures with the do-statement - which, incidentally, is how Ruby should have done it.
- Macros. HOLY CRAP, MACROS! When Tim showed us an example of using
define-macrofor syntactical abstraction, Wolf Rentzsch and I started spontaneously applauding. His example even contained an example of absolutely beautiful exception handling that should be familiar to anyone with any ObjC or Ruby experience. - Symbol generation (__) to make macros hygenic and prevent variable name conflicts.
- Nu data objects are Cocoa classes - the strings are NSStrings, the arrays NSArrays, etc.
- Ability to create new Obj-C classes from inside Nu.
- Interfaces with Cocoa libraries - you can access Core Data stores from within Nu in a much easier fashion than pure ObjC, thanks to Tim’s very clever idea of using a $session global to store the NSManagedObjectModel, NSManagedObjectContext, and NSPersistentStoreCoordinator.
- Ruby-style string interpolation with #{}.
- Regular expressions.
- Positively drool-inducing metaprogramming, including a simulation of Ruby’s
method_missingfunctionality. - A web-based templating system similar to ERb in 80 lines of Nu code - compare that with the 422 lines of code in erb.rb.
Tim showed us a MarsEdit-like blog editor written entirely in Nu, using Core Data as its backend - and then showed us the built-in Nu web server inside that program, complete with beautiful CSS/HTML/Ajax.
As F-Script is to Smalltalk, so Nu is to Lisp. Tim said that he hopes someday to open-source Nu; if he does, he will introduce what is quite possibly the most exciting development in the Lisp-related community in a long time. I don’t think I speak for just myself when I say I cannot wait to get my hands on it.
Entry Filed under: apple, c, cocoa, code, fp, functional, gui, nifty, nu, objc, programming, ruby. .
3 Comments Add your own
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed
1.
Victoria | August 27, 2007 at 2:03 am
Thanks for the great summary!
2.
ken | August 28, 2007 at 6:19 am
Yes, thank you, very informative. Here’s waiting for Nu!
3.
john | October 23, 2007 at 1:00 pm
I just hope Tim would have taken the same approach and created a new closely Objective-C based Ruby intepreter. Lisp mindset does not have anything to do with the real-world programmer mindset. Sorry.