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

notjustjay

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
My problem with Java for beginners is that it forces a fairly strict object oriented design approach, which is good in some ways, and confusing in others. A simple "Hello World" program requires you to create a class, then define a static main method within that class, then to even call the println function you need to understand its class hierarchy (System.out.println).

My sister, for example, did an "introduction to programming" class in high school, and hated it because the teacher didn't do a particularly good job of explaining the concepts -- and there are a lot of concepts to know -- so it felt too much like magic incantations to her. (Is it "public static void main"? or "static void public main"? or ...)

C is a little looser in that respect (though they get far more similar once you dive into C++) as you can write simple procedural programs without having to worry too much about wrapping the code in a class.

So for the very basics, if you're going to learn one before the other, I'd probably start with C. (Actually, for the extreme basics of programming, I'd start with Python.) But if you're already reasonably comfortable with object oriented programming, Java has a lot more functionality "out of the box". Once you learn one, switching to the other is not too difficult.
 

larswik

macrumors 68000
Sep 8, 2006
1,552
11
I took a Java class last semester and I learned C from a really good book about 18 months ago. If you don't have any experience in programming I would start small so that it won't confuse you, like it did me. I found that the book Learn C on the Mac was a great was to get started in programming. I spent a good 3 months slowly reading that book and redoing the small projects my own way. When I finished I wrote a small console based blackjack game.

With C under my belt I was easier to move into Object-C. Everyone has a learning curve. You can aim hi but don't be afraid step back in to a simpler language. It will take a while to get good and it depends on you.
 

macbook pro i5

macrumors 65816
Original poster
May 13, 2011
1,338
1
New Zealand
I took a Java class last semester and I learned C from a really good book about 18 months ago. If you don't have any experience in programming I would start small so that it won't confuse you, like it did me. I found that the book Learn C on the Mac was a great was to get started in programming. I spent a good 3 months slowly reading that book and redoing the small projects my own way. When I finished I wrote a small console based blackjack game.

With C under my belt I was easier to move into Object-C. Everyone has a learning curve. You can aim hi but don't be afraid step back in to a simpler language. It will take a while to get good and it depends on you.

Yeah i have no prior knowledge but i replace computer parts
 

Mac_Max

macrumors 6502
Mar 8, 2004
404
1
It's not really going to help you learn core C concepts faster. It might actually prejudice you in some ways so if you do go that path (or really even the reverse) so try to keep an open mind when switching to one language from the other. Essentially the core concepts are different and the stuff that does transfer is syntax like:

Code:
for (int cnt = 0; cnt < SomeInt; cnt++)
{
int myInt = AFunctionCall(cnt);
}

Stuff like that should be rather reasonable to learn in the first place.

Edit: Ironically I had a much longer post that covered a couple of things now brought up in replies... here's part of it in reference to...

I want to learn c++ then objective c so i can make apple apps.

Coming up with good advice for this kinda depends on what your background is. I get the feeling that you're just starting out and really don't have a lot of familiarity with any one language.

C, C++, and Objective C are similar in a great number of ways. Learning one can help with learning one of the others but it can also cause major headaches. As I learn Objective C myself, I tend to rely on my C++ knowledge in respect to the overall Object Oriented nature of the language but I really have to try to keep myself in an Objective C state of mind. Trying to use Objective C like C++ is a pretty bad idea (and vice versa for that matter). Each language has its own mindset that you have to get a grasp on. In many ways this is more important than just getting used to a different syntax. In the case of C++ and Objective C, even though they're both Object Oriented, they do it in two very different ways.

If your end goal is learning Objective C, you're probably better off starting with a good C primer to learn the C memory model, pointers, and C style syntax before moving to Objective C related books (most of which will have a mini-C primer as a refresher). You will end up working with ISO/ASNI C code at some point so thats definitely not a waste of time. Once you're comfortable with C/Objective C, start from a fresh empty cup stand point and learn modern C++ (as in, don't write C++ like C with a little C++ sprinkled in). Then feel free to mix them properly and appropriately with Objective C++.
 
Last edited:

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA
I wouldn't bother. I'd probably learn C, then Java.

But, I'd learn Python, Ruby, or Javascript first. Java and especially C can be incredibly de-motivating when trying to learn how to do the simplest of programs.
 

notjustjay

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
I wouldn't bother. I'd probably learn C, then Java.

But, I'd learn Python, Ruby, or Javascript first. Java and especially C can be incredibly de-motivating when trying to learn how to do the simplest of programs.

Agreed. Start with Python. Use the command-line interpreter at first for instant gratification. Then write simple programs. Try your hand at user input and output. Basic control flow like loops. Simple functions. The forced indentations in Python will help you visualize code in structures which will help you discipline your coding in C and C++.

Then move to basic procedural C. Write a "hello world" app. Write a simple console game where the computer picks a random number, you guess, and it tells you if it's too high or too low. Write the opposite program where YOU think of a number and the computer guesses. Stuff like that.

Then move to objective C and/or C++.
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
I still assert that if the goal is Objective C you should try to learn that first, then once you have the hang of that back off a bit to learn some more C and then jump with both feet into Cocoa or Cocoa Touch.

This is the approach Kochan takes and is aimed at those without any prior experience.

Hillegass' latest book gives a whirlwind tour of C before launching into Obj-C and this would be my only recommended alternative.

IMHO Java and C++ will only add confusion to the mix.

B
 

mrxak

macrumors 68000
I feel that in general, it's better to learn older languages before learning newer languages, if your goal is to learn a lot of different languages. If your goal is to learn one language, just learn that language. If you want to learn many languages, start with the earlier stuff first.

My reasoning is that new languages are created in reaction to other older languages, which inform their philosophies and syntaxes. New languages are created because the creator felt that existing languages were not suitable for certain problems. I believe it would be useful for you to understand what those problems were first, so when a newer language says it can handle it better, you understand what it's all about. Especially when you're just starting out and everything's new, older languages have less concepts to learn just to get your foot in the door.

Every language has its benefits and downsides; there is no one perfect language for every single problem. The more languages you know, the more flexible you can be as a programmer, just like choosing the right tool for the job. You can still bang in a nail with a wrench if it's just one nail to hang up a picture frame, but you probably want a hammer if you're going to build a house. The point is, it's good to have options so you can weigh the pros and cons when you want to tackle a project.

So, my advice would be to learn C first. C is a wonderful language that will give you a great foundational knowledge of computer programming, as well as an appreciation for memory management. Then, if your goal is Objective-C, you'll already know the bones, and just add on object-oriented programming (and presumably Cocoa libraries). Then, if you're interested in learning other approaches to object-orientedness, try out C++, or Java. Then you can start digging into some really interesting languages like Haskell, Ruby, or Lua. Before long, you'll be doing crazy stuff with Perl, Scheme, and MIPS assembly language.
 
Last edited:

alandy

macrumors newbie
Feb 29, 2012
1
0
Learn C

The short version: Everyone should learn C first.

I agree completely with mrxak

As a Computer Engineer, trained bottom up from transistors to assembly to C, I could not stress more how important I would say it is to learn C. I believe that everyone programming should thoroughly understand what they're really doing and what is happening when their code is executed/compiled/etc. I'll admit its not necessarily useful for an average programmer to worry about learning assembly first, but a fundamental knowledge of the lowest levels of computer software are essential to well-designed code. Since C is at this point as close to bare metal as really matters, and is so fundamental to so much of today's world of programming languages and modern computing, every programmer should thoroughly understand it.

Object-oriented programming is useful but certainly is not the end-all of software design, and it definitely doesn't make sense to me to start there. That being said, I found the jump from C to Java (when first learning OO) easier than to Objective-C even after years of experience with C++ and Java. They are so different that Java is probably not the best starting point for learning Objective-C, but I would definitely recommend it as a next step to learn OO after mastering C.

Scripting languages are useful but learning them definitely doesn't tell you anything about how a computer works, of course not everyone cares how the computer works, as long as it magically happens. I see them as shortcuts (and I do use them often) but as tools for simple tasks (perl is pretty much only good for find and replace) or simplifying and automating a long toolchain, for which they are perfect.

Of course that's just my opinion, I suppose it doesn't work for everyone.
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
The problem I have encountered, even in my own coding, is that the C/Unix DIY approach is the antithesis of good Obj-C code.

In C, you are actively encouraged to build stuff from scratch. Painfully crawling over the broken glass and barbed wire.

Higher level languages, especially OO ones, would never force you figure out your own bubble sort, or parse input strings by hand, and the reality is that you do not need to know how this works to be productive and meet your goals.

Sure, it can help when you run up against something that doesn't work, but it is far from essential.

I repeat if the end goal is to learn Objective-C to program on Macs/iOS focus on learning that. Learn C along the way as it will be useful, but it is too easy to develop detrimental habits that way.

DISCLAIMER: Everyone learns things differently, YMMV, IANAL, etc...

B
 

macbook pro i5

macrumors 65816
Original poster
May 13, 2011
1,338
1
New Zealand
It's not really going to help you learn core C concepts faster. It might actually prejudice you in some ways so if you do go that path (or really even the reverse) so try to keep an open mind when switching to one language from the other. Essentially the core concepts are different and the stuff that does transfer is syntax like:

Code:
for (int cnt = 0; cnt < SomeInt; cnt++)
{
int myInt = AFunctionCall(cnt);
}

Stuff like that should be rather reasonable to learn in the first place.

Edit: Ironically I had a much longer post that covered a couple of things now brought up in replies... here's part of it in reference to...



Coming up with good advice for this kinda depends on what your background is. I get the feeling that you're just starting out and really don't have a lot of familiarity with any one language.

C, C++, and Objective C are similar in a great number of ways. Learning one can help with learning one of the others but it can also cause major headaches. As I learn Objective C myself, I tend to rely on my C++ knowledge in respect to the overall Object Oriented nature of the language but I really have to try to keep myself in an Objective C state of mind. Trying to use Objective C like C++ is a pretty bad idea (and vice versa for that matter). Each language has its own mindset that you have to get a grasp on. In many ways this is more important than just getting used to a different syntax. In the case of C++ and Objective C, even though they're both Object Oriented, they do it in two very different ways.

If your end goal is learning Objective C, you're probably better off starting with a good C primer to learn the C memory model, pointers, and C style syntax before moving to Objective C related books (most of which will have a mini-C primer as a refresher). You will end up working with ISO/ASNI C code at some point so thats definitely not a waste of time. Once you're comfortable with C/Objective C, start from a fresh empty cup stand point and learn modern C++ (as in, don't write C++ like C with a little C++ sprinkled in). Then feel free to mix them properly and appropriately with Objective C++.

Thank you you are right i have no prior knowledge to any language so i think ill just get my self a learning c book in fact i saw a website teaching c and it is much easier to learn then java IMHO.
 

Mac_Max

macrumors 6502
Mar 8, 2004
404
1
The problem I have encountered, even in my own coding, is that the C/Unix DIY approach is the antithesis of good Obj-C code.

In C, you are actively encouraged to build stuff from scratch. Painfully crawling over the broken glass and barbed wire.

Higher level languages, especially OO ones, would never force you figure out your own bubble sort, or parse input strings by hand, and the reality is that you do not need to know how this works to be productive and meet your goals.

Sure, it can help when you run up against something that doesn't work, but it is far from essential.

I repeat if the end goal is to learn Objective-C to program on Macs/iOS focus on learning that. Learn C along the way as it will be useful, but it is too easy to develop detrimental habits that way.

DISCLAIMER: Everyone learns things differently, YMMV, IANAL, etc...

B

Yeah, my experience has been the same when it comes to C++ and other languages. A lot of people get stuck in the romantic idea of tweaking their code for "maximum performance" for hours on end. I try to stick to the platform's built-in constructs as much as possible. I've seen some really weird things like ad-hoc developed XML parsing facilities in C# (which must have three different, solid, built in ways to do that already) that are terribly inefficient, leak memory, and had to have taken at least one hundred hours to write. I think it took me about 10 hours to teach myself how basic Linq queries and XDocuments work.

I learned how to work with ANSI/ISO C on the fly while learning and working with C++ (mostly within the realms of Win API calls) and my experience has left me feeling like it might actually be worthwhile to learn the basics of C first, separately. A lot of times my C knowledge is not particularly good (my worst being C style strings... terrible things they are anyways...) and it sometimes makes debugging sample C code for iOS and Mac learning projects painful ;). Granted that probably is more a function of that being a hobby instead of my primary language so this experience likely can be filed under your disclaimer haha.

Thank you you are right i have no prior knowledge to any language so i think ill just get my self a learning c book in fact i saw a website teaching c and it is much easier to learn then java IMHO.

Looking at balamw's book link and its TOC, he's probably quite right, the first 70 pages should teach you what you need to know. You can also try "Learn C the Hard Way" (note, that's "hard" as in correct/not taking short cuts):

http://c.learncodethehardway.org/
 
Last edited:

Mhkobe

macrumors regular
Jun 25, 2009
140
0
I want to learn c++ then objective c so i can make apple apps.

Learn Objective-C first if you want to make Apple apps. You will likely need a little background in C first, but that should be covered by most introductory objective-C books. I would recommend Cocoa and Objective-C Up and Running if you are new to programming, if you have any background in a C based language I would recommend starting with Programming in Objective C 2.0.
 

GorillaPaws

macrumors 6502a
Oct 26, 2003
932
8
Richmond, VA
A someone whose taught himself to code with Objective-C as my first real language, I have to fully agree with everything @balamw has said. If things get too difficult for you, and you really feel like giving up, Python, might be a reasonable alternative to build your confidence before returning to Objective-C. Java doesn't make much sense to me based on your stated goals. You might want to learn it some day, it's a fairly common language, but it's a bit like flying from the US to Sydney when your final destination is Moscow (it's vaguely in the right direction, but far enough away that it makes no sense).
 

mrxak

macrumors 68000
Glad to hear you're taking the plunge into C. Good luck to you and have fun.

I highly recommend, in addition to learning how to program in C, that you try to learn computer science concepts as well and not just... "programming". I'm not familiar with the book you're using, so I have no idea what's covered, but it'll be useful long-term for you to understand algorithms and data structures and all sorts of things like that. It's not just important to know how to program things, but to know how to design and build a program that works efficiently and isn't a nightmare to maintain and alter.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.