C Before Objective-C?

Discussion in 'Mac Programming' started by Vaxuun, Feb 13, 2010.

?

What do you recommend to learn as first languages?

  1. Learn C

    53.5%
  2. Learn C# or C++

    9.3%
  3. Learn Objective-C

    23.3%
  4. Learn Cocoa

    2.3%
  5. Something else (what then?)

    11.6%
  1. Vaxuun macrumors member

    Joined:
    Feb 6, 2010
    Location:
    Denmark
    #1
    Hi MR.

    I can't figure out to learn C before Objective-C?.. My primary goal is programming for Mac and the iPhone because I love the interface prettiness and the operating system. :)

    I am reading the book "Programming in Objective-C 2.0" by Stephen Kochan (60 pages read) and so far it is great.
    In his book he doesn't recommend to learn C before Objective-C because it will give one a bad habit when programming Objective-C.

    But the MR guide recommend to learn C first, then Objective-C.

    What is your opinion? Why SHOULD I learn C first? Why SHOULDN'T I learn C first? Any other programming language you can recommend before Objective-C? If yes, why? If not, why?

    Thanks in advance! :D

    P.S. I know there is ALOT of threads about this, but I havn't found the answer for my question yet.
    P.P.S. English is not my mother language so sorry for any typo mistakes.
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    If you have read the threads, you know there isn't an absolute answer to this. This is really dependent on your longterm goals. If you only ever intend to program OS X or iPhone OS, then C isn't a neccesity. I believe if you want to be a programmer, and not tied to a specific platform, I'd say learn C.

    -Lee
     
  3. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #3
    Objective-C is a superset of C. Any legal C code is also legal Objective-C code. So if you have learned Objective-C completely, then you also know C.

    Many books and many people will assume that you know C when they discuss Objective-C. If you don't know what a pointer is in C, then you will be programming in Objective-C like a blindfolded man tapping around with his hands in the dark, and occasionally hitting a mouse trap, and that hurts.

    We have people here posting code like

    Code:
    NSMutableString* myString = [[NSMutableString alloc] init];
    myString = @"Hello";
    
    and then they can't figure out why their program crashes when they modify myString. If you know C (and just start learning Objective-C) it is blatantly obvious. If you don't know C and don't know what that "*" is for, you have a very hard time.

    BTW. C++ instead of C will do just fine.
     
  4. Vaxuun thread starter macrumors member

    Joined:
    Feb 6, 2010
    Location:
    Denmark
    #4
    If I some day in the feature wanted to do some Windows programming (C++ or C# I believe), will it be possible to learn C fairly quick if I know Objective-C?
     
  5. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #5
    So objective-C is just C, and some extra stuff added on top of it. If you're really passionate about specifically Apple development, and are eager to get into writing GUI apps on the Mac/iPhone/iPad as quickly as possible, then there's nothing wrong with starting with Kochan and working towards that goal. It's pretty much the path I've been taking.

    But you're going to want to learn C eventually so you can better understand how Objective-C works and also use some of the Apple frameworks based on C. Kochan's book actually has a section dedicated to this, but you'll eventually want to explore it further--it's not immediately critical however.

    There's nothing that you will learn with C that will permanently damage you as far as learning Objective-C, but procedural programming has a different approach than Object Oriented Programing, so if you start off learning procedural programming there is a bit of re-training you have to do to get into the OOP mindset. Again, this is nothing permanent, it's not like you'll be mentally ruined or anything, it's just a different way of doing things and may take a bit of effort to re-train the way you go about solving a problem with programming.
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    It depends on how well you know Objective-C. If you know it well, then you will already know C. If you don't know Objective-C well, then you may encounter some difficulties seeing how it relates to C.

    C++ and C#, however, are not C. They are completely different languages from C, which were originally based on C (at least for C++), but are now sufficiently divergent that you can't trust that knowing C will tell you anything too useful beyond the basics of primitive types, pointers, and structural keywords like if, for, while, do.

    http://en.wikipedia.org/wiki/C++

    http://en.wikipedia.org/wiki/C_Sharp_(programming_language)
     
  7. mdeh macrumors 6502

    Joined:
    Jan 3, 2009
    #7
    Well, I hesitate to jump in because you have been answered by 2 of the most experienced people on this forum, who always provide great answers.
    My 2c worth is this. I was in the same position as you, and after a while, realized that I needed to go back and learn C. I used K&R, which is OK, but difficult at times. Then I found Steve Kochan's books....and would highly recommend them (He has one solely for C, and one for OBj-C). Those, in very short order, will at least make you pretty competent in both. (In fact , there is a section dedicated to C in his second book, and you might want to start there, as he takes on the approach of teaching both in his Obj-C book). There are a lot of tutorials out there, but from my perspective, a well thought out book is better as it is structured better.
    Anyway, that's what I did.
     
  8. Vaxuun thread starter macrumors member

    Joined:
    Feb 6, 2010
    Location:
    Denmark
    #8
    So learning C won't really benefit if I someday in the future want to learn C++ or C#/C Sharp?

    Thanks for the replies :)
     
  9. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    It will be beneficial, it is just not strictly necessary.
     
  10. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #10
    Learning C will make you more aware of how the machine actually works, and how the code you write operates. You have to be explicitly aware of resource management, etc. I think that this makes you aware of the choices you make in any language, and more thankful for features like garbage collection when they're available.

    I think learning C will serve you well no matter what other languages you want to learn. As I say, if you want to be a programmer and not an "x programmer" where x is some specific language or platform, I'd start with C. I've personally never thought "I wish I didn't know how to do this in C". Even if you don't start there, I'd revisit C later.

    -Lee
     
  11. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #11
    If you "know C", that's like 10% of what it takes to "know" C++. That 10% is fundamental, so if you don't know it, then none of the other 90% will matter. You can't build a 3-story house on a shaky foundation. But if you do know that 10%, well, that's still only 10% of what it takes to "know C++".

    If you "know C", that's like 5% (or less) of what it takes to "know" C#. Again, though, that part is fundamental. Most of C# isn't C-like at all, in the sense of pointers and memory access.

    And if you "know C", that's maybe 50% of what it takes to know Objective-C.

    However, if you don't know any programming language, then learning just one programming language, whatever it is, is a net benefit. And if you know C, then you will know what pointers are and what direct memory access means, which are the biggest stumbling blocks for all the C-like languages. Many languages don't have pointers and direct memory access, so these things never occur, and are not even part of the vocabulary.

    Note: all percentages are approximate, based on my own proprietary language-comparison algorithm. The one in my head. Stored right next to the "Ooh, that's pretty" algorithm.


    Your original question can't be answered definitively except by you. You know best how you learn things. We know hardly anything about you or how you learn things best.

    What you should probably do is stop trying to find the one perfect solution based on other people's opinions, and simply try one thing for two weeks in order to inform your own opinion. If you're not making progress, after honestly trying it, then consider something else. If it's working, you'll know. And if it's not working, you'll know that too.
     
  12. Vaxuun thread starter macrumors member

    Joined:
    Feb 6, 2010
    Location:
    Denmark
    #12
    Thanks for the great replies :)

    After what you said it seems defiantly worthful to learn C.

    For what works best for me (when learning) must be books. Because they a structured right and you can't be sure about the internet tutorials. If there is something in a chapter I can't understand, tutorials are nice.

    If you should choose a book for learning C, what can you recommend? I am not asking for the single best book, I am asking for a book that thought you something.

    The "bible" of C books must be Programming Language C (1988) by K&R, but I found it a little dry and maybe outdated (they start with main() instead of int main()) but I can't be sure :p

    I have read 60 pages of in Programming in Objective-C 2.0 (2009) by Stephen. I think he is great, but haven't looked in his Programming in C (2004) so can't tell you.

    Thanks again guys :)

    A little poll:

    how many of you did learn C as the first language? How many of you did learn Objective-C as the first language?
    If none of the above, what did you learn as your first programming language?
     
  13. Muscleflex macrumors 6502

    Joined:
    Jan 26, 2010
    #13

    i learnt LOGO when i was maybe 11
     
  14. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #14
    C was my first language. After that I found Java and C# pretty trivial to pick up, but for some reason Objective-C took me longer to ¨get¨.
     
  15. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #15
  16. Vaxuun thread starter macrumors member

    Joined:
    Feb 6, 2010
    Location:
    Denmark
    #16
    I will look into that book, thanks.

    EDIT: Learn C on the Mac, does that mean learning C specific for the Mac or does it mean learning C language on the Mac OS X with Xcode? :) Because I am not 100% sure, but 85% C work as great on Mac as Windows with the same source code

    I was told to learn Java to look for a great online place or a book, but couldn't find anything really good.. What place/book (which I prefer) is great for learning Java? :)
     
  17. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #17
    The Java Programming Language, Fourth Edition and the Java Pocket Reference is what I used (and still do, frequently).
     
  18. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #18
    It's learning C on the Mac, learning C in Mac OSX and Xcode. There really isn't really anything mac specific to do in C unless you start linking against CoreFoundation or something.
     
  19. whooleytoo macrumors 603

    whooleytoo

    Joined:
    Aug 2, 2002
    Location:
    Cork, Ireland.
    #19
    I'm a bit late to the discussion, but I'd recommend learning C first too. If you learn Obj-C, you're going to be learning C anyway; but learning C on its own first is more of a gradual learning curve.

    Plus, by learning C, then Obj-C you'll learn what the features/differences of each are; whereas if you go straight to Obj-C, you might not realise where C ends and Obj-C begins.
     
  20. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #20
    Everybody here has already given great reasons why learning the core concepts of C would be very valuable before moving on to Obj C.

    My only other suggestion for easing the learning curve would be to learn a scripting language before learning C. Javascript and Python seem popular, and knowing Javascript will give you a leg up on Web apps and creating UIWebView helper views. Knowing multiple languages is always an advantage (you'll know what's weak/missing/constraining with whatever language you're currently working with.)

    C was around my fourth programming language. I've implemented a few small programming languages, and used so many languages, some as part of my university coursework, some professionally, before getting to Obj C, that I've lost count (who here has even heard of SNOBOL, MUMPS, Tcl, 1802 assembly, etc.)
     
  21. Vaxuun thread starter macrumors member

    Joined:
    Feb 6, 2010
    Location:
    Denmark
    #21
    What books can you recommend for learning C (and maybe JavaScript?)?

    So far, I heard about:

    What can you recommend?
    What other books can you recommend?

    Thanks again and thanks for great replies so far! :D This has defiantly been helpful, I just need the very last step (the book)
     
  22. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #22
    Personally I think all programmers should know C. It's the basic foundation of understanding pretty much everything. I'd go further and say that all programmers should know enough assembly that they understand somewhat what their C is doing underneath. How does a function call actually work (with reference to the stack) etc...
     
  23. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #23
    The C Programming Language is THE C book. But you might find it hard as a complete beginner. I started with "Pointers on C" and then moved on to that.
     
  24. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #24
    A Book On C was our course text at Edinburgh Uni when I was there. I thought it was very good and actually teaches you the language.
     
  25. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #25
    I disagree, scripting languages are usually loosely typed and probably will not prepare the OP for Objective-C and Cocoa touch.
    And if people say learning C will give you "bad habits" just think about what kind of habits you pickup from PHP or Python.
     

Share This Page