Going Ape

What with mentioning Monkey here, there and everywhere of late, I thought I’d expand on why I find the language so inviting. Of course I could just say “It’s BlitzMax for mobiles!!!” and leave it there, but while that might convey my excitement (three exclamation marks!) it wouldn’t explain much to those unfamiliar with BRL’s prior work.

A Base Monkey Project Is Simple

Simple in a way that even minimal platform-native projects tend not to be. The basic structure of a Monkey program looks like this:

Import mojo Class MyApp Extends App Method OnCreate () End Method OnUpdate () End Method OnRender () End End Function Main () New MyApp End

You’re not worrying about a multitude of libraries or headers simply to get going – you import Mojo (the 2D graphics module) and you’re set. Compare that to the looming complexity of an XCode, VisualC++ or XNA project (bolstered by their not-inconsiderable IDEs) and you can see how Monkey gives you room to breathe, free of technical clutter. Now, obviously, you’re not going to be able to avoid having to edit and tweak the native projects that Monkey spits out for you, especially if you want to actually release something on iOS or Android or whatever. It’s important to realise that Monkey is (at least in my opinion) a tool to aid developers who know how to get things done natively, but who want to spend the majority of their development time coding at a higher level and in a re-targetable language. Which brings me to…

Monkey Is Cross-Platform

Not only in the sense that it is cross-platform, the same code being used to generate iOS, Flash, HTML5, Android, XNA and Win/OSX-native projects, but also in the sense that the syntax is highly readable and therefore eminently portable longhand. Monkey offers enough power to be useful but not so much that it’s dangerous and obfuscated, which brings me to…

Monkey’s Syntax Is Lovely

One of the things I like best about BlitzMax is that you don’t have to know what a pointer is and it’s the same with Monkey, making for some very clean code:

myInstance = New myClass

Isn’t that a lovely way to instantiate an object? If you see an asterisk in Monkey it’s because something is being multiplied! The OOP feature-set is, itself, well considered: You get inheritance but not multiple inheritance, for example, function overloading but not operator overloading. It’s not a hand-grenade, it’s just handy.

There are a few things I don’t like, admittedly. It’s bizarre, frankly, that the ‘Global’ keyword is used to denote static members and it’s something that can only serve to confuse those who are learning with the language (“So this is a not-actually-global global?!”) I wouldn’t have minded C-style For loops on top of the BASIC-like For.,.Next syntax, either, but what we have makes for some very lovely collection iteration…

For Local currentInstance:MyClass = EachIn myList currentInstance.Update() Next

…so It’s really not a biggie :) Continuing with the pluses, Generics are there for those who value them (the topic is new to me) along with niceties like Constructors and some interesting collection classes (linked lists, hash maps, stacks, sets), but the one thing I really value is that…

Monkey Is Garbage Collected

I love garbage collection. I love how it takes the kind of mistakes that were the bane of developers lives and makes them good practise. (Now it’s true that its suitability for game development has been questioned, but I really think that just stems from people not always grokking that it isn’t there to let you carelessly instantiate and destroy a babaillion objects every game loop. If you take care not to invoke garbage collection at critical moments then it need not make your game hiccup.) Suffice it to say, you have to manage your memory somehow, so having it dealt with automatically while you get on with what you actually want to code (which probably isn’t a memory management solution) can only aid productivity. Which brings me to…

Monkey Is Quick

I’m going to qualify this by saying that, without a lot of the cool things that, say, Cocos2D offers (2D physics, tile-maps, scenes, transitions etc) out of the box, Monkey probably can’t currently qualify as a truly rapid application development solution. There’s a lot of stuff that you probably want that you’re either going to have to code or integrate.

However when I think about simply adding a member to a class under Cocoa Touch and what that entails (declaring it in the interface, setting its property, synthesizing it in the implementation, writing the release code…), I know I’d much rather have the cleaner, more elegant syntax of Monkey for the actual “top level” application stuff. Testing ad-hoc ideas and revising existing code form such a large part of the development process that the maintainability of Monkey source has to matter to anyone wanting to finish in a timely manner. Which brings me to…

Monkey Is Free To Try

I’m going to stop evangelising now and let Monkey do the rest for itself. The demo will build to html5 and is free for non-commercial purposes. Have fun!

<< Go back to the previous page