So part of my new years resolution is to learn more technologies. I am very strong in Java, ask me to do something and I can rip it out with Eclipse and a JVM. C++ is my second strong suite. Even though it doesn't look like professionally I'll be moving out of these technologies for a while, I think its important for me to try new things.
Last night I was playing with Cocoa and Objective-C. Apple has heavily adopted these technologies so I wanted to see why they went this direction. Objective-C is an Object Oriented Language that contains the speed and power seen in C/C++, but also has many of the dynamic features you see in Java and Ruby.
C++ lovers talk about the power and low-level access you get from the language. Whether you are interfacing with a piece of hardware or writing a GUI, it can be done directly in C++. However, you miss out on the dynamic features like Reflection and inspection that Java has. But in Java you are restricted by the fact that you exist in a Virtual Machine and everything you need to access in the operating system either needs to be done using the Java API, or some JNI layer which gets you back to C++.
Objective-C fixes this by the way its classes are defined and how you interact with them. Rather can calling methods, you are really sending them messages and receiving responses. You can inspect if an object will respond to certain messages and change that at runtime (a little scary). They have also changed the way inheritance is done by adding sort of a "Role" attribute.
Another neat thing about Objective-C is that it can link against call C++ APIs natively. This is huge for anyone who has had to build a Java JNI interface to some C++ code they need to access, it isn't pretty.
However with all the dynamic stuff in ObjC you do give up some of the stability and security C++ offers. But with great power also comes great responsibility. All-in-all I really like it and wish it was used more in my professional world. I can think of a lot of situations where my C++ programming tasks would be easier with just simple inspection.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment