Type Systems in Objective-C and C++

Objective-C offers a few advantages compared to programs written in pure C or C++. For example, with Objective-C you are have access to a comprehensive library that can handle most program-ming tasks on desktop or mobile applications.

On the other hand, if you’re used to C++ style of programming it does take some time to get used to Objective-C. It is necessary to realize, for example, that Objective-C requires a different way of thinking about software development when compared to other languages. For one, in Objective-C you have to get used to make programming decisions that will be performed at run time.

But I would say that most of that time is spent on good surprises. After all, Objective-C follows more closely the path traced by the OOP paradigm, while C++ is fond of the many compromises for the sake of pure performance. After using the language for a while it may even be hard to go back to the C++ way of doing things — with all its nasty problems and the huge amount of work involved with exception handling, for example.

And the good news is that, although Objective-C is the language used by Apple, it is also a standard and available through GCC in most modern platforms. Therefore, even if you’re developing for Windows you could still use Objective-C in new projects. Of course you will have to do some fighting the system if your program is in C++. This is the main reason why some people with large codebases avoid this route, but it might be a good idea if you’re starting a new project from scratch.

Relaxed Type System

Across the many features provides by Objective-C, what stands out in the first place is that it provides a nice departure from strong static compilation, the hallmark of programming languages such as C++ and Java. Static compilation has some advantages, but its problem is that it requires the programmer to determine a lot of de-tails even before the program can be compiled into an executable. For example, a C++ programmer has to come up with a class hierarchy or a set of templates that represent the software. Once this is done, they have to stick with the consequences of these decisions.

On the other side, Objective-C allows programmers to create code with less formal requirement from the beginning. For example, classes can just extend NSObject after the fact, using mechanisms such as extension protocols. In fact, Apple has consistently done this with classes such as NSString, which is extended to handle more responsibility as new frameworks are loaded.

About the Author

Carlos Oliveira is the author of Objective-C Programmers Reference.

Related Books

Here are some other books on this topic:

Programming in Objective-C

Objective-C Programming

Similar Posts:

About the Author

Carlos Oliveira holds a PhD in Systems Engineering and Optimization from University of Florida. He works as a software engineer, with more than 10 years of experience in developing high performance, commercial and scientific applications in C++, Java, and Objective-C. His most Recent Book is Practical C++ Financial Programming.

Post a Comment