Ask Slashdot: Which Classic OOP Compiled Language: Objective-C Or C++?
Qbertino writes: I've been trying to pick up a classic, object-oriented, compiled language since the early 90s, but have never gotten around to it. C++ was always on my radar, but I'm a little torn to-and-fro with Objective-C. Objective-C is the obvious choice if you also want to make money developing for Mac OS X, but for the stuff I want to do, both languages would suffice on all platforms. I do want to start out on x86 Linux, though, and also use it as my main development platform. Yes, I know quite a few other languages, but I want to get into a widespread compiled language that has good ties into FOSS. Both Objective-C and C++ fit that bill. What do you recommend? How do these two programming languages compare with each other, and how easy is cross-platform development in either? (Primarily GUI-free, "headless" applications.)
I'd go with C++ as the toolchain is mature and if you want to do any GUI work there's Qt, etc. Obj-C is more limited on Linux, but I"m sure the Windowmaker guys would love to have some more folks on board.
If you were me, you'd be good lookin'. - six string samurai
C++ is still very much a living, actively developed language. There's a lot of people using it for modern projects. It's well supported under pretty much all modern operating systems & you have excellent tools available under Linux.
There's not a lot of reason to pick up Objective C unless you plan on targeting Apple. It's pretty much a dead language everywhere else, outside of a few niche projects.
my sig's at the bottom of the page.
I don't expect any contrary opinions here on /.
NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
C++ is darn-near universal. It is everywhere and everyone uses it for everything.
Objective-C is an alternative language used, supported, and pushed by exactly one vendor. It only even exists because of the hipster mentality to "be different" just for the sake of being different with no real other point.
I don't see how this can possibly be a difficult decision.
Learn C++, and if you find yourself needing to dabble in Objective-C for some Apple device, no problem there. Doing the reverse would be more challenging and would limit your skills.
I wish people would stop treating modern C++ as if time had been standing still in the past decades. Yes, C++ is complex, but also expressive. Modern features (e.g. lambdas+auto+templates) often let you write code which is just as concise as its Ruby counterpart, but much more efficient.
Computer simulation made easy -- LibGeoDecomp
I hate C++. It's the triumph of syntax over clarity. The only thing it brought to the game was a better commenting method. I can't read a page of C++ without referring to something. I've never seen clear clean C++. I'd never willfully write in C++. Objective C is a measured improvement over C and I vacillate between obj C and GCC. Would that Swift were more like obj C and less like C++.
Have you ever heard of VB6? I'd start there. Nailed it.
Unless you're using Apple's base libraries. Implementing a new Base Library is hard, I've gotten a tiny subset working on my own to see just what is involved. I wouldn't recommend writing the full thing unless you have a burning desire to do it. Porting GNUstep Base Library to various platforms is possible, and has already been ported pretty widely. You'll have to bundle LGPL libraries with your application if you plan to distribute binaries, depending on your application that can make Obj-C a non-starter.
I use C everywhere, and never C++. C is not the easiest thing to do, but putting together portable frameworks for C is less work than doing the same for Objective-C. (at least in my personal experience, your mileage may vary). C isn't an object oriented language, in that it doesn't do anything special to make that work. But there are OO toolkits for C, with varying degrees of horribleness. A classic is Xt (X Toolkit) and Xaw(X Athena Widgets), which is not terribly C99 friendly anymore. But it does permit limited object-oriented hierarchies. GObject (GTK+) is another option for C, I'm not a fan of it, but it's not obsolete unlike the Xtk/Athena example I mentioned.
What confuses me about your question is why are you only asking about C++ or Objective-C? There is Free Pascal (Delphi clone) and D. (D is very good, I highly recommend that over Obj-C). There are probably a lot of other options out there that would suit your initial criteria, especially surprising is you didn't mention Java. It's very good example of OO, perhaps OO taken to the extreme, but it's fairly clean. (Obj-C is a little hacky, but thats it's charm and power)
“Common sense is not so common.” — Voltaire
There really isn't all that much difference, so that once you get comfortable with one you should be able to switch to the other without much difficulty if you need to. But I'd lean towards C++ because the tools are more mature.
Two other tips:
1. Use Clang (part of LLVM) as your compiler. The error messages are vastly easier to interpret, which should cut down on both learning and development time. Note that Clang supports both Objective C and C++.
2. If you do go for C++, make sure to start learning on C++11 or C++14. C++11 significantly changes quite a lot about the language, and if you start with older C++ books, you'll have to unlearn a lot of stuff if you want to develop modern C++. C++14 has mostly just minor fixes to C++11.
Object Pascal that is. It's available in Free Pascal for a lot of operating systems and is a small and fast development environment.
I don't get the whole debate. Programming is independent of language any good programmer should be able to learn a new language in a few days. In my career I've developed applications in four different assembly languages, java, Pascal, C++, basic, etc. It's just a matter of reviewing the syntax and doing the same things in slightly different ways.
Apple has made it clear their development future lies in Swift, not Objective-C.
That means you're choosing between a popular, well supported language and a dead end.
The choice should be obvious.
I do not fail; I succeed at finding out what does not work.
Indeed -- learn LISP. Lambda variables, recursion, all atoms being true objects. Then you can redefine the language to pretend to be any of the other HLLs out there.
Problem is, all the lessons that were learned with LISP have since been forgotten and are doomed to be made again and again.
You should learn c++ unless your real intent is to write a lot of software for an Apple only environment in a language they are looking at deprecating.
You can get a c++ build chain for pretty much any platform worth working on, and those without it will have a c build chain. There are literally billions of lines of c++ code out there, working in every possible environment. Programmers are churning out millions of more lines every year. You will never be out of work if you are a c++ programmer.
All those moments will be lost in time, like tears in rain.
There's not a lot of reason to pick up Objective C unless you plan on targeting Apple.
C++ is also important when targeting Apple. Objective-C is the language of the Cocoa API (Mac OS X and iOS), however there is no need to use it beyond code that makes Cocoa based system calls. And getting C++ and Objective-C code to call each other is trivial.
Personally I recommend separating UI and platform (OS) specific code from an app's core functionality and implementing the UI/platform-specific code in whatever the native language for the platform is and implementing the core code in C/C++. This leaves the core code portable, ready to target other platforms. I have iOS apps where the core code can be compiled in a console Linux environment and exercised by various scripts (regression testing) and in a random manner (fuzzing).
Submitter wants a "widespread compiled language that has good ties into FOSS".
What about plain old C? Otherwise, second best choice seems C++
I've been trying to pick up a classic, object-oriented, compiled language since the early 90s, but have never gotten around to it. C++ was always on my radar, but I'm a little torn to-and-fro with Objective-C. Objective-C is the obvious choice if you also want to make money developing for Mac OS X, but for the stuff I want to do, both languages would suffice on all platforms. I do want to start out on x86 Linux, though, and also use it as my main development platform. Yes, I know quite a few other languages, but I want to get into a widespread compiled language that has good ties into FOSS. Both Objective-C and C++ fit that bill. What do you recommend? How do these two programming languages compare with each other, and how easy is cross-platform development in either? (Primarily GUI-free, "headless" applications.)
I would only bother with Objective-C if I was anticipating having to develop a lot of code for OS X or iOS which might be worth your time since there is money to be made there and IMHO it is a fun language to code in. There is a FOSS Cocoa implementation for Linux, GNUstep but I don't know how current it is or how much cross platform development it allows. Integrating C++ code in Objective C programs (aka. Objective-C++) is as easy as integrating C code into a C++ program so for cross platform purposes you'd be best advised to write as much of your business logic in C++ or even C and use more platform specific languages like Objective-C for view and controller logic. Basically write as much in C++ or C as you can since both can be used in Objective-C apps. That way, if you also want to, say... have an Android version you could write Java wrappers for your C/C++ code. Finally be very careful about what system calls and libraries you use. Just because something is available on Linux does not mean it is available on OS X, the other *NIX'es or Windows. I have all to often seen people end up with egg on their faces after spending significant amounts of time developing something on Linux and using everything Linux offer with wild abandon only to find out hat several key functions or even entire libraries are not available on other target platforms like, say Sun OS or AIX or that even if these are available they behave in a totally different way (example: Lex/Yacc). When doing CP development, even if it is just across multiple Linux/Unix platforms, it pays to write unit tests and regularly compile your software and run the entire test battery on target platforms other than the one you do most of your development work on (which is likely to be Linux).
Only to idiots, are orders laws.
-- Henning von Tresckow
This is like asking "which medical technique should I use for treating headaches, trepanning or inhaling mercury vapors?"
Generally when people say compiled language, and they refer to things like Objective C and C++, they usually mean compile to as close to native code as possible. I love C#, but its fairly obvious that bytecode languages were not options this time around.
C++/Boost is their best bet.
Yes... You can do OOP in C. With todays toolchains, libraries and techniques, C is more viable than a lot of people give credit for.
I personally have always disliked C++, and I know I'm not the only one. I've been OK with Obj-C, but... It is a bit eccentric, and it's probably on the way out with Apple now promoting Swift.
C, on the other hand, is eternal and evergreen.
I'll admit I haven't seen much of Objective C (apart from on OSX) - while C++ is pretty much available on anything and anywhere. However I'd also recommend having a look at C#. If you are not allergic to Microsoft products it's got a lot to recommend it:
But stay away from Entity Framework and Nuget. EF is slow, and Nuget....well, even Microsoft evangelists criticize it.
Cross-platform tools like Xamarin (which as an interesting ecosystem for cross-platform mobile apps)
If you do want to do cross-platform development, you should stay away from advanced C# features like code-contracts. In fact, if you really want to do that, then you should have at least one person developing on Linux, so you stay aware of all the little incompatibilities.
"First they came for the slanderers and i said nothing."
C++ is very complex, and whole swaths of the language can be safely ignored.
And this is why I wouldn't recommmend C++. I loved the language and did it for right around ten years (1999-2009), and saw people online who knew it, but I never met anyone live in my professional career who ever bothered to really learn it. (And now later, I'm having the same experience with JavaScript.)
But I wonder about why the very particular constraint of "classic OOP compiled". I don't think I'd recommend any of those anymore; aside from specialized applications, if what one is going to be writing is large enough to utilize OOP, then VM'ed languages are much more relevant these days.
Attention zealots and haters: 00100 00100
And haskell is about 10/10, being able to expressively type functions, and make custom types. Point being some may find 7/10 good enought to catch stupid errors, while letting the code be a bit terser and more readable. I'm not sure the tradeoff is at the couple hundred lines territory, as there are often ways to add in additional type restriction in dynamicly typed languages, and you may just want to start with a quick and dirty prototype as a template for the final version.
Actually, Haskell goes all the way to 11,
Why is Snark Required?
I'm not happy with any language that's available, but that's because I have interests in hard to program stuff.
I have lots and lots of experience with C++, but I wouldn't recommend it, except as a form of torture. Java too, is gets in your way far too often, though it's better than C++.
To me, objects are a way of organizing APIs, so I DO like OO...
What to write it in depends on what features you need. Do you need it to be fast? How fast? Do you need to take advantage of multiple processors? Do you need to share data between them?
Is programmer time more important than running speed?
Is reliability more important than programming time?
One system I'm enjoying these days, though it's far from perfect is Lua, through the amazingly good trace compiler/jit Luajit.
It is every inefficient in terms of memory. It doesn't support multiple threads. It doesn't even have standard object system, though it's not hard to implement a prototype based one in it... But it's kind of like programming in Self or Ruby with the complexity knob turned all the way down.
It also has the advantage of running on everything. There's even an ARM version of the JIT.
If you don't need the speed, Python doesn't look too bad and has lots of libraries.
If you need something that can be data-center-sized then find a .net language or java... There's a lot of choices under .net and it probably scales the best. Depending on what I was trying to do, I might use F# or ClojureCLR or IronPython...
The best OO language that time forgot is Dylan. I'm disappointed that Apple never really finished developing it.
I have been mulling similar question for myself for some time. i.e. where should I spend my limited hobby time: learning Obj-C or C++?
In the last few months Rust has caught my attention. Even then it's not yet at verstion 1 (at time of writing its at alpha-1), I really like the concept and what they are try to achieve with the language.
My comment will probably be burried, but if you do read it, spend a few minutes wondering around their web site. For exmaple their 30 minute introduction to Rust.
I know plenty of open source applications, from GUIs in Qt and gtkmm to console applications and interpreters of programming languages in C++. The backbone of any Linux distribution is C and C++.
I know 0 packages in my Linux installation that are written in Objective-C. There are some, for sure, but are they widespread? I doubt it.