If I want to start mac programming, do I really need to know C first?

Discussion in 'Mac Programming' started by I'm a Mac, May 24, 2008.

  1. I'm a Mac macrumors 6502

    Joined:
    Nov 5, 2007
    #1
    Because I was interested in mac programming, I decided to buy both Kochan's programming in objective-c and Hillegasse's Cocoa Programming for Mac OS X. However, with no programming background (and not a math major), I found it a little difficult to get started at programming.

    I never thought programming was easy, and maybe it's not for me, but I found it difficult to absorb everything and get started on programming. I bought Kochan's book because it didn't require C knowledge, and it stated that learning C to learn obj-c is wrong, but I found the concepts a little difficult, and I feel like it was hard to start "thinking" like a programmer. Is this because I need to take more math courses, because it's hard to start with objective-c, or am I impatient?

    I was debating buying C programming by King, but at $80, that's a large investment for one book. (Not that I wouldn't buy it, but it better be a great teaching tool for that amount) The K-R book looked very intimidating and boring, but it seems to be "the standard". I was also thinking of buying a C book for "dummies" but I wasn't sure which one to get.
     
  2. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #2
    Someone saying you shouldn't learn C before ObjC is crazy or a language-bigot. ObjC is an extension to C, and if you don't understand basic programming principles then you will be lost when you dive in as you discovered.

    If you only buy a few books and don't take up programming you are only out the cost of the books. Don't worry about not "getting" programming instantly, its not something you just start doing one day and make complex working programs the next.

    If you put the book down for a week and never pick it up again, find something else to do. If you have to get back to the exercises or read the whole book, maybe you have the "bug."

    No one tell you that you are a programmer, you either know it or you know that you aren't. I always knew and now I am making ridiculous amounts of money (compared to past computer/tech jobs) by making Mac software all day.
     
  3. I'm a Mac thread starter macrumors 6502

    Joined:
    Nov 5, 2007
    #3
    So what book to you recommend for learning c... also, how do you compile programs from terminal? I know the command, but how do you save your program and when do you run the compiling command from vi or emacs?
     
  4. tacoman667 macrumors regular

    Joined:
    Mar 27, 2008
    #4
    Objective-C is definitely a extension of the C language but it has also evolved into being a derivative of it far more then actually "being" it. You do not need C knowledge to learn and understand C++ but C++ is a derivative of C and actually started out being an extension to C by adding Object Oriented Architecture and methodologies.

    I feel that the author that said you do not need to learn C before Obj-C is right to a certain degree. You need to learn programming fundamentals and methodologies as well as theories and concepts but those pertain to any programming language and not just 1 in particular. If you only want to program applications but not to the degree of an artist, then learn a language and what you can and cannot do. If you want to be like me who has a passion and fire for all aspects of programming, then learn the computer science part of programming. I want to create software, not just reduce redundancy through scripts and short applets.

    (This is NOT a post to degrade those who take the latter route to ANY means! Please do not take it this way at all!)
     
  5. I'm a Mac thread starter macrumors 6502

    Joined:
    Nov 5, 2007
    #5
    So do you think learning C will help me understand programming concepts better? I think the Kochan book is great, I just think that the concepts are a little advanced for someone who was no background in programming. What book do you reccomend for C?
     
  6. tacoman667 macrumors regular

    Joined:
    Mar 27, 2008
    #6
    I couldn't tell you, friend. I started with C++ back in college and Turbo Pascal with Basic in high school. I skipped over C and went straight to C++. I like the series of book by Dietel. I own a few and coincidentally 1 of them is C++ and I enjoyed it a lot.
     
  7. I'm a Mac thread starter macrumors 6502

    Joined:
    Nov 5, 2007
    #7
    The reason I wanted to start with objective-c was because one, I'm a little impatient and two, I'd rather not learn one language and then get confused when the new one is totally different. I could probably learn the basic concepts from online tutorials, but I don't want to be missing out on important info by not learning c, if it's necessary to be "proficient" with cocoa. Also, can someone please show me how to compile application from terminal?
     
  8. rev316 macrumors regular

    Joined:
    Nov 7, 2004
    #8
    You don't need to know C to get into Mac programming. Sure, It'll help. Find a project, and just start connecting pieces.
     
  9. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #9
    objective c is a proper superset of C. If you don't understand assigment and pointers, it will be hard to understand what is going on when you need to pass an object about or what types of arguements are passed in a message.

    I'm on my phone, but I and others have posted gcc commands for compilation a number of times. Your source code will be a text file that is saved as a .c file or .h for headers. An object file resulting from compilation will have a .o extension and the executable binary tends to have no extension.

    -Lee
     
  10. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #10
    I came from a BASIC background when I decided to start on learning cocoa, so the only thing I had over your current situation is I knew programming in general. Here's what I advise doing. Go to www.cocoalab.com and go through their BecomeAnXcoder tutorial. It assumes you have no C knowledge, and it's a great tutorial. Free, too. Now about programming terms and that stuff, if I remember correctly the book covers a lot of them but if you don't know one, use google searches. Just search for "C" or "objective C" and then the word/phrase. Once you're done with that book you should be able to go on to real pure cocoa and objective C books. And just a note: When they say get familiarized with the help document, they mean it. It is so nice to be able to look up all this stuff, and it gives you EVERY bit of detail you need to use that object and its' methods.
     
  11. Mebsat macrumors regular

    Joined:
    May 19, 2003
    Location:
    Florida
    #11
  12. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #12
    In a word. Yes. It is absolutely essential. I'd also recommend picking up a small C pocket reference which covers C99 as well just so you know about the additions that K&R does not cover.

    This is the one I have.
     
  13. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #13
    If you mean "all that" in the Ricki Lake sense, yes, it is all that (and a bag of chips). It might be more difficult to learn C from that book, as it is essentially the comprehensive language reference, it does not hold your hand. It's what you have on your desk for when you're not sure you really know it 5 years later. I think the internet is a fount of information on learning C from Hello, World to bitwise operators to function pointers, it's all out there.

    I learned C in a pretty roundabout way, so I don't have any great advice on where to start other than the terminal, a text editor, and gcc.

    -Lee
     
  14. Mebsat macrumors regular

    Joined:
    May 19, 2003
    Location:
    Florida
    #14
    Thankfully, I can't place the Ricki Lake reference.

    But, like the thread starter, I have found a lot of materials online and books such as Hillegaas' a little hard to follow at times. This is simply because they rightly presume a familiarity with programming fundamentals and/or C. The question for those wishing to "start from the beginning," is:

    "I'm willing to do the work, but where do I start?"

    And this yields different answers from different people.

    Can you recommend any specific sites? I am sure many reading this thread are eager to build their bookmarks.

    Thanks.
     
  15. -::ubermann::- macrumors regular

    Joined:
    Sep 9, 2006
    #15
    i read that learning OO programming often was more difficult for someone who already knew procedural, than for someone without programming knowledge
     
  16. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #16
    You may be able to hobble together a textbook program knowing only Obj-C, but at some time, you will have to learn the proper C subset and its idioms. With OBj-C, you'll learn the basic C data types and control flow mechanisms, but the subtler points: pointers, arrays, pointers vs. arrays, the stack vs the heap, C-style strings and string handling, C-style declarations, the C standard library, the C object model, dynamic memory management, the POSIX API, etc., will haunt you if you don't don't devote the time and concentration to their study.
    When you decide to do that is up for debate. If you're impatient, pick up the more advanced portions of C you need to know on the way, but do pick them up.

    You don't need to be a math major either. I was a math major, even studied towards my PhD in the subject, but aside from anything explictly algorithmic or theoretical, none of it helped learning how to write software. If not an art-form, programming is at the very least a craft that requires years of practice to attain complete fluency.

    As far as object-oriented explanations being difficult to understand, the literature on OO programming suffers greatly from what is sometimes called 'proof by vigorous hand waving'. Much of it is poorly written with murky distinctions and nebulous logic, and the 'a ha!' moment only comes after seeing several concrete examples (or even better, writing your own). Perhaps remembering the lesson of Algol 68, most texts assume the normal reader would find formal definitions, such as they are, indigestible or besides the point.
     
  17. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #17
    I mentioned cocoalab before... at the end of their book they recommend a list of websites... some are a little outdated, some a lot outdated some are 50/50 but they all have interesting stuff. So just go to the last pages of the pdf, either the last or the second to last page and they list some websites. Cocoa literature is the most promising, it has a LOT of links including links for C I believe. Some of their stuff is outdated but it shouldn't be too bad.
     
  18. hazmatzak macrumors regular

    Joined:
    Apr 29, 2008
    #18
    Cocoa is probably not quite yet at the point where you can ignore all the crufty C stuff. Maybe you don't ever have to worry about how scanf() works, for example. For a novice and green-field development, maybe you can start with Obj-C 2.0 and let it do garbage collection, so you don't manually deal with memory management (as much).

    For some. There are at least three mental models for how programs work:
    • Procedural: the CPU runs your program, following its structure -- control blocks, subroutines. At any given time, the CPU is definitely "somewhere".
    • Object-oriented/Event-driven (conflated because people usually first encounter these at the same time): Objects "send messages" to each other; one has the other "do stuff" for them. At any given time, the CPU may be "doing nothing" -- actually it's in the event loop waiting for a keypress, click, timer, callback, etc.
    • Multi-threaded: Threads are the actors, acting upon objects in memory. Depending on the memory model, two threads might see the same object differently. Multiple threads can block, race, and other fun stuff.
     
  19. Earendil macrumors 68000

    Earendil

    Joined:
    Oct 27, 2003
    Location:
    Washington
    #19
    I'm a Mac,
    I'm going to take a contrary position to some here, and see if I can explain myself.

    You do not need to know C before learning another programming language.
    Most University professors start students with either Java or C++ (God help the ones starting in basic), I personally started with C++.

    What you do need to know, understand, learn, and grasp *somehow* is the basic ideas, methods, and systems for all programming languages. They are not complicated per say, but it's like walking into a completely different culture and picking up a detailed manual on a sub system of the culture, it would be far more helpful to get the 30 minute overview on how to approach and interact with that strange culture, than the nitty gritty details.

    A LOT of programming books out there are written for people who already understand at least one programming language (usually C or C++), and thus they leave out a lot of the general information, and head straight for the "here is how it is different". You could learn C just in order to understand those books, but I don't think that is useful, because those books are written for people who REALLY know C or C++, and thus assume a lot of knowledge, so you'd still probably get lost.

    Certainly I was given the general ideas and concept from my professor and lectures, but they were nothing I couldn't convey to someone in a few 15 minute lessons over coffee. There are plenty of good books out there (I'm sure) that start you with a language as if it is your first language, and THAT is the kind of book you want to get.

    That said, take programming slowly. It's more complicated and twisted than the English language (And I still don't even grasp that). It can be taken in small chunks, and you will start to understand piece by piece. But even as a college senior with 3 internships under my belt and the ability to program in 3 languages, I can still come across code in those three languages and respond with a "wtf does that do?!" :)

    Oh yeah, and a disclaimer, I don't actually know Object-C or Coco, those aren't one of the three.but I suspect my principles hold true none the less.
     
  20. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #20
    I resent you saying "God help the ones starting in basic" because I did and I'm doing fine. I know it's true that I learned a way different language and indeed a different programming style because I learned basic, but at least I'm familiar with programming. I know plenty of generic programming terms, I know which languages are better than others at x tasks, it really isn't that hard switching. I'm sure it's easier than for someone who has never programmed a line of code in their life.
     
  21. Aranince macrumors 65816

    Joined:
    Apr 18, 2007
    Location:
    California
    #21
    I suggest learning something like Python, which is simple and built into OS X. Its good for teaching the basics of programming and how to think in programming.

    All programming languages are similar at a level:

    All have variables
    All have Functions/Methods
    All have conditional statements
    All have modifiers(addition, subtraction, etc)

    If you can learn how to think using those ideas, you can learn almost any language, and the rest just comes naturally as your write programs in a specific language and need to learn how to accomplish something the best way.
     
  22. Phil A. Moderator

    Phil A.

    Staff Member

    Joined:
    Apr 2, 2006
    Location:
    Shropshire, UK
    #22
    Becoming a programmer involves much more than just learning a language - it's far more important to learn and understand the fundamental concepts behind programming as mentioned by an earlier post in this thread. Having said that, I personally think C is the most useful language you can learn as it will give you a very, very good understanding of how programming languages work. I started on Z80 assembly language over 25 years ago writing games for the Sinclair ZX81, and from there onto C. Once I was happy and comfortable with C, I learned a lot of other languages (C++, Pascal (Delphi), Visual Basic (Ugh!), Obj-C, C#, Java, PHP, Perl, Python, etc, etc) and because of my solid C foundation, I found (and still find) it very easy to pick up and use other languages.
    You need patience and dedication to become a good programmer (as with many other things in life!), and things will seem tough at first, but once it drops into place you'll be glad you put the work in.

    Good Luck :)
     
  23. Earendil macrumors 68000

    Earendil

    Joined:
    Oct 27, 2003
    Location:
    Washington
    #23

    Sir, I meant no offense by it, and was making a candid statement that I feel I should now explain.
    I was speaking not about all people who learn basic first, but people who learn basic as a first language at the University level. At that level you have serious people who are looking at software as a carrier, and I feel that, with PhD professors around, a serious full time student should be able to start with something like C++ or another fully OO language.

    Also, when moving to classes like X86 assembler language that a knowledge of C/C++ is benaficial to deeper understanding at that level than is basic.

    That said, there ARE universities that teach basic first, and I'm sure those universities are run by people smarter than myself, with professors teaching that are smarter than myself. So, obviously I am just holding an opinion.

    When I was 13 I dabbled in both Basic and C, cheers to all :D
     
  24. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #24
    No one is going to intend to hurt your feelings, but BASIC has a very, very bad rap amongst programmers. It's great that you got exposure at an early age to any programming. However, if a university or even high school curriculum in programming was based on BASIC, I do think that would be a problem.

    There are many reasons out there that people put down BASIC, and "modern basic" probably has many fewer things to hate than previous BASICs, but I am not going to list any myself (please note this is not meant as a personal attack, but rather to give you background on why you will hear people speak ill of BASIC). Instead, I am going to let Dijkstra explain, instead:
    http://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html

    This article mentions BASIC specifically, and the other main source is "Goto Statement Considered Harmful", though I can't find a copy online that doesn't require an ACM membership.

    You can program poorly in any language, but some of the earlier BASIC designs nearly forced the use of labels and gotos.

    Basically what I'm trying to say is you got started with BASIC, and that's fine, but it can breed bad habits amongst beginners so most people will try to discourage its use now in favor of other languages. As an aside, C has a a goto as well:
    http://www.lysator.liu.se/c/bwk-tutor.html#goto
    but you hardly every need it (I have never written one, and have only seen one used and based on who wrote it, I am not surprised by this).

    Anyway, it's all in good spirit, and no one thinks you are less of a person for learning BASIC a long time ago. You're recovering now, so no worries =).

    -Lee
     
  25. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #25
    If you start with C++, you start with C. If the first lesson in a class is how to use virtual functions or inheritance, no one is going to have a clue. You'll learn the C syntax, and how to call methods, passing arguments (maybe pointers first, maybe by reference first which is C++ only, but not that big of a deal), etc. Then you'll learn the C++ object model.

    I think it should go the same way with Objective-C... but I'm afraid a lot of the references start with the Objective-C object model, message passing, and Core Foundation classes and NS* classes. If they start teaching C first, then move to things specific to Objective-C that's fine, but IMO that's still learning C first.

    -Lee
     

Share This Page