NUI and languages bindings and WIP updates
what is the team working on?
We've been very busy fixing bugs and adding small features in many parts of the lib lately:
- many threading bugs have been fixed
- we have added some multi threading helpers like nuiReaderWriterLock that handle the multiple reader/one writer pattern and nuiCondition.
- many optimizations have been added to the whole lib and particularly concerning graphic rendering and the management of the widget tree. The general idea is to optimize for the iPhone without compromising on the set of offered features (if it is fast on the iPhone/iPad then it ought to be ultra fast on a desktop machine). For now have have been able to make almost no concession on that front which if very cool.
Last but not least, there have been a huge effort to open a new dimension of NUI programming by opening it to other languages than C++. We really want to add bindings for high level and dynamic languages (so called scripting languages).
There are many languages available, they are more or less easy to create bindings for and they all have their pros on cons. There is one family of these languages that even have many available implementations: JavaScript. It is also the most pervasive scripting language of all as it runs inside all web browsers so our choice has been to choose that language as the first one for which we will add bindings in NUI.
Doing bindings is a really tiresome operation and we'd rather not repeat the same boring work for every implementation of every language so we tried to have a more general solution to the problem. Thanks to the use of tamplates we have now a nice way to describe the internals of a C++ class, its methods and its types, in a very simple way. We have also a nice way to create an object and call its methods only thru a set of classes (nuiBindingManager, nuiClass, nuiFunction, etc.). This part has just been proven to work very well so we are now ready for the next step: binding the API description stored in these classes to the scripting language implementation.
There are three main families of opensource JavaScript implementations right now: JavaScripCore (KDE + Apple / Safari / iPhone), V8 (Google Chrome) and SpiderMonkey + TraceMonkey and it descendants (FireFox). The choice was not easy to do as V8 is really easy to bind to C++ but it comes without an interpreter which disqualifies it for the iPhone (JIT is not possible there). JavaScriptCore is very fast too and it embeds an interpreter but it is LGPL which would mean dragging DLL with every Windows NUI application, and moreover it is not a public API on the iPhone (it is only available thru Safari/WebKit but it doesn't expose its binding API on that platform). This leaves us with only one choice: SpideMonkey or one of its JIT fork: it is offered under a very liberal license which permits us to ship it in a statically linked binary, it has an interpreter and it is a very mature project. The only problem is that the Fast JIT implementation is not yet in the main trunk which means SpiderMonkey only use an interpreter and this makes it slow.
The plan is to bind to the slow spidermonkey first and to prot it to every platform currently supported by NUI. Then we will investigate the possibility to add the JIT implementation when possible (i.e. for Desktops). Then we will start investigating the possibility to add the glue for the other JavaScript engines as well as other languages (Lua, Python, Ruby and .NET/mono comes to mind) once a good part of the NUI API is exposed. We also plan to use the JavaScript bindings to add JacaScript capabilities to nuiHTMLView.
We welcome any help that cound help us make that whole process faster and safer by implementing the actual bindings for existing methods and then test it!
Feel free to contact us for any questions 9and if you\re willing to help.
We will hopefully update this page in a few days to report the initial success of this project!
Thank you very much for your attention,
Sébastien
Comments