Thread: Direction for Learning C?

  1. #1
    Registered User
    Join Date
    Jul 2009
    Location
    Oxford, AL
    Posts
    3

    Direction for Learning C?

    I need some direction, and I am very eager to listen to anyone willing to help.

    I have been a web developer, trouble shooter, random do this guy, etc... for almost 10 years for the same company.

    They now request that I learn How to write iPhone apps. Which after looking into it, requires cocoa, which requires a knowledge of objective based c, which requires a knowledge of c, etc.... You get the point.

    I can read html, basic perl and js, but that's about it when it comes to languages.

    I started with the book " The C Programming Language " by Brian Kernichan and Dennis Ritchie. I got to the 18th page of the intro and was stumped. So then I started using the tutorials on this site and got stumped with the second section of the Learning C guide where it discusses boolean operators. After two days I think I finally have that part figured out.

    Is there anything else that I need to start with besides C?

    I was reading Chapter 1: Introduction " "This aspect of C is very widely criticized; it is also used (justifiably) to argue that C is not a good teaching language."

    So I am started to wonder if I need to step back even further than C?

    I would learn to write for my own personal reasons, but not it is required of my job.

    Can anyone help point me in the right direction?

    Thanks,

    Sam

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    A good book is the best way to start with a programming language. And the reason they say it's not a good teaching language is because it's so complicated and offers so little in terms of existing code. C is a very difficult language and where concerns about a powerful language that's blazingly fast and powerful, C++ has taken its place, so that's kind of why C is criticized.
    You don't need to go back further than C. You need to learn C, or perhaps Cococa itself, rather than some other language.
    Sort of, you shouldn't learn C first if you wanted to learn C++. You'd go directly for C++. I believe the same principle applies here.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by saminoxford View Post
    I can read html, basic perl and js, but that's about it when it comes to languages.

    So I am started to wonder if I need to step back even further than C?
    No, you are probably as ready as you ever will be. Plus there is not anything to "step back" into.

    The idea that "since it doesn't do everything for you, there's a lot you have to do yourself" makes C difficult is IMO primarily to do with memory management, which is a non issue in perl and js, where the hard part is learning all the syntax. C syntax is actually simpler and more straightforward once you understand how it manages memory -- or rather how you are supposed to use it to manage memory.

    The downside of that simplicity is that it takes more work to do complex things. C uses the byte (or datatypes, such as char, which is a byte) as a basic unit. In perl and js, bytes and types are less relevant. In perl and js an array is an array -- it is not an array of a specific sort.

    So I would say focus on how everything in C is really about manipulating units of bytes in memory. Especially try to get a good grasp on pointers. And be patient.

    It's worth it tho. My perl skills probably doubled thru learning C, partially because they are very strongly contrasting, and because C is so "close to the board".

    C is a very difficult language and where concerns about a powerful language that's blazingly fast and powerful, C++ has taken its place, so that's kind of why C is criticized.
    As usual, Elysia is talking about the context of her own life and not the real world (90% of linux and unix systems, which form 80% of the internet's functionality and 95% of "supercomputing", are still pure C). The real criticism is that C is lower level than any other "high level" language* and requires more work -- part of the work is avoiding the "dangers" implicitly referred to in the article you site. It does not have as much syntax because of that. The only complex part about the basic syntax involves pointers.

    *AFAIK the only things not considered "high level" are assembly languages, which require *a lot* more work. Think of C as intermediary to that.
    Last edited by MK27; 07-24-2009 at 03:44 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    19
    Going from "I can read HTML..." to iPhone developer is not a small step and will take some doing. You won't be able to read a book over the weekend and show up Monday morning as an iPhone developer. I think that it's perfectly doable just don't be too impatient.

    I think C is the perfect teaching language. Every other language comes with crutches. C makes you understand everything that you are telling the computer to do. After that the rest of the languages are just a matter of learning the syntax. I like "C Primer Plus" from the Waite Group as a good book to start learning C. They also have a C++ book with a very similar name. I'd skip C++ and go strait to ObjC if Cocoa is your end goal. You can always come back and pick up the C++ stuff later.

    Get the book, load Xcode and enjoy. You will have to have a Mac to write iPhone Apps so you might as well start using Xcode as your IDE. It's a free, although quite large, download from Apple. You will also have to pay Apple to become an iPhone developer, but you can learn the language and the API without the developer subscription, using the included simulator. You have to pay the money when you finally want to load the App onto a phone and/or submit it to the App store.

  5. #5
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    Sit down and write some pseudo code and then write code. Going threw the exercises and not just reading the examples, but actually typing them down, is the best approach to any language. Review source code within the area that you are needing to develop in as well. If you have access to existing cocoa source code iPhone apps, all the better.

    When you mention troubleshooting, what was your approach? Did you check memory resources, 'use cases' and such. I would then get familiar with some good debugger tools as well, gdb, gprof, strace and valgrind are a few that come to mind. Though I am not sure what the MAC environment will provide in terms of such tools being available.
    Last edited by slingerland3g; 07-24-2009 at 01:47 PM.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    C is hard if you have bad learning materials.

    C isn't really harder to learn than any other language if you have good learning materials.

    K&R is a good C book, but it might be a little like a reference book for your tastes, I don't know.

    Some things that might make the concepts easier to learn:

    what RAM is
    what kinds of instructions cpus run
    what a branch is
    what a function call is
    what a function call stack is
    what a stack is

    also keep in mind that objective-c isn't really built on C. it's more like a blend of C and an object-oriented syntax. so you probably don't have to be an expert in C before you go on to objective-c.

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    I'd be willing to give you some help with learning C.

    I'm usually up late.

    I tried to send you a PM.... But I think since you're new I am not allowed. PM me then.
    Last edited by nonoob; 07-24-2009 at 03:19 PM.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Are you sure it's a good idea to leave your email open to the world?
    I dare say it's better that you exchange emails through PMs.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    You're probably right. Seems the internet is becoming more and more nasty every day.
    I changed my post.
    Thanks for the warning.

  10. #10
    Registered User
    Join Date
    Jul 2009
    Posts
    1

    A Great Place to Start with C

    To clear up a few arguments, C is my suggestion as the place to start, as far as programming for the Mac and iPhone goes. C is the basics of C++, Java, and Cocoa. It provides similar syntax and structure to the other languages.

    Whether you're writing for yourself, or your company, it mainly depends on what platform you intend to develop for. It sounds like you're going to be focusing on the iPhone/iPod touch? You'll need to learn a good amount about Cocoa Touch, a derivative of Mac OS X's Cocoa. Cocoa and Cocoa Touch are both s sub-structure of Objective-C. Naturally, Objective-C is a variation of C.

    So, to get headway on developing for the iPhone, become familiar with C. Then, move onto Objective-C. After Objective-C, you can either attempt Cocoa, or go straight towards iPhone development.

    One quick thing. if you have any intention of developing for the iPhone, be it personal or business-wise, I assume you know that you have to use a Mac? Any kind, and any model. It just has to meet a few requirements.

    - At least 1GB or RAM
    - A nice speed processor, 2.0GHz+ is good.
    - A good 10GB+ of extra room for the tools, documentation, and projects
    - Be running Mac OS X Leopard (or, come September 2009, Mac OS X Snow Leopard)
    - If you really want to be in good shape, a Mac from the last year or so is perfect. (I'm on an iMac, 3.06GHz Intel Core 2 Duo, 4GB or RAM, 500GB HDD, and Mac OS X Leopard 10.5.7, and it works perfectly for app store development.)

    Those specifications (to me) seem powerful enough to run Xcode, the software IDE (Integrated Development Environment) that you'll be using to develop the iPhone apps.

    Now, I understand you've been having some trouble with the sources you've tried? It's alright I tried a couple too that didn't work so well. But. After some digging, I found a great book series that makes it very easy to become familiar with C. They separate the functions are explain what and how the functions work. It also gives many external resources for more knowledge bases. They break down the Standard Library, and give examples that you can work with in Xcode. I recommend the Apress publishing group. They have some wonderful titles, like the book I mentioned earlier, by Dave Mark. He writes "Learn C on the Mac", and does an excellent job of making clear the ins and outs of C. The follow-up is "Learn Objective-C on the Mac". The third book to read (assuming you ARE going for iPhone dev at this time) would be "Beginning iPhone Development". All of these titles are by the Apress publishing group, and have hilariously put fruits with Vitamin C on each cover. ("Learn C on the Mac" has a lemon, "Learn Objective-C on the Mac" has a lime, and "Beginning iPhone Development" has a grapefruit.)

    I hope I have given you something of use, and wish you the best on your path to programming in C.

    Apress Home:
    APRESS.COM | Books for Professionals, by Professionals ...

    Learn C on the Mac:
    APRESS.COM : Learn C on the Mac : 9781430218098

    Learn Objective-C on the Mac:
    APRESS.COM : Learn Objective–C on the Mac : 9781430218159

    Beginning iPhone Development - Exploring the SDK:
    APRESS.COM : Beginning iPhone Development: Exploring the iPhone SDK : 9781430216261

  11. #11
    Registered User
    Join Date
    Jul 2009
    Location
    San Jose
    Posts
    4
    I think the following can be a good starting point.Its breif,accurate and you can follow advnced materials after that.There are other good stuff at the cslibrary.stanford.edu that you may want to look after you read the below :

    http://cslibrary.stanford.edu/101/EssentialC.pdf

    Dont miss Herb Schildt books also.I am reading his "C++ from the ground up" its very easy to follow and constructive.

  12. #12
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by arash
    Dont miss Herb Schildt books also.I am reading his "C++ from the ground up" its very easy to follow and constructive.
    I have no idea how reliable is Herbert Schildt when it comes to C rather than C++, but if his C++ books are anything to go by, then do miss Herbert Schildt books. The style of the books may be good, but the content is typically problematic.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by KodyTroje View Post
    To clear up a few arguments, C is my suggestion as the place to start, as far as programming for the Mac and iPhone goes. C is the basics of C++, Java, and Cocoa. It provides similar syntax and structure to the other languages.
    C is the basics syntactically wise. But nothing else.
    C++ uses totally different programming paradigms and other features than C, for example. Same for Java.
    While I agree that most of your suggestions are good, I don't believe this is one of them. If you want to learn a language, learn the language. Don't learn C first.
    Learn C if you want to work with C.

    For example, how the hardware works is totally unnecessary to know for Java or C++ (unless you're interfacing with C written code and/or API).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Registered User
    Join Date
    Jul 2009
    Location
    Oxford, AL
    Posts
    3
    Thank you everyone so much for all help you have suggested. Honestly I wasn't expecting so many responses, but this is great!

    I did notice when I first started last month that everything I was learning was nothing like anything I had done before. So everyone that has suggested some much needed direction, I really appreciate it.

    I am torn between " C Primer Plus " and " Learning C on the Mac ". Just from searching, C Primer Plus, seems most novices opt. for this title instead of some of the other choices. I am worried if I choose the Apress route that I will be putting the blinders on to any other environments?

    I am currently using a newer iMac and Macbook at home, with several PC's scattered around the house for all the kids, and a PC at work. So I have access to both environments. Last year I setup a web interface for the iPhone that borrowed from our existing database that dynamically generates content. That wasn't too bad, but I quickly learned was nothing like creating an app.

    I have installed Code Blocks at work, since it was free, and I do like using xcode at home. Especially the way xcode autofills syntax like I am used to in dreamweaver for html.

    I look forward to hearing what everyone has to say.

    Thanks Again,

    Sam

  15. #15
    Registered User
    Join Date
    Jul 2009
    Location
    Oxford, AL
    Posts
    3
    Just wondering if anyone had anything else to say about the advantages/disadvantages if I choose to use the Learning C on The Mac book, over C Primer Plus? If I would be limiting myself at all.

    Thanks,

    Sam

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Some Direction Needed
    By Bidamin in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2009, 10:15 AM
  2. Mouse Maze Problem
    By Furbiesandbeans in forum C++ Programming
    Replies: 13
    Last Post: 04-28-2008, 04:20 PM
  3. Algorithm to walk through a maze.
    By Nutshell in forum C Programming
    Replies: 30
    Last Post: 01-21-2002, 01:54 AM
  4. Finding the direction to another object
    By Person Man in forum Game Programming
    Replies: 9
    Last Post: 12-05-2001, 02:56 PM
  5. Classic problem doesn't accept direction
    By cheesehead in forum C++ Programming
    Replies: 5
    Last Post: 11-13-2001, 06:32 PM