XCode annoyances


I have started to seriously play with Objective C and XCode about week ago. So far it was very pleasant experience. I really like the language – feels like Ruby (or Smalltalk if you want) with rocket launcher: very powerful, blastingly fast and dangerous like hell. No array boundary checks as in Java :-).

The XCode was not bad experience either. Here my very long Eclipse and Visual Studio history is going a bit in the way, as the things often works quite different. Not necessarily worse, but different. It would be too early to judge it – not before I get more proficient in both Objective-C and XCode and learn more Cocoa goodness.

Two things however are so annoying, that I have to mention them right now:

1) Setting breakpoints was gamble – sometimes it worked, sometimes it did not. I could not figure out why, until I found here that you must in Preferences -> Debug switch off the ‘Lazy loading symbols’. After re-entering the breakpoints, I finally got it to behave as expected.

2) Trying to add existing files to a projects crashes the XCode with the following:

The console window shows error:

PM Xcode[34563] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '
*** -[NSAutoreleasePool stopObservingModelObject:]: unrecognized selector sent to instance 0x32da240'

which is clearly a bug. I tried to reboot (it was about time after running for over two weeks anyway), no help.

Weird is that I remember doing that before without any problems … Workaround is use drag and drop, of course, but I wish Apple would fix this Really Soon, as it is plainly embarrassing …

I have seen crashes like this in Visual Studio, but Eclipse was rock solid environment despite the very complex plugins ecosystem, so it is hard to go back to use something blowing under your hands …

Couple of Objective-C and Cocoa links


Lured by the iPhone platform, this is what I read in the evenings. Feels kind of funny: after 10+ years of Java/C# and almost as many years  of C++ beforehand, I mostly lost my C instincts and C habits. Fortunately, I have also mostly lost my C++ bad habits as well.

The Apple site is definitive starting point – put the http://developer.apple.com/referencelibrary/index.html into your bookmarks. From non-Apple sources, very bookmarking-worthy is the Cocoa Literature and Cocoa Devcentral.

Theocacao has a nice example highlighting diferences between Objective C 1.0 and 2.0. There are many tutorials available, with various depth and quality, e.g. here, and here. Wikipedia page is also quite useful.

From books – I have browsed few in Chapters and on Safari Books, the best still seems to be Hillegass’s book. There is an updated version (for Objective C 2.0) coming out in June 2008.

From list of links, try this.

Excellent comparison of C++ and Objective-C


One of the languages that I managed to completely ignore for almost 20 years was Objective-C. I always saw it as less developed, dead-end version of C++ that has little perspective – despite that GCC supported it since early days. I guess I was wrong on two of three counts – that of little perspective still holds as long as you want to stay outside of OS-X platform.

One of the issues I had was strange syntax and that from not too many books on subject, they were

a) too hard to read because they attempted to explain Cocoa / Carbon frameworks AND the language at the same time and

b) that they were focused on beginner audience and basically went too basic into the OOP principles and fairly obvious (for experienced programmer) stuff.

What I always really wanted was detailed comparison how are things different to Java or C++. And I managed to finally find it. The good guy named Pierre Chatelier wrote exactly that. The document is over 50 pages long, has just right mixture of details and is available in English and French from here. The target audience is experienced C++ programmer, but to my pleasant surprise – even if my C++ is a bit rusty (did not do any serious coding in C++ for over 8 years) – it was perfectly understandable. I guess C/C++ is like riding a bike – once you learn it, you have it forever :-).

The point of actually looking at Objective-C is simple: you should not learn a new programming language that does not change the way how you look at programming or program design. And Objective-C seems to be very good candidate to deliver that. The strange syntax (borrowed from Smalltalk) is actually quite simple after you overcome mental blocks inherited from UML (that + and – do indicate public/protected) and Java/C++/C# (that <Something> is related to generics/templates). The language is surprisingly powerful and I am quite enjoying reading about it. I think you will be seeing more of it on this blog …

Managing knowledge portfolio


There are few technical books which you enjoy first time you read them, remember the experience and keep coming back. One of such classic books is The Pragmatic Programmer – from journeyman to master – by David Thomas and Andrew Hunt. If you have not read it, get it, it is worth every cent. Since the book was written – ages ago, back in 2000 – it did not loose anything of its freshness and value – which one cannot say about most of technical books written earlier than 2-3 years ago. Inspired by the success of their initial creation, Dave and Andrew started the website and continued writing whole Pragmatic Programmer series of books.

Book contains 46 tips and explanations and the tip #5 deals with knowledge portfolio – one of developer’s main assets. Unfortunately it is expiring asset so you have to work hard to keep it recent and in good shape. Dave and Andy recommend using the same strategy as successful investors in finance markets:

  • invest regularly – even if small amounts, but create habit investing
  • diversify to embrace change and to widen the reach
  • manage risk – combine high-reward high-risk with low-reward low risk
  • buy low, sell high – try to identify future hits before they become popular
  • review and rebalance – what was true last year, can be different now

They also recommend few practical steps and goals how to achieve the healthy and well balanced portfolio, such as:

– learn new language every year
– read a technical book every quarter
– read nontechnical books too
– participate in local user groups
– experiment with different environments

Which got me thinking about how am doing wrt these suggestions. I guess I have no problem with “read a book” part, either technical or non-technical 🙂 – thanks to Safari I consume 1-2 technical books a month and thanks to e-books even more non-technical ones :-). What I have not done in about 3-4 years was learning a new language. I think I have not learned really new language since C# in 2002. One could argue that for Java programmer, C# is not really such a new language – in that case I have not really updated my language toolset since I started with Python back in 2000. That is terrible ! Obviously, some action is required – I am overdue at least with 4 new languages. Because it is highly impractical to tackle 4 problem at the same time, for this year I will be adding two.

But which programming languages ? Key here is the word pragmatic and the investment strategies above – more specifically, combining high and low risk, buying low and diversifying. I want to explore new territories, but stay away from esoteric and pure-research areas (e.g languages like Janus, Limbo or Concurrent Haskell :-)). After some research I picked two candidates: Ruby and Objective-C for the year 2007.

There are few reasons why exactly these two: they are both similar (with Smalltalk and functional programming/OO heritage) and opposite – one is multiplatform, interpreted, very high level, the other is (practically) single platform – OS-X language of choice, compiled and up to version 2.0 not even garbage-collector enabled. One has pretty clean and nice syntax, other is – well – simple, but quite ugly. And so on.

I have started with Ruby yesterday – found a good book on Safari and started to read and play with the code. I will get back to it when my head stops spinning – and after I get some non-trivial programs done to get some real life feeling of the language. From the book reading point of view, it is pretty amazing what I have found in few hours :-).

Btw, the version 1 of the Ruby boom by the same two authors is available online.