(archive 'newLISPer)

October 2, 2007

Hello nu (Lisp)

Filed under: newLISP — newlisper @ 11:48

In other nu-s: say hello to the nu programming language. Nu™ is an open-source programming language descended from Lisp. Read all about it here. It’s based around Objective C, which means that, in practical terms at least, it’s MacOS X only at the moment. Tim, nu’s creator, says:

In a lot of ways it’s like Ruby, but in one important way, it’s Lisp. You might say that it’s “Ruby with Parentheses”, but it’s called Nu, and it’s not just for the desktop.

And here’s a sample of nu code:

 
    (class ConverterController is NSObject
      (ivar (id) window (id) form)
    
      (imethod (id) init is
       (super init)
    
       (set @window 
          ((NSWindow alloc)
               initWithContentRect:'(125 513 383 175)
               styleMask:(+ NSTitledWindowMask
                            NSClosableWindowMask
                            NSMiniaturizableWindowMask)
               backing:NSBackingStoreBuffered
               defer:0))
       (@window setTitle:"Currency Converter")
    
       (let (form ((NSForm alloc) initWithFrame:'(15 70 348 85)))
    
        ('("Exchange Rate per $1" 
           "Dollars to Convert" 
           "Amount in Other Currency") each:
          (do (text) (form addEntry:text)))
    
        (form set: (interlineSpacing:9 
            autosizesCells:1 
            target:self 
            action:"convert:"))
    
        ((@window contentView) addSubview:form)
        (set @form form))
    
       ((@window contentView) addSubview:((NSBox alloc) initWithFrame:'(15 59 353 2)))
    
       (let (button ((NSButton alloc) initWithFrame:'(247 15 90 30)))
            (button set: 
              (bezelStyle:NSRoundedBezelStyle 
               title:"Convert" 
               keyEquivalent:"\r" 
               target:self 
               action:"convert:"))
            ((@window contentView) addSubview:button))
    
       (@window orderFront:nil)
           self)
    
      (imethod (void) convert: (id) sender is
         ((@form cellAtIndex:2) 
           setStringValue: 
            ((* ((@form cellAtIndex:0) floatValue)
                ((@form cellAtIndex:1) floatValue))
                stringValue))))

As you can see, you’ll be better off if you already know your way around Objective C (notice all those NS objects?). Unfortunately I’m already using up most of my brain cells working with newLISP, and I didn’t see any tutorials floating around to make learning Nu any easier than it looks. But it’s great to see people coming up with new languages.

Comment from cormullion

Sorry about the formatting. It’s hard to retain the original’s formatting given the limited width of the text area…

Leave a Comment »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Create a free website or blog at WordPress.com.