Post Format

Objective-C? plain ugly

Leave a Reply

Now using a Mac for over a year I would really like to do some programming for OS X. Just to learn something new (and do some “real” work instead of creating slides).

But Objective-C?

  int main ( int argc, const char * argv[ ])
  {
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     NSLog ( @”Programming is fun! ”) ;
     [pool drain];
     return 0;
  }

plain ugly. Mixing Smalltalk style message passing with C, throwing in some brackets like parentheses in Lisp? It gets worse: we have again to maintain an interface and an implementation file for each and every class. And even if there is now a garbage collector in Objective-C 2.0, you cannot use it when programming for the iPhone. Duh!

MacRuby

So I looked elsewhere, what about MacRuby? From Objective-C (Smalltalk-style):

  [person setFirstName:first lastName:last]

to MacRuby’s

  person.setFirstName(first, lastName:last)

or

  person.setFirstName first, :lastName => last

To me that looks rather, hm, unbalanced? The first argument has other syntactic sugar than the second. Ok, I understand that there are limitations to Ruby’s malleability, and it sure is better than RubyCocoas:

  person.setFirstName_lastName(first,last)

which even has other problems. I am not sure that I would like

  person <= (firstName: first, lastName: last)

better, if that would be possible in Ruby.

Conclusion: undecided.

F-Script

Some time ago, when I was looking for a Smalltalk implementation for OS X (and don’t start with that ugly Squeak) I stumbled upon a Script language called F-Script. Its main goals are to provide

  • an embeddable scripting language for OS X applications
  • to have an interactive shell (REPL) to experiment with the APIs and to prototype solutions

It is not intended to write complete applications, but John Sterling has a nice blog entry, that shows how it could be done.

Perhaps this is the way to go. Remember: I do not want to create a real application, just to play around and have fun.

Leave a Reply

Required fields are marked *.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s