Need advice about learning programming languages.

Discussion in 'Mac Programming' started by Dragonlance1561, Oct 24, 2008.

  1. Dragonlance1561 macrumors member

    Dragonlance1561

    Joined:
    Aug 16, 2007
    #1
    I know that the answer to my question is on the forum somewhere... and I could probably find it but all I really want is an answer without reading pages and pages of text.

    Ok so I want to learn to program macs, but the only programming I know is a very small amount of BASIC, and I was wondering what language I should learn for macs, C, C++, or something else compleatly. I have read that C and Objective-C are almost the same and that objective-C is what you use for macs so I thought "Ok I'll learn C" but then I found that there is also Objective-C++ so now I'm really not sure which is better. Basically want to know is which "basic" language should I learn so that learning the others will be the simplest.

    Hope that made some sort of sense....
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    A large part of programming is reading pages and pages of text, and pages and pages of code, to find an answer. If you don't want to do that, you might be in for an unpleasant surprise down the road.

    That is unfortunate, but I believe you can be rehabilitated.

    Learn C first. C is the foundation for C++ (even though there are some profound differences), and Objective-C is a proper superset of C. Objective-C++ allows you to mix Objective-C and C++, and I would consider it to be most useful for leveraging existing C++ code/libraries. It's not something you need to worry about right away. If you don't know C++ already, you probably won't need to deal with it at all. Once you know C, objective-C will be very easy to pick up syntactically, but you will have to wrap your head around objects and the Objective-C object model. If you find, sometime down the road, that you want to learn C++ a foundation in C will be fine there, too. Some of the concepts will be more difficult than Objective-C, but your knowledge of C will not hinder you.

    Good luck, get coding (for your next question, do it using gcc at the command line, and a text editor like Smultron. Now is not the time for XCode)!

    -Lee
     
  3. ChrisA macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #3
    Start with plain old ANSI C. The others, C++ and Objective C are based on C.

    But be warned. Learning the language is only 2% of what you need to know. The major part of it is the environment. Unix is hundreds of system calls and the Mac APIs are even larger. So not only do you need to know the "C Family" but you need to how to interact with the insides of a computer. The computer is far more complex than is C. It will take a few years of reading and study to come up to speed.
     
  4. jepjepjep macrumors member

    Joined:
    Aug 16, 2004
    #4
  5. Dragonlance1561 thread starter macrumors member

    Dragonlance1561

    Joined:
    Aug 16, 2007
    #5
    Oh don't worry I know that.... I just finished reading pages and pages about Binary,Hex,and how to convert them between each other and to decimal

    Thanks for the other advice though. one More question:
    I found Smultron but I'm not sure what u meant by "do it using gcc at the command line" lol I'm a total noob at this stuff... did u mean use this program as a compiler? and if so then whats so bad about Xcode at this stage?
     
  6. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #6
    There are two different opinions: One opinion is that you should let Xcode do the hard work for you. If you start programming, start Xcode, choose "New Project", then choose "Command-Line Utility", then pick whether you want C, C++ or Objective-C, and let Xcode figure out how it all works. Just concentrate on the programming.

    The other opinion is that you should learn how to use the compiler and linker and learn how to do it by hand.

    I tend to prefer using Xcode.
     
  7. Dragonlance1561 thread starter macrumors member

    Dragonlance1561

    Joined:
    Aug 16, 2007
    #7
    Well it's always a good idea to learn anything by hand before you make something (or in this case someone's program) do all the hard work for you... that way you understand just what the thing or program is doing for you.

    anyways to finish answering my own question.... gcc comes freely in the xcode suite of development tools. acording to this website

    and also according to apple's website Xcode comes on the Leopard DVD so you don't have to download it like that website says. (It just isn't installed already when you get the computer.)

    Of course everyone here already knows all this I'm sure, but watever I'll write it anyways for anyone like me who didn't/doesn't know this.

    I also found this website for some basic tutorials: http://http://www.cprogramming.com/tutorial.html
     
  8. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #8
    Lee --

    You've proven time and again you're damn smarter than I am. And I've seen you give this same advice before -- I've followed it -- but I started Kochan's book the other day and he makes the case AGAINST learning C before Objective-C. C is procedural, he says, which can lead to bad habits when a novice turns to an object-oriented language (I'm paraphrasing and condensing; see the introduction to his book).

    Just wanted to throw this out there.

    mt
     
  9. lucidmedia macrumors 6502a

    Joined:
    Oct 13, 2008
    Location:
    Wellington, New Zealand
    #9
    I am also of this school of thought... why not start with a good conceptual understanding of OOP?
     
  10. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #10
    I think that would only be an issue if you are a lazy programmer. It is fairly obvious that if you are moving to an OOP language then you need to learn a new way of thinking about things.
     
  11. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #11
    This is simply a matter of perspective, and one's ultimate goal would greatly sway which direction is best. I consider versatility one of the cornerstones of a good programmer. I think starting with a strong foundation in C (and command line tools) allows greater versatility. My concern with someone starting out, is they'll learn Objective-C using XCode, then find themselves in a situation where they have a shell account on a linux or UNIX system, and they then feel that they have to start from scratch as a great deal of their programming knowledge does not transfer. Yes, they may be able to use Objective-C, but they won't have all of the libraries they are used to, the IDE they're used to, they won't know the command line arguments to gcc, or how to invoke gdb from the command line, etc.

    If one's goal is to only program for OS X on OS X, and they are confident that they will always be able to do things the Objective-C/Cocoa way (instead of say, using function pointers, or system calls like memcpy, the "C" way) then I'm sure a cursory understanding of C is sufficient to be an effective Objective-C programmer. That's simply not my approach to programming, and I think if one is serious about being a programmer, a working knowledge of C is crucial.

    In terms of the "Object-Oriented mindset", i did mention:
    I think moving from procedural programming to object-oriented programming is a bit easier than the other way around. I see object-orientation as an extension of procedural programming, not a totally different paradigm like functional programming. This may be considered faux pas by hardcore academics, but truly in most cases an Object is a bundle of methods and data. You can easily bundle data with structs in C, and you can name methods in a manner that they are bundled in C. When you get to more interesting things like polymorphism, inheritance, etc. OOP really opens up some options that a strictly procedural language is not well suited to.

    Obviously Kochan is doing better than I am in terms of educating programmers, being that he is a published author. However, I wouldn't say that his advice is in direct opposition to my own. I think that at the surface I agree that one doesn't need to know C to learn Objective-C. My point is that for some, the ultimate goal isn't to just learn Objective-C, but to become a well-rounded programmer. To me this means having a large toolkit from which to choose from when approaching a problem.

    I do understand the idea of learning bad habits from a strictly procedural language, but I don't feel that that's a strong enough argument against having a background in a procedural language before moving to OOP. To me, a higher-level language that supports OOP frees you of some of the more tedious, error-prone tasks such as manual memory management, buffer bounds checking, etc. These are the areas that beginners seem to have the most trouble with, so I think that once a better way is presented in an OOP language most will welcome it rather than clinging to concepts that they weren't 100% comfortable with. By the same token, however, there are some weaknesses of dynamic data structures provided by some languages and libraries. One of these is storage of an arbitrary number of primitives. Maybe you "shouldn't need" to store N ints, but I don't think it would be a "bad habit" if a particular problem, algorithm, etc. needed this. In Objective-C, you have options. You can fall back to the C way, and malloc yourself N*sizeof(int) bytes and assign the pointer to an int*. You can stuff each int into an NSNumber, then you can use NS(Mutable)Array. I'm sure there are other creative ways around this problem, but if this is a performance-critical area of code, having the C way of dealing with this in your back pocket is not a bad thing, in my opinion.

    This certainly ended up longer than I had expected, but I think your point deserved a considerate response. I am not trying to defend myself against Kochan's point, as he's obviously more seasoned and has more experience educating new programmers. I'm just trying to provide a counter-point, and some rationale behind my advice.

    -Lee
     

Share This Page