Learn C++ or C# Before Objective-C?

Discussion in 'Mac Programming' started by Josh Kahane, Dec 10, 2009.

  1. Josh Kahane macrumors 6502

    Aug 29, 2006
    Suffolk, UK

    So I know that Object-C is the prodominent Mac and iPhone programming language but I am currently an A-Level student taking Computing and I have been given the choice to follow and learn C++ or C#. Whic is best to leanr for becoming a Mac/iPhone programmer in future?

  2. mags631 Guest

    Mar 6, 2007
    These are all dialects of C (expanded to support object-oriented programming and other "modern" techniques). They are both different enough that regardless of your choice, you will still have to learn Objective C.

    If you stick with software development, you'll find that the language is rarely the impediment to developing (good) software, and is almost never a reason to not do a project. The frameworks and APIs might be a reason, since there is lot more to learn (relative to features of a language).
  3. Catfish_Man macrumors 68030


    Sep 13, 2001
    Portland, OR
    C# is not a dialect of C. It is a significantly nicer language than C++ though, I would go with it.
  4. DazBrowne macrumors member

    Dec 6, 2009
    I have no programming history at all and have never learned any type of computing language and am currenty studying c++ and just thought id let you know that its tough!
  5. mags631 Guest

    Mar 6, 2007
    You are right, that it's not a dialect (I overly simplified on that point). However it is in the same family, as discussed by its chief architect.


    In any event, the choice of language is not as interesting as the choice of framework. You can and will learn a ton of different programming languages in your lifetime with very little effort. The frameworks are much harder to learn and use well.
  6. Josh Kahane thread starter macrumors 6502

    Aug 29, 2006
    Suffolk, UK
    Hmm, ok well Im leaning towards C#. Any reasons why I shouldn't learn C# and go for C++?
  7. rowsdower macrumors 6502

    Jun 2, 2009
    It's much easier to write cross-platform applications in C++. That may or may not be important to you.
  8. gnasher729 macrumors P6


    Nov 25, 2005
    C++ code using the standard C++ library (STL) will work on your Macintosh. C# won't.
  9. mark2288 macrumors regular

    Jan 11, 2006
    I have found C# to be more similar to Java than C actually and would be hesitant to call C# a dialect of C.
  10. Josh Kahane thread starter macrumors 6502

    Aug 29, 2006
    Suffolk, UK
    Ok interesting. Im more interested in which would be easier to switch into Objective-C from rather than which will run on a mac or not. The more similarities there are with Objective-C, I ill more likely go with that. Unless there is a decent reason why not to.
  11. rickbsgu macrumors newbie

    Dec 10, 2009

    C++ is 'closer to the metal', so to speak. A C++ implementation will always perform better than a C# or java implementation (although the latter are getting better.) You'll have to concern yourself with memory management, pointers, and the stack - you can gain a deeper understanding of how computers work using C++ (and occasional assembler.)

    But, it's slow going, comparatively. Some newer toolkits help the process, significantly, but separated declaration headers and implementation bodies invite a lot of issues if not kept in sync. If you learn C++, you might also want to learn Qt (http://www.trolltech.com). Qt's 'signal-slot' mechanism is a whole lot like Objective C's messaging system (but the syntax is completely different, of course...)

    C# is a great language. With the recent implementation of garbage collection in Objective C, memory management is less of an issue (than it was before.) In C#, you can leverage the 'delegate' mechanism to function as a messaging system (also completely different syntax.) It also interfaces to C++ more easily than java, for those 'down-dirty-close-to-the-system-high-performance' coding efforts.

    You *can* write cross-platform C# - look at Novell's 'mono' project (http://www.mono-project.com/Main_Page.) They've put a lot of effort into it and it is becoming the preferred implementation language in KDE.

    Best, and good luck,
  12. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Neither one is "more similar" to Objective-C than the other. They both have enough differences that conversion can be a real pain, especially for non-trivial code. For trivial code, either one is sufficiently similar that general algorithms are easy to port, but both are sufficiently different that syntax conversions could be the major obstacle.

    I think your best bet is to get your feet wet learning the rudiments of all 3 (Objective-C, C++, and C#), and see which one you get farther on quickest.

    Another thing you should evaluate is the quality of the debugging environment. No matter which language you learn, you'll spend a lot of time debugging, so it often makes the most sense to optimize for debugging. You can improve a lot of things in development, and play games with translator and parsers, but I've never seen anyone automate the debugging process.
  13. SRossi macrumors regular

    May 27, 2009
    Glasgow, Scotland
    Right to the point, yeah it's good to learn objective-C for programming on the mac, which I love and would never put anyone off, but asking between C++ and C# thats an easy question.

    Choose C# for one main reason, a job. Look at any jobs available in programming these days and most (not all) will involve C# knowledge, unless you are going to program for OpenGL etc. There is no use in learning C++ these days.

    Currently I have just finished learning C# at university, at first I was uninterested in learning it at all but when you see the jobs for it I was silly not to be interested. Luckily though my university is negotiating with Apple to try and get me an internship in June, and hopefully my objective-C knowledge will come in handy.

    But seriously learn C# in your A-Levels and outside studying buy an objective-C book and teach yourself from that.

    If you do not have a PC to program on consider using Mono as rickbsgu says, great app, I have just started using it for ASP.NET.

    Just my 2 pence worth, hope this helps.

  14. CylonGlitch macrumors 68030


    Jul 7, 2009
    If your goal is to write in objective-C then you want to learn C++; it will be a better primer for you. BUT I would only do C++ for console based applications because that will apply toward just about any operating system. If you go to the GUI section of C++ then you'll be learning Windows only coding. C# can teach you some of the C coding you need; but it is very tied to Microsoft.NET so I wouldn't recommend it IF you want to get to objective-C.

    Now, personally I really prefer to write in C# then in C++ and I find it a much more logical and useful language.

    What you really need to learn is ANSI-C which is the precursor to C++; that is very portable. Then learn object oriented programming with C++. Finally move to Objective-C. You can learn object oriented programming with Objective-C; especially if you have the ANSI-C background.
  15. PoetCSW macrumors newbie

    Oct 26, 2009
    Wishes for more cross-platform tools

    On topic… whatever you learn will transfer. I'd learn C and Objective-C, then add C# if you are Mac-centric but want to ensure you're industry-current. If learn C# first, it is different enough that a shift to Objective-C can be slightly frustrating.

    Of course, it doesn't have to be this way. Cross-platform could be done, at least of the non-UI elements. (Coding two UIs is not that big a deal if the interfaces are functionally identical.)

    Embarcadero has Delphi Prism, finally, which uses .Net on Windows and Mono on other platforms. The downside is you do have to code on Windows. But, what really matters is that this shows we could, in theory, have any .Net language on the Mac. Prism uses gtk# for the UI elements, though, and that can be pretty obvious.

    We know Objective-C is on other platforms, but Cocoa isn't (outside Apple). I have looked at the code in iTunes and Safari for Windows and if you use a hex editor you actually can see "NSTableView" and similar signs of goodness. I've been told they use Visual Studio, so I'm not sure what Apple really does.

    I'd love to use C# on the Mac or Objective-C and target Windows.

    Again, whatever you learn will be worthwhile.
  16. chrono1081 macrumors 604


    Jan 26, 2008
    Isla Nublar
    I wont chime in on the "this or that language is better" but I will say no matter which you choose its not going to be the only language you learn.

    Learning the concepts are important because they pretty much stay the same throughout languages, its the syntax that changes.
  17. jtara macrumors 65816

    Mar 23, 2009
    Depends on your purpose. If you intend to pursue a career in programming, learn C++. It's a useful skill to have. C# is closer in principle to Objective-C, but won't do you much (if any) good in the Mac world.

    If your goal is simply to write Objective-C programs for the Mac, you might just want to skip both.

    C++ is WAY more complex than Objective-C. Objective-C should be quick learn, IF you are not tainted by already knowing C++! It takes YEARS to become a competent C++ programmer.

    It would be use to learn C (not C++) because Objective-C is not much more than a thin object-oriented veneer over C. EVERYTHING you learn about C will transfer. Much of what you learn with C++ or C# won't. (OK, not EVERYTHING - no pointers, good riddance!)

    Don't go near STL unless you really have a need.
  18. jsonli macrumors member

    Oct 26, 2008
    Do you already know a high-level language (Java)?

    If so, take C++
    if not, take C#.
  19. jtara macrumors 65816

    Mar 23, 2009
    Oh, and if your purpose in learning C++ or c# is to have a better understanding of the underlying hardware - don't. Learn ASSEMBLY language (machine code) first. FIRST. It will remove a lot of mystery right from the start.

    I was lucky in that my high school had a computer. (Hey, I graduated in 1972!) First, we learned machine code. Punched on cards. No assembler. Digits on punch cards. (Oh, it was a decimal machine - IBM 1620.) THEN we learned Fortran II. In college, it was similar - first we learned Knuth's pseudo-machine-language (forget what it was called). Then PL/I. It's a perfectly sensible sequence that, sadly, is skipped in most computer science education programs today.

    (Oh, there was SOME mystery. In high school, they skipped the whole part about compilers. I thought the disk drive WAS "the compiler". Hey, for machine code we just fed it cards and the lights blinked. For Fortran, we fed it punch cards, the disk drive arm went nuts, and the lights blinked... Fortunately, that was cleared-up in college, when we had to WRITE a compiler - after first writing an assembler, of course.)

    So, I have some experience. Just skip to the Objective-C...
  20. Kaliemon macrumors member

    Apr 30, 2006
    I would say go with c++. Objective-C has a wonderful ability of integrating directly with c++, so you get Objective-C++.

    What I do, is write a C++ program with cross-platform deployment in mind and use objective-c to interact between Cocoa and core services and the c++ parts when developing the mac target.

    Also, c++ will get you started with memory allocation, and even though Objective-C 2 has a garbage collector, it is still a good thing to know and I believe objective-c for the iPhone doesn't have a garbage collector at the moment, so it is necessary.
  21. Sander macrumors 6502

    Apr 24, 2008
    Unless you want an interesting job.

    Sorry, but blanket statements call for blunt replies.

    C# is the new VB. Managers love it, because the promise is that C# makes for far more productive programmers than C++ does, since C# frees you from all the chores of manual memory management etc. So you can get the same end result with cheaper programmers! I'll have a dozen, thanks!

    Disclaimer: where I work, I constantly need to clean up after C# programmers and need to spend a lot of time making components (in C++!) C#-programmer-proof.

    If your jobs consists of making GUIs or "gluing stuff together", then C# is the language of choice (on Windows). If you are writing functional components or libraries, I still think C++ it the tool of choice.

    Why C# is not my favorite programming language.
  22. gnasher729 macrumors P6


    Nov 25, 2005
    C++ can be mixed with Objective-C in the same application freely. And there is Objective-C++. Basically Objective-C is "C with some additions"; any plain old C code is valid Objective-C code. And Objective-C++ is "C++ with the same additions"; any plain old C++ code is valid Objective-C++ code. I have legacy C code that calls functions written in Objective-C which call methods written in Objective-C++ which use C++ classes, and it all works together without problems.
  23. mslide macrumors 6502a

    Sep 17, 2007
    Yeah. What he said.

    Don't sweat over "should I learn this language or that language first?". What's important is that you understand the underlaying concepts in programming. Plus, even if you only ever plan on making high-level windows c#/.net apps, a good programmer should understand what's going on underneath the hood and thus I always think it is a good idea to understand C and assembly.

    Make sure you understand the concepts of building and debugging. I'm shocked as to the number of professional programmers I run into who don't know how to use a debugger properly and instead waste hours upon hours trying to debug things with 'printf' statements.

    I stick to C & C++ (the latter is most certainly still widely used and worth learning, contrary to what someone up above said) because in my world, embedded programming, that's what many people use. If I ever write higher-level user apps, with GUIs, I always strive to make them cross-platform compatible and that is not hard if you use the right tools. I use C++ and the Qt framework. Great combination, IMO. Personally, I don't see much of a need to bother learning Objective-C/Cocoa unless I wanted to work for Apple or make iphone apps.

Share This Page