Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

What do you recommend to learn as first languages?


  • Total voters
    43

Vaxuun

macrumors member
Original poster
Feb 6, 2010
35
0
Denmark
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.
 
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
 
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.
 
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?
 
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.
 
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?

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)
 
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. :)

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.
 
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 :)
 
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
 
So learning C won't really benefit if I someday in the future want to learn C++ or C#/C Sharp?

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.
 
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?
 
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.
Thanks for the great replies :)

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?


i learnt LOGO when i was maybe 11
 
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?

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¨.
 
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.
I recommend http://www.amazon.com/Learn-C-Mac-D...1?ie=UTF8&s=electronics&qid=1266114038&sr=8-1
Learn C on the Mac, which is a phenomenal book and what I used.

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

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¨.

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? :)
 
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.
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? :)

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.
 
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.
 
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.)
 
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)
 
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.
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.

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...
 
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)

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.
 
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.
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.

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.
 
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.
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.)
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.