Finally I decided to try out the programming tools of MacOS. I haven’t done desktop programming since Windows, years ago and it was a pretty bad experience. I had to program a lot of things before getting something done. After looking at the tools provided with MacOS and read some documentation about its framework, I was pretty excited to learn more about it. And when you look at all these great applications that makes MacOS its even more attractive.
I never liked IDE because I found them too big and not enough flexible. I’m more an Emacs guys with some habits. Learning to program on a new platform is something very frustrating because you start from scratch again and you have to be patient because you feel lost. But lets face it, to get things done you sometimes have to accept to work with different tools even if they are not your dream environement.
Objective-C as the Core
Apple choose Objective-C as their implementation language, so you have to learn it. Even if there are bindings for Java or Python they are not yet complete and not as integrated as Objective-C. The foundation of the language is not difficult to learn, its standard OOP business but I’ve to admit that managing memory manually again is frustrating. Being used to Java and dynamic languages such as Common Lisp and Python that’s a step back for me.
Xcode and Interface Builder, the Power Tools
With MacOS X, the power comes from the tools. Programming a desktop applications means GUI programming and that were most enviroments fails to provide the good tools. Cocoa is the application framework of MacOS X. Xcode, the IDE comes with Interface Builder an application designer. At first sight its seems to be two different applications but they are actually tighly integrated.
When you start a project with Xcode, it comes with a default GUI that you can edit and build with Interface Builder. It is more than a simple GUI editor or code generator, it saves you from writing the glue code between the GUI and the core of your application. From Interface Builder you can bind different elements of the GUI together and define behaviors.
For example, if you want to write an application for managing books you would build an interface with a table for the book entries and buttons to add, remove and inspect books. The books will have to be inserted into a database (say, an array) to be managed by your application. The great thing is that you don’t have to write any code for that. All the thing you have to do is defined what is a book. Interface Builder makes an extensive use of the MVC design pattern and it does the job for you. Thanks to what Apple calls the Cocoa Bindings you will be able to keep synchronized the GUI and the values to be used by your application automatically.
The result of Interface Builder is called a NIB. Its a bundle where all the objects required by the GUI are serialized in, even your own objects. At the start of the application, everything loads up and you’re ready to start the business. There is no generated files polluting your project directory, it is done before. In the example I told you before, you would only have a book definition class. With IB, it’s very fast to produce a working application.
I have to precise that Objective-C, even if compatible with is not C++. It comes with a runtime system that provide late bindings and introspection features. That helps Interface Builder to do the job. When I see that tool I wonder why there is no equivalent in the Java world. It provides the same kind of mechanisms and most developers still write Swing applications manually. Programming a desktop application is the matter of assembling graphic elements and plug behaviors in. Writing it is a pain and cumbersome task. You should focus on the business of your applications instead of dealing with the GUI.
Xcode and Interface Builder are very great tools. When you add technologies like Core Data that–with the same process–abtract you from building the database of your application, you can be very productive.
Do More with Frameworks
MacOS X comes with very good frameworks from real-time image compositing to PDF generation. All kind of services you would expect from a modern computer systems. Programming MacOS X application can be fun and very lucrative if you listen to some guys in the community. Good arguments to try it.
My first impression to Cocoa programming are very positive and I’ll continue to explore it by writing small applications. I’ll keep you posted about my next experience.




Add New Comment
Viewing 1 Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks