Please disable AdBlock. CAN is an ad-supported site that takes hundreds of hours and thousands of dollars to sustain.

NUI Framework – ObjectiveC Alternatives [iPhone, C++]

iPhone development is red hot right now, with thousands of individual developers and big brands trying to carve out a miniscule piece of the Apple’s rather large pie for themselves. Aside from the profit aspect, there are many creative programmers looking to experiment with a powerful, hand-held, multitouch multitouch device. With it’s advanced features, such as audio input / output, accelerometer, wifi, bluetooth, and location awareness, the iPhone really is a device that many people have been dreaming about for years. To program for the iPhone, a developer typically has to learn ObjectiveC and it doesn’t hurt to know some C / C++ since a lot of iPhone libraries are written in that.

ObjectiveC is an object oriented language like any other, and takes a little time to become familiar with it, due to it’s specific brand of memory management and unique syntax.

The interface framework (UIKit) is good and very well suited to touch devices, though it’s clear that Apple doesn’t really want people to mess with it. Trying to change the look and feel of built in components can be a real challenge (or be downright impossible) sometimes, since the source code to those components is not available.

People looking to get the best possible performance or write cross-platform code will find that plain ObjectiveC has trouble meeting those goals.

For these reasons, I chose to look for an alternative that would let me work mostly in C++ which I am already very familiar with. The one I decided on was the libNUI framework. Having worked extensively with Juce, I’ve come to appreciate the value of a comprehensive cross-platform framework that compiles under Mac, Linux and PC and provides abstracted access to low-level hardware such as audio, networking and graphics. LibNUI offers the same thing – a set of code that handles all the OS specific stuff for you, and provides you with a set of GUI widgets that can be easily extended or modified to meet your needs. It also provides you with the full source code so you can see how everything works and make your own changes. Since it’s 99% written in C++, performance for stuff like audio is very good. Plus, I can compile the same application on my Mac desktop, my PC or my Linux box and it works with minimal changes. I’ve currently written two iPhone apps using libNUI – bleep!BOX and bleep!Synth. I am currently exploring a Mac/PC VST version of bleep!BOX as well, and was able to get it compiled and running in only a couple hours.

Some caveats about libNUI – it’s still very heavily under  development and things are being added and fixed all the time. Documentation is a little sparse but it’s getting better. There are tutorial applications you can build to learn your way around. But if you are not comfortable digging into code and figuring out how it works, libNUI may not be for you. Expect to spend several days just learning how things work.

For those looking to experiment with graphics and sound, there is also Open Frameworks which was used in the Thump app. It’s a very basic framework around OpenGL and audio/networking protocols. It’s nowhere near as exhaustive as libNUI, but if you want something basic that you can pick up quickly, OF is a good option. Like libNUI, it’s also cross platform and open source (and C++).

If games are what you’d like to get into, a couple of the major open source 3d engines, Ogre3D and Irrlicht now compile on the iPhone. No doubt they can be used for creative coding too.

Have another iPhone framework that we missed? Post it in the comments.

Posted on: 29/12/2009

Posted in: c++, iPhone

Post tags:

  • http://twitter.com/misc Jesse Baer

    I just started learning Python as my first computer language. It's for a simple web project, because I wanted to start small — but I know what I really want to do is iPhone apps. The plan was to learn Objective C after I learn Python, but I've been tempted to forget about Python and go straight to Objective C. But this makes me wonder, is there a way I could apply Python to iPhone development? (Other than iPhone optimized webapps, which I am thinking about too)

  • http://twitter.com/zachlieberman zach lieberman

    this library (libnui) and your apps looks great !

    one difference with openframeworks is the license. we're (as well as ogre3d 1.7+ and irrlicht) MIT license, ie, “use it as you like”, whereas libnui is GPL / $$ for non open source projects.

    I'm not so hot on that kind of license, but other folks might jive with that.

    more info at: http://www.libnui.net/pages/licensing.php

  • http://twitter.com/jamiebullock Jamie Bullock

    If you want to write apps for the iPhone, but code in Python, you could try PyObjC. It looks like someone got it working: http://www.saurik.com/id/5. Good luck!

  • http://www.PatternMusic.com PatternMusic

    LibNui's paid licensing seems reasonable when compared with other commercial audio and graphics libraries licensed for the iPhone. But I think it's a mischaracterization to call it open source when it's used for commercial and free closed-source projects. (It's not even clear that Apple's license agreements don't violate GPL entirely since Apple is imposing additional terms on distribution. But there are some GPL licensed apps available on the App Store such as Frotz. Go figure.)

    I like Objective C so much better than C++, but the performance difference it ridiculous.

  • http://work.mrkbrz.com/ Marek

    libnui looks awesome, I've downloaded it in the past for a butchers, it looks very extensive, but it's the pay bit that puts me off using it. oF is very bare-bones but the best part of it is the community that comes with it. I guess the thing that makes oF a little tough for iPhone is the lack of UI stuff, which I understand libnui is pretty comprehensive with that.

  • http://twitter.com/davewallin David Wallin

    Good points – I should clarify that when I say open source I mean that the full source code is available whether you decide to pay for it or not (not that it adheres to one of the stricter Open Source licenses). Almost all the good frameworks have some kind of fee associated with them – libnui is a little steeper than lets say Juce, but if you make one semi-successful app with it, it should pay for itself.