Making the move to the Mac
Mac development for Windows programmers
As should be pretty clear from previous ramblings, I've about given up on Windows and am in the process of trying to reinvent myself as a Mac developer (I should perhaps say re-reinvent myself, since I worked with Macs back in the early days of the original 128K Mac, over 20 years ago).
Things are going pretty well so far, and if I could only resist the temptation to disassemble bits of the AppKit framework whenever I have an idle moment (see here for more on my strange personal habits) then I might actually have had a shareware application or two out by now.
This article is aimed at Windows developers who are considering making the move. The idea is to get you up to speed as quickly as possible with mainstream Mac development. Rather than discussing cross-platform programming techniques and toolkits (the subject of previous articles), I'm going to focus unashamedly on Cocoa and Objective-C. I'll assume only that you're coming at things from a RAD perspective: Delphi, WinForms on .NET, or maybe even "classic" Visual Basic. Think of this article as a "Dummmies Guide" to Mac programming if you like. All I'm trying to do here is cover the basics using terminology that should already be familiar to a Win32 RAD developer.
As with many development environments, the two most critical components in the Mac development equation are the programming language and the class library/libraries; we'll look briefly at these first.
Having bought out NeXT, Apple ended up with the OpenStep development system, hence the emphasis on Objective-C. For those who haven't used Obj-C before, it's basically a superset of C with object-oriented extensions. The syntax of the OOP extensions is rather esoteric for those unused to it. For example, to call a method taking three arguments in C++, we'd do this:
someObject->drawCircle (20.0, 27.0, 5.0);
To do a similar thing in Objective-C looks like this:
[someObject drawCircleAtX: 20.0 Y: 27.0 withRadius: 5.0];
Objective-C developers prefer to talk about sending a message to an object rather than calling a method. Notice that the name of the message (in this particular case,
'drawCircleAtX:Y:withRadius:') is arguably more self-explanatory than the C++ example because the meaning of each argument – preceded by a colon – is made clear; proponents claim that you end up with code that's more descriptive, but against this, you'll get much more verbose syntax.
Personally, I like Obj-C more than I did when I started using it, but in the gcc compiler the integration of Obj-C syntax leaves something to be desired. Leave off one of those all-important colons, for example, and you will get an unhelpful error message from a very confused parser. Put simply, part of the rationale behind the language syntax (aside from the language designer's fondness for Smalltalk) is to necessarily disambiguate the object-oriented extensions from the underlying C syntax. The brackets and colon symbols are compiler hints, if you will, which tell the thing whether it's looking at an Obj-C method call or a chunk of plain-vanilla C.
The whole thing is potentially more dynamic and reflective than many programming languages because, for example, an efficient mechanism exists for asking a particular object whether it handles some message before sending the message to the object.
Sponsored: Hyper-scale data management