Learning Objective-C from C

Discussion in 'iOS Programming' started by lynkynpark86, Dec 31, 2011.

  1. lynkynpark86 macrumors 6502

    #1
    I've wanted to learn Objective-C since I learned what it was about 3 years ago. Many, many, many, many, many details removed, I can't do anything more advanced than Python on my Mac. If I learn C or C++ on my Windows machine, how much will it help me (eventually) learn Objective-C? From 1-10, 1 being "It will help me as much as knowing German", and 10 being "They're the same language"...
     
  2. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #2
    I bought the book Learn C on the Mac and read that first, great easy book to learn from. I took my time and created my own examples from the examples in the book so it set it. by the end of that book I wrote a really poor looking, but working console blackjack game.

    C is a good place although many people have different opinions as to how to approach it. I started the C book in September 2010 and wrote the blackjack game over Christmas that year. one year later I am well into Objective C but still learning since learning never stops.
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    If you don't know some C it will be difficult to learn Objective-C. You don't have to be an expert though.

    If you were an expert in C++ it would help you to learn Objective-C, since you would already understand OOP. However, if you don't know either one and your goal is to learn Objective-C I wouldn't spend any time on C++.

    I would recommend looking at the Kochan book. I believe that it starts you off at the beginning and takes you through Objective-C. Maybe someone who has done it this way can comment. I recommend you read the user reviews of it on Amazon.
     
  4. mduser63 macrumors 68040

    mduser63

    Joined:
    Nov 9, 2004
    Location:
    Salt Lake City, UT
    #4
    Why not learn just start with Objective-C on your Mac? Objective-C is a strict superset of C, so anything that's valid C is valid Objective-C. That said, Objective-C is for writing object-oriented programs, while C is for writing procedural programs. What that means is that while Objective-C contains all of C's capabilities and syntax, you don't actually use the strictly C stuff too much.

    C++ is object oriented like Objective-C, but they're fairly different languages. Learning any object oriented language will make it so you understand the basic concepts/theory behind object oriented programming (OOP), but to be honest, if your goal is to learn Objective-C, learning C++ first probably isn't really the way to go.

    I think Stephen Kochan's book is an excellent way to go. It teaches you Objective-C without assuming you've ever programmed before, so there's no need to learn C or any other language first.
     
  5. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #5
    Knowing C will make an Obj C programmer a better Obj C programmer. However knowing C will not automatically make a person into an Obj C programmer. For that one has to learn OOP semantics and object oriented design patterns and methodologies. And spend a couple weeks getting used to new weird punctuation (brackets and such).

    If you know how to do modular and event-driven programming in C, that will give you a big head start in learning Obj C for Cocoa or iOS.
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    Hillegass' new book also assumes no foreknowledge and teaches C in ~80 pages.

    B
     
  7. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #7
    I have to strongly agree with that. Having seen some of the difficulty that C++ programmers tend to have adapting to the Objective-C paradigm, I think it would benefit one more to go in the opposite direction, if necessary. C++ might be a useful, marketable tool in one's bag, Objective-C would provide a good base for learning it.
     
  8. lynkynpark86 thread starter macrumors 6502

    #8
    I don't have any administrative access to my Mac. Is there a way to use objective-C on Mac without xcode or gcc?
     
  9. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #9
    Who's Mac are you using ? Ask them to install XCode for you. There's no way to compile programs on a Mac without installing XCode to get gcc.
     
  10. Carl Sagan macrumors 6502a

    Carl Sagan

    Joined:
    May 31, 2011
    Location:
    The Universe
    #10
    That's heartening to hear, I've just bought the very same book for the same reason to eventually learn Ob C...:)
     
  11. North Bronson macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #11
    What about LLVM?
     
  12. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #12
    No. You will need to get an administrator to install Xcode with the developer tools.
     
  13. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #13
    You actually might be able to install the tools from hpc in your home directory. i.e. ~/usr/local/...

    http://hpc.sourceforge.net/

    B
     
  14. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #14
    Sure. But these tools are pretty much useless to a learner without Apple's libraries and frameworks.
     
  15. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #15
    Definitely more useful for C/C++ (and FORTRAN/Pascal) than Obj-C, I agree.

    FWIW the real Apple compilers are available here: https://github.com/kennethreitz/osx-gcc-installer without Xcode. For those learning to use Foundation Kit from the command line this should be enough. However I believe the installer still requires admin privileges, so is not a solution for the OP.

    B
     
  16. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #16
    The big problem with not having admin access is debugging. I use a user-level account almost all the time, and when I try to launch a debug build with breakpoints, it asks me for admin privilege (username and password) the first time.

    Granted, you can do a fair bit of debugging with NSLog reports in place of breakpoints, but when it gets complicated, nothing substitutes for being able to step through your code.
     
  17. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #17
    There is an OS X command-line incantation which an admin can use to give a non-admin user just debugging privileges. I develop Mac OS apps from a non-admin account to keep me from screwing up my or bricking my Mac accidentally.
     
  18. francis21 macrumors member

    Joined:
    May 2, 2011
    Location:
    Mississauga, ON, Canada
    #18
    If you are just starting with Objective C, but have some backgrounds with most of the things about OOP, then you can probably start with Objective C. However, there is a catch: there are some concepts such as memory management, etc. that have originated with C.

    Right now, in my current situation, with the book that I bought called The iOS 5 Developer's Cookbook by Erica Sadun (which is, by the way, I really good book for iOS programming), it talks about memory management with Core Foundation, and just the overall concept of memory management was just really hard for me to grasp the idea.

    My situation just goes to show that there are some concepts that requires C knowledge (obviously Obj. C is a strict superset of C).

    So my two suggestions are:

    1) If you have a pretty good solid foundation of Object Oriented Programming and some languages that implement OOP (e.g. Java), then you can get-by starting with Objective C right away. Your knowledge of such language will help you somewhat to learn Objective C, but many ideas are new there so watch out for that.

    2) If you don't have enough knowledge about OOP and have not looked up OOP-based languages, then I suggest going with C first then learn some OOP concepts, then start with Obj. C. Many books will guide you through the concepts of OOP, so you'll be able to start programming with Objective C in no time.

    Hope this helps. Cheers. :D
     
  19. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #19
    You mean like doing a setuid on gdb?
     
  20. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #20
    maybe something like:

    sudo dscl localhost -append /Local/Default/Groups/_developer GroupMembership theNonAdminUserName
     

Share This Page