3 ms·
Objective-C: "You messaged?" I believe that Objective C is a pretty good (yes, it's getting old) combination of C compatibility with object oriented features a
by neverartful 11y ago
Objective-C: "You messaged?"
I believe that Objective C is a pretty good (yes, it's getting old) combination of C compatibility with object oriented features as well. The 2 big downsides IMO are: (1) essentially restricted to Apple ecosystem and (2) the syntax keeps a lot of developers away.
- QuercusMax 11y agoI agree strongly; I never really mastered C++, but I've done lots of Java development and enough C developments in anger to consider myself at least a journeyman C developer. (I know enough C++ to be dangerous.) The message-passing syntax is such a funny thing to me; it looks weird, but it takes about 1 minute to grok if you try, and then the rest is very simple. It's really dynamic and lets you do some very powerful things that you wouldn't expect to be able to do in a C-derived language (NSProxy, respondsToSelector:, etc.). I find it very natural when doing ObjC development to write all my high-level code is very "objecty" style, and then call into pure C methods when I'm doing something tricky/low-level/fiddly. On the downside, though, mostly due to it being old and not very well adopted, ObjC never got a proper generics system, which is really annoying if you're used to Java or C++.
- nickpsecurity 11y agoMy quick perusal of online links show that Objective-C is slower than C++, maybe due to its dynamic typing. It has the C compatibility and basic OOP. Yet, my idea was a language like this which is faster than C++. Maybe a statically typed version of Objective-C would do?
- neverartful 11y agoThe OO parts of Objective-C will likely be slower than the OO parts of C++ in many cases. There are a few places where ObjC can help even the score on performance. Typically ObjC objects are not copied (cloned). Normal usage (within a collection, ivars, etc.) is with reference counting. Prior to C++11 (shared_ptr, unique_ptr, etc.), there wasn't a good way within the language itself to track object ownership without having to make object copies. Since C++ and ObjC are both (essentially) supersets of C, you can always mix however much (or little) of plain C that you want. Everything about OO in ObjC is very dynamic. It allows you to do some very cool/flexible/unsafe/unwise things. In my opinion, that where the tradeoffs start showing up. Flexibility, runtime speed, nice abstractions, development speed, code complexity, etc. Really difficult, if not impossible, to have them all at once. Despite the unusual looking OO syntax of ObjC, overall it's a pretty simple language given the power it provides. Once you get acclimated to looking at its syntax, I'll even dare say that it's much easier to read and understand than many other languages.
- nickpsecurity 11y agoI appreciate the detailed reply. It seems like it's not a fit for my zero-overhead strategy but an interesting alternative to C++ for app development.