Twitter and Nu with MGTwitterEngine
Here’s a quick demo of Matt Gemmell’s MGTwitterEngine with Nu.
A Nu take on Objective-C Actors
The Actor model of programming was presented in 1973 by Carl Hewitt, Peter Bishop, and Richard Steiger. You can find their original paper online and their ideas can be found in many contemporary programming languages, including Erlang and Io.
An actor is an abstract encapsulation of computation that makes it easier to represent multiple concurrent streams of control. One way to see actors is as objects that run in their own dedicated threads; messages are sent asynchronously from actor to actor, and each actor concurrently receives and responds to its messages, often by sending new messages to other actors.
I’ve written a short Nu program that sketches a pattern for actor-oriented programming in Objective-C. Except for its use of Nu blocks (a.k.a. anonymous functions), my entire example could be easily rewritten in Objective-C, and with a certain loss of flexibility, message selectors could be used instead of Nu blocks to build a purely Objective-C solution. But once you’ve seen it in Nu, you may not want to go back.
Scripting NSOperations with Nu
One of the big problems I had with the Python and Ruby bridges to Objective-C was that neither Python nor Ruby worked well for multithreaded programs. For both, the best we could hope was to use them on an application’s main thread. But if you (like I) wanted to use a scripting language to write actions to be run on other threads, you were out of luck.
But Nu is different.
SmallSockets with Nu
Last week Colin Barrett suggested that I take a look at SmallSockets, a lightweight Objective-C wrapper for BSD sockets. Today I downloaded the code, built it as a framework, and ran it through a few simple exercises with Nu. Like its name suggests, SmallSockets is simple, but that also means that it’s really easy to use.
Here’s a quick demo.
The World's Simplest Distributed Objects Example
With many Cocoa design patterns, getting started is the hardest part. Distributed Objects is a perfect example of this. Run these two scripts to see how simple Distributed Objects can be. It’s all Nu, so there’s no compilation necessary. Be sure to use Nu-0.3.0 or later.
Nu/Linux update
Here’s an update on my port of Nu to Linux.
Dependencies
So far I’ve been running on Ubuntu 7.10 in VMware and using debuggable versions of libobjc and libFoundation that I built from source. Nu also depends on libffi, and on Linux it uses the “stock” libffi that Ubuntu and Debian users can install with apt-get.
OSCON '08 Proposal
I’ve submitted this proposed talk to the O’Reilly OSCON in Portland this July. If you have ideas or suggestions to help improve it, let me know!