dimanche 31 août 2008

iPhone apps performances


While struggling to speed up the app I am developping for the iPhone, I discovered how heavy and resources demanding the NSLog() method was. Ok, right, I know this is quite obvious, but if you forget to remove the NSLogs from your code, you will just see the responsiveness of the app drop by almost 80%. How lovely is it?
What is a pitty, is that I couldn't find any common or standard way of deactivating the NSLog() when building for Release. I had to use the infamous #define DEBUG 0 if(DEBUG) NSLog(...), like I was and its respectiveback in the nineties...

Hope this post will remind that you have to deal with this output !

C++ matrices and vectors library


The iPhone SDK is nice even if the iPhone developer program is crap (I will talk about that another time).

My main problem with it has been the external libraries I usually use, such as GSL (Gnu Scientific Library). Indeed, the software linked to it would perfectly work within the simulator but could not be used on the iPhone as the library is not compiled for ARM architecture. And I had no clue how to compile it for this platform.
I ended up looking for a simple algebra library (I just needed a few matrices and vectors manipulations), although I can't understand Apple not providing it... I also wanted to access elements easily , meaning I wanted a C++ library with operator overloading and not an Obj-C one.

I finally found the following library : C++ Grid from Kenneth Wilder
It is really straightforward to use. You just add the header which contains all the source in your project and that's it. The "gt_*" files are examples and they are very self-explaining and complete. Thanks Mr. Wilder for this lib !

However, I didn't test this library extensively and I guess the performances are not incredibely good, but it is certainly enough for simple things.

jeudi 14 août 2008

Java gives you pleasure...


Yesterday, I discovered again the pleasure of programming !
You know, when you enjoy spending your evening writing code and seeing your software building up ? This was lovely.

I guess I should give a word of explanation at this point. My first job involved writing project management tools in Java. I did it for 3 years. Now I am developping a data quality monitoring tool in C++.

I always considered C++ uglier than Java, old-fashion and unproductive. But, as a smart guy should do, I also tried to convince myself that was bad "a priori" and that I would change my mind if really working in C++.
I was f***** wrong !
C++ stinks. C++ is ugly. C++ makes you focus on the language instead of focusing on the core purpose of the software.

Coming back to yesterday's evening, I was looking for a simple Todo application ; something just a bit more convenient than a file text, where I could log the stuff I have to do for a project. Surprisingly, I couldn't find anything fitting my needs on the web. It was always too complicated. There are plenty of smart tools to manage issues or bugs, but I really wanted something which need no more than 1 minute to fill a new item.
Finally I decided to write my own tool. I am pretty sure this is a very common exercice in programming course and it would clearly be a very small task.

Here comes the interesting point. I hesitated between Java and C++ started listing my needs and how each of them would cope with it.

First point, I would need a gui proposing an editable table component. Java has one in the sdk, no problem with that. Moreover, I found in less than 2 minutes a free GUI builder for eclipse. What about C++ ? Well, nothing standard here. I have not much experience about that and would have to go through the documentation of several frameworks before finding what I need and understanding how to implement it.

Second point, I need to save the data. C++ sucks and I would have to spend time on that point whereas Java provides me with serialization. Of course, it would maybe take less than 30 minutes to write a basic serializer fitting my needs, but it took less than 2 minutes to do it in java...

Third point, if possible it would be nice to have the tool able to cope with new columns/fields for the Todo. In java I can use the introspection to look at the properties of the Todo and create the table accordingly. In C++ I guess there is a solution but I can't see it right now. No introspection for sure...

Last point, I want to write it fast and dirty, during a single evening if possible. I did it in java and it works. The code is far from perfect, but thanks to the nice IDE and the fact that I don't need any external lib, a few hours were enough. In C++, I can't believe it would have been as quick and stable as that, even for someone with several years of experience.

I know I am not fair with C++ because most of the reasons I didn't choose C++ were mostly related to my lack of experience. Anyway, when writing Java code I really enjoyed it and felt productive. No needs for any external library to solve trivial problem. No problems with those nasty pointers. Just a smooth development process.

Cigarettes...

Arrêter de fumer c'est comme apprendre à conduire. Ce n'est pas au tout début que le risque est le plus fort, c'est une fois que l'on prend confiance en soi.