The Nu World Order

I have been testing Nu by bootstrapping a small set of tools for software development. As they’ve matured, I’ve come to rely on them daily. Some of them required some thought and an occasional new feature in Nu, but none needed much code or time to develop. They aren’t as many-featured as some of their alternatives, but they are lean, clean, and do just what I need.

Here is a list of the most important ones.

nubile: code beautification

nubile is a code beautification tool that automatically indents Nu code. It can be used standalone or called from a programmer’s text editor such as TextMate.

status: in use. I currently run it within TextMate. It uses hooks in the Nu parser to correctly handle comments and embedded here strings.

nuke: build and task management

Similar to Ruby’s rake, nuke is a build and task management tool that allows Nu to be used to build Nu-based frameworks and applications. Like rake, the nuke task system is completely general purpose, allowing nuke to be used for other varied tasks such as software testing, deployment, and management.

status: in use. I use nuke to build frameworks, applications, and standalone binaries, to run tests, and to setup and archive application data files. Here is an excerpt from Nu’s main Nukefile:
(task "test" => "framework" "nush" is
     (SH "nutest test/test_*.nu"))

(task "doc" is
      (SH "headerdoc2html -o doc objc")
      (SH "gatherheaderdoc doc index.html"))

(task "default" => "nush")

; Build a disk image for distributing the framework.
(task "framework_image" => "framework" is
      (SH "rm -rf '#{@framework}.dmg' dmg")
      (SH "mkdir dmg; cp -Rp '#{@framework}.framework' dmg")
      (SH "hdiutil create -srcdir dmg '#{@framework}.dmg' -volname '#{@framework}'")
      (SH "rm -rf dmg"))

(task "install" => "nush" is
      ('("nuke" "nubile" "enu" "nutest") each: 
        (do (program)
            (SH "sudo cp tools/#{program} /usr/local/bin")))
      (SH "sudo cp nush /usr/local/bin")
      (SH "sudo rm -rf /Library/Frameworks/#{@framework}.framework")
      (SH "cp -pRfv #{@framework}.framework /Library/Frameworks/#{@framework}.framework"))

A Nukefile is just a Nu source file, so it can contain any Nu expressions. “task” is a Nu macro that creates and manages NukeTask objects, which are connected together to build a tree of dependencies.

Unlike make and rake, nuke doesn’t (yet) support rules, so build tasks are created by looping over the necessary files. Also, nuke doesn’t yet have a way to extract and include header file dependencies.

nutest: unit testing

nutest is a test harness and a top-level class that is used to define unit tests. New groups of tests are created by writing subclasses of the NuTestCase class; individual tests are instance methods of these subclasses. A few common assertions are defined as macros and more can be easily added. Tests may be run individually or in groups.

status: in use. Here’s an example from the Nu regressions:

(class TestArray is NuTestCase
     (imethod (id) testCreate is
          (set a (NSMutableArray arrayWithList:'(1 2))) 
          (a << "three")
          (assert_equal 3 (a count))
          (assert_equal 2 (a 1))
          (assert_equal "three" (a 2))))           

enu: templating

enu evaluates Nu code embedded in text files. Much like Ruby’s “erb”, enu is a standalone version of a general-purpose templating capability that can be embedded in Nu programs. Special markup allows code to be included for evaluation only or for evaluation with inclusion of the evaluation results. The underlying NuTemplate class has been used to generate HTML, CSS, XML, and Objective-C source code.

status: in use. NuTemplates are used to publish this blog and to generate documentation in NuDoc.

nudoc: documentation extraction and generation

Modeled on Ruby’s RDoc and Apple’s HeaderDoc, the goal of nudoc is the automatic generation of reference documentation for programs written in Nu and Objective-C. Documentation is organized logically and without regard to a class or method’s implementation language.

status: in development, but nearing completion. This project got sidetracked when I learned about Apple’s HeaderDoc tool; I was hoping to find a way to blend documentation extracted from Nu files with HeaderDoc’s output from Objective-C files. But after digging through the HeaderDoc sources (and discovering how easy it is to extract Objective-C declarations with regular expressions), I decided to build NuDoc to read both Nu and Objective-C. My current nudoc draft is a single 850-line Nu source file that includes parsing code, page templates, and a stylesheet. It reads both Nu and Objective-C source files and generates an index and documentation pages for each file and class.

8 comments ↓

#1Matt Mower on 2007-08-30 at 06:06:11 America/Los_Angeles

Tim, please, put us out of our misery and release it already ;-)

#2anonymous on 2007-08-30 at 08:42:25 America/Los_Angeles

When can we expect a release?

#3Tim on 2007-08-30 at 09:01:17 America/Los_Angeles

Sorry, I’m not even good at committing to dates for paying customers, much less anonymous ones. I’d like to release it sometime this fall, but it’s still a very young project.

#4Tim on 2007-08-30 at 10:11:48 America/Los_Angeles
Meanwhile, I’ve put some nudoc output online "here":http://blog.neontology.com/nudoc-preview/index.html. It’s level-zero reference material that was automatically extracted from the Nu sources. It won’t help anyone get started with Nu, but it might be interesting to other Objective-C geeks.
#5David Phillip Oster on 2007-09-02 at 14:10:07 America/Los_Angeles

I got tired of waiting for Tim to release Nu, so I just wrote my own lisp interpreter that easily interfaces to Objective-C. You can find it, with the source code, at: http://turbozen.com/sourcecode/TinyLisp/

#6Tim on 2007-09-02 at 14:40:27 America/Los_Angeles

Hey, that’s not bad, and it’s a lot less code :-).

#7David Phillip Oster on 2007-09-03 at 11:51:41 America/Los_Angeles

Thanks. Turbozen Tiny Lisp is a toy to play with until I can work with your polished code. But, being a toy, it is very easy to embed it in something else, or embed something else in it.

Keep up the good work Tim, you’ve got a fan here.

#8Tim on 2007-09-03 at 13:33:56 America/Los_Angeles

David: Whew. Turbozen Tiny Lisp looks a lot like an early version of Nu. Now I know how the Common Lispers feel :-)

I’ve finished cleaning up the core, settled on a license (the Ruby license), added some basic documentation (build instructions, etc), and am now sorting through the examples to pull out some proprietary stuff while leaving enough in to keep them interesting. Then I’m planning to ask a few people to kick it around for a week or two before a more general release. If you are interested and have time to help with that, send me an email and I’ll let you know when it’s ready (probably in the next few weeks).

Leave a Comment (sign in with Twitter)