views:

2518

answers:

35

I realize this is a subject of hot debate, but I'm interested in opinions that relate to my specific situation.

I want to learn the basics and fundamentals of programming, so I'm already taking a college course in general programming concepts. It isn't covering a specific language, but it's giving me a solid foundation that I can build upon when I move on to a class that teaches a specific language.

My two options for a specific language are Java and C because those are the two languages taught at the college I want to take classes from.

What I want to do is learn a complex language so that I can apply that knowledge to languages that I use, or will eventually use, in my current job building web pages: XHTML, CSS, JavaScript, PHP, XML, ActionScript.

I'm not necessariy interested in becoming a Java developer or a C developer in the immediate future, but I do have aspirations of developing web applications and iPod/iPhone applications.

So, basically, I'm looking for answers to these questions and the reasoning behind them:

  • Do I take the introductory course in Java first, and then take the intro course in C, or

  • Do I take C first and then take Java?

  • Is there any reason not to take them concurrently?

  • Should I skip C altogether as Java covers everything I need to know?

EDIT: Thanks everyone for your thoughtful and insightful responses.

+1  A: 

They will teach you different things, so if you have the time and the bandwidth of taking both you can. It would be a little bit confusing for me but your mileage may vary.

Remo.D
+2  A: 

I would take both intro courses concurrently. No single language covers everything you need to know. As a professional programmer, you'll need to be able to switch between different programming languages (especially as a web developer). There is no reason not to start developing these skills now.

MusiGenesis
A: 

Take an introduction to programming course first - the language doesn't matter, then take C++. Every programmer should know some C++ - there's just too many important things written in it. Plus it gives you a good idea of what's going on "under the hood". Update: C++ being a superset of C and any good course should cover what's C and what's "++". Java whould be a good. next step, esp if the introduction couse didn't use java. Don't take both at the same time I've done that myself - too much to grok properly.

Update: I'm not a C++ snob. I program in VB.NET and I love it. I hated C++, but it's important and I'm glad to have been forced to take it.

Booji Boy
C++ has too much magic to be a good way to learn about what goes on behind the scenes. Real world C++ code does not translate easily at all to what goes on at the level of bare metal.
Joeri Sebrechts
Neither is java. But C++ includes C, so there's opportunity to learn bare-metal, AND opportunity to learn all the object oriented stuff. I've met too many programmers that do fine with C and Java, but can't handle C++ because C++ includes OO things java doesn't.
davenpcj
Really? I don't recall any magic in my C++ courses.
Booji Boy
I remember things like templates, memory allocation and de-allocation, pointers, stacks, queue's, the stack, the heap registers, etc... No magic.
Booji Boy
and of course OO concepts like inheritance and polymorphism.
Booji Boy
The problem with C++ is that if you don't have a really good professor its basically pointless, you'll have to learn it all on your own, which is why C is safer to start with alot of times as its a bit smaller.
Greg Rogers
@Joeri: You are quite naive. My own experience of real world C++ was more "C+", that is a C++ compiler used by C developers unable to do anything that go beyond their prefered language. The "on the bare metal translation" is a fallacy since multicore and multithread became the norm.
paercebal
+3  A: 

I would say to start with C, or something else that isn't object oriented. This gives you a good base, for just thinking about algorithms, without getting involved with all the complexities that objects bring into the picture. Then you could move on to something like Java, or C# to explore Object oriented programming. You don't have to stick with one language for too long. A month or two should be enough to master most of the syntax. After a month or so of learning, you can turn to something else, and continue to learn something new while you are still exploring the intricacies of the other. If you really want to start out small. Just go with Basic for like 2 weeks, and understand the really simple stuff like doing loops, using conditionals, and calling subroutines.

Kibbee
You can write java programs that have a single class with a single method, so you don't have to worry about all those tricky OO problems.
Joeri Sebrechts
"you can" is not the same as "you will be taught that way".
gbjbaanb
I agree, with gbjbannb. Although you can use just one class, if you're going to to that, you might as well not use Java. Also, if you do this, you are somewhat setting yourself up to relearn Java once you want to go object oriented. Doing things the "wrong way" the first time is a bad way to learn.
Kibbee
I think postponing OO is a terrible idea. OO is at the core of most modern software, and the more you train your mind in procedural design, the harder the paradigm shift to OO will be.
slim
+3  A: 

For something useful in relation to other high-level languages and web programming, learn Java.

If you want to understand more about how computers work, learn C.

If you already know PHP and ActionScript reasonably well, then Java is not going to teach you all that many fundamental programming concepts that you haven't encountered already. But there will still be some new things (for example strong typing).

C does seem to be generally regarded as "harder" than Java, and may have a steeper learning curve, so to an extent it depends how smart you are. But if the only course prerequisite is basics of computing, and as long as the professor isn't a sadist, the course is presumably designed to be manageable to people like you. I mean, your school is there to teach you stuff you don't know. You wouldn't not take Ancient Greek 101 just because you didn't already know Ancient Greek. Consult your faculty for advice on prerequisites, and don't be scared that the C course is "hard-core" unless they tell you to be.

The discipline and detail required to get C code even vaguely working is quite different from HTML and CSS, where interpreters are designed to be very forgiving. The C compiler is designed to forbid certain illegal things completely, but to emit code that crashes mysteriously, or produces the wrong output, or sets your machine on fire* when you do other illegal things. There's not much scope for guesswork.

Java is also much stricter than the stuff you already know, but it's not so fiddly as C and it won't set your machine on fire. So to learn how to write working code, establish that it's correct, debug it when it isn't, and that sort of thing, then Java is probably the better bet. In C it's easy to make obscure, boring, mistakes that don't really educate you about anything other than the C language itself and to be more careful next time, and there's other stuff you want to learn.

(*) This is a common joke among C programmers. If you take the C course you will soon learn about "undefined behaviour". When the C standard says that your program results in undefined behaviour, the compiler is "allowed" to emit code that does absolutely anything, including catch fire. Or cause demonic monkeys to fly out of the screen and bite your face. Very few compilers actually do either of these things. But you never know.

Steve Jessop
However, using Java would teach you what a good API looks like, as opposed to PHP.
Kibbee
Java's API is good? ;)
Telos
There is "knowing" and there is "knowing". Being able to write a script in PHP doesn't mean he has actually learned how to program. A formal introductory java course would teach about data structures and algorithms.
Joeri Sebrechts
Sure, but I said "if". Maybe I should say it louder.
Steve Jessop
That's exactly right. Basically, I can write a simple script in PHP, but I really need a formal introductory course to learn how computers really work.
Well then I'd say there's 2 issues. For how computers (i.e. hardware) works, learn C, assembler, take courses on CPU architecture, etc. For how programming works, the business of designing software, language doesn't really matter and Java will get in the way less compared with C's awkwardness.
Steve Jessop
A: 

Both will teach you discipline which usually non well trained developers lack, especially on the web.

C will teach you a lot more discipline than Java as you'll have to handle memory management and be at a generally lower level.

Neither is directly applicable to your web development experience, though Java is more related as you can easily program web apps in it.

I would take them both simultaneously to be able to compare them "in real time", so to speak. That's supposing you can handle the load, it will be hard if you've only seen PHP. If you think you can't, I'd start with C because it'll teach you more.

Vinko Vrsalovic
+3  A: 

I'm inclined to say to take C first, as it is as close to Assembly as you can get without actually being Assembly. Assembly, in turn, is close enough to the Turing model of computation, which is the real science of Computer Science.

Java provides a fair amount of abstractions on top of C/C++. I think you'd be well-served to understand the details that Java is hiding from you so you don't mis-use the language.

Of course, if all you want to get up-to-speed for your web development job as quick as possible, then skip straight to Java.

moffdub
Thanks, yes I do want to get up-to-speed as quickly as possible, but I'd also like to learn Assembly. That's my dilemma. :)
+1  A: 

OO is a difficult thing to get. Most "OO" programmers don't really get it. So I suggest trying to start with an OO attitude and have time to mull it over. It's not very productive to get into the mindset of worrying over the little details that computers can be made sort out anyway.

Tom Hawtin - tackline
A: 

You don't want to start with C, because you'll get bogged down in low level details, while you want to focus on the essentials of programming: algorithms, data structures, OO, ... For an absolute beginner I feel javascript is the best choice, but java will do. Java's level of abstraction is definitely closer to the other web languages than C's.

On the other hand, you have to learn C, just because it will give you a better understanding of what happens behind the scenes. This is incidentally also the same reason you have to learn assembly, eventually. In my opinion you can't be a good programmer if you don't understand how programs work on the level of bits and bytes, and learning C (and assembly) will give you that knowledge.

My advice: if you feel you can take them both and carry the workload, then do so. Otherwise, start with java, then move on to C.

Joeri Sebrechts
I hope you know Java and Javascript (aka Ecmascript) are not related!
Partial
What part of my answer put that into doubt? JavaScript and Java are not related, but that doesn't rule out the notion that both of them are good beginner's languages, due to being high-level. The advantage of JavaScript is that it lends itself to one-liners, which are usually the best teaching method for absolute beginners.
Joeri Sebrechts
+2  A: 

If you don't wanna be a programmer, and you don't have the background knowledge, then I suggest starting with Java.

If you have greater plans, then start with C.

I wouldn't take them concurrently without prior knowledge, you might be confused.

asalamon74
+5  A: 

I recommend that you start with Java. Beginning programmers are typically tripped up, quite badly in fact, by pointers in the C programming language. (Pointers can be a tricky subject in any language that supports them, but they are especially difficult to understand in C. I had already master pointers in the language Pascal before I learned C, but I still had a devil of a time with them.)

If you begin with C, count on spending a great deal of your time not learning the fundamentals of programming, but instead trying to figure out why arrays are just like pointers, why arrays are not just like pointers and why your program is crashing seemingly at random. Java is a richer, more complex language, it requires you to learn many more concepts than does C, but you will spend far less time struggling with the fundamentals in that language than you will in C.

Java also has the advantage of being an object-oriented language. You will need to understand object-oriented programming to work with most modern languages, including JavaScript and ActionScript.

If your career is limited to building web pages, you will probably never need the additional concepts you can pick up by then learning C, although understanding C will certainly give you a better of understanding of "how computers work," since it is a much lower-level language.

dgvid
+8  A: 

It's too bad your college doesn't offer C++, as that gives you everything C would teach you plus the Object Oriented stuff you'll learn with Java.

Java will almost certainly be more applicable to your web development future.

C teaches you a lot of important low level stuff.

The question is: How important is that low level stuff to a web developer?

Being primarily a web developer myself, I don't think it's that important. Everything you really need to know you'll learn with Java. So although I hesitate to say it, go with Java first then C if you really want to get a deeper understanding of programming in general.

Telos
Thanks, actually, C++ is offered, but not as an introductory class. I would need to take Java before I could take C++.
I agree, Java first, but I disagree about C++. C++ is too hard; it scares students away. The ones left are mostly OK with unnecessary complexity. I like programmers who value simple, elegant design. So, I think it selects the wrong people.
Alan Hensel
Hey, my first language was C++ and I turned out ok! (I think...)
Telos
Just because the design of the language is not simple doesn't mean you can't write simple, clear programs in C++...
Greg Rogers
Just to be clear, neither Telos nor Greg are contradicting my comment.
Alan Hensel
I just didn't want to get into an argument. I don't think C++ is so complex that it will scare anyone away who is capable of becoming a good programmer in the first place.
Telos
+1  A: 

C has a large number of icky features that make C programs a pain to write a debug. C has ambiguous semantics and endless memory-management problems. C is so bad people write books about how to make C acceptable for common use.

[Example, what does a[i++]= i; do? Now try to find a reference to back up your opinion. If you actually compiled it, try compiling with different optimization switches.]

However, C is also the foundation for the GNU/Linux OS, and consequently, one of the two most widely used programming languages. Java's the other.

Java lacks the ickiest features of C. The folks that invented Java learned their lessons from the problems C has. The semantics of Java are crisply defined. Memory management is part of the JVM, not a headache you have to cope with.

Learn Java first.

If you ever need C, you'll have a foundation of experience in good software, so you'll understand the issues with C. If you start with C, you'll learn some trivia that you have to unlearn when you try to pick up Java.

S.Lott
why would you need to write a[i++] = i; ? There are more simple and understandable ways to do that.
djeidot
The point is not to write it. The point is that the language specifies no semantics for it. The statement is just one example of a C construct that cannot have any well-defined meaning.
S.Lott
The point is that There#s More Than One Way To Do It, and several of those ways are wrong. And even quite experienced people can choose the wrong way without knowing it. Also true of Java, but less often.
slim
Technically the language specifies undefined semantics for [i++] = i, not just unspecified. Most compilers will yell at you anyways so its not a big deal.
Greg Rogers
I'm not sure "most" compilers will. I think some are smarter about this than others. But there are too many things which are syntactically correct but have vague or indefined semantics. That's just creepy.
S.Lott
Ok, keeping in mind that I never learned C itself but started with C++...Shouldn't that statement just assign i to the value at array index i and then increment i?I don't see a problem with the statement... even if not explicitly defined shouldn't precedence basically work the statement out?
Telos
Java has just as many issues. I say write your code so it is clear to understand and reduce the chance of things being dictated by how the compiler is implemented.
bruceatk
When -- precisely -- does the increment happen? After a[i] is found? After i is assigned to a[i]? Could be a[0]= 1 or a[0]= 0. There is no definition if which is correct.
S.Lott
Java has some issues, true, but it doesn't have the "undefined semantics" issue. The "this statement has no meaning" is a show-stopper for newbie programmers. I suggest avoiding the language that has this problem.
S.Lott
A: 

I would say Java first. It's a much more beginner-friendly language to learn. It is also very powerful and lets you accomplish alot in less time than C would take.

Everyone should have a look at C at some point though - it teaches you how to work closer to the computer than Java does and this is useful to know.

Scottm
+33  A: 

I personally believe that C is the better language to start with. Even if you never use the low-level bits of C, you'll force yourself to think in a particular way to get things accomplished.

If you take a good enough C/C++ courses for 1 or 2 semesters I think you'll become a much better programmer later. When I was learning programming I opted for the more advanced C++ classes at my school. I found that I had a much bigger advantage than people who took only basic programming courses before when it came time to learn higher level programming languages like JavaScript and PHP.

High-level concepts are easier for me to understand. I can also pick up new programming languages very quickly. All because I took some lower level programming courses for a year.

I definitely think you're better off taking Java after a C/C++ course.

Of course, your mileage may vary depending on how you learn...

Dan Herbert
I've coded 99.99% Java since 1995, but I would still recommend starting with C. I interview too many who don't understand how computers work, which is something you're more likely to learn in C. I love Java, and highly recommend that you learn too it so you can port your apps to Android.
erickson
Same as erickson. I have been mainly coding in Java over the last decade, but I reckon learning C first helped me immensely.
toolkit
C and Java are too different to take one or the other. I would compare Java more to C++ than C. The advantage of C++ is that it is a multi-paradygm language where you could do some functional programming like what you will see in C, do some OOP like what you can see in Java, do some meta-programming which you will not be able to find in C and find as powerful as C++ in Java , or even mix all of those together! Learning C++ first has helped me so much to be able to go from one language easily without trouble.
Partial
Given his target languuages like XHTML and CSS, knowing the details of how Java works and especially C is likely to be unhelpful. C might be how you feel real programmer should learn programming but it doesn't make a good choice here. IMHO.
Peter Lawrey
Dan Herbert
@Peter: He also mentioned that he would like to develop applications for the iPod/iPhone. To create applications on these you must do some Objective-C which is based on C and is somewhat comparable to Java.
Partial
@erickson, I agree is he was planning to be a Java programer, But he is planning to be an ActionScript/Web Developer/GUI and this is a very different skill set than low level C programming. WHat point in wasting many hours cursing pointers if you are never going to use them?
Peter Lawrey
@Dan To start with; knowledge and commercial experience in the languages he actually plans to use is more valuable than learning etymology. Learning Java and C would make him more valuable in the future, after perhaps five years experience.
Peter Lawrey
@Partial, then I would suggest learning Objective-C.
Peter Lawrey
@Peter Lawrey: Have you ever heard of Objective-C++? You can mix some C++ with Objective-C. Learning C/C++ would help a lot!
Partial
@Partial, have you never heard of libraries and tools? Learning a language is easy. However, for it to be any use you need to understand the tools and a non-trival portion of the libraries. That is where the real effort is. You can buy a single book which describes every piece of functionality of a language with useful examples. That won't actually be very useful in the real world unless you know how to use the libraries/tools which are used with it. How many books would it take to cover every library (including open source) and tool with useful examples for a language like C++ or Java?
Peter Lawrey
@Peter: Learning a language for the first time is not easy. You need to learn a new way of thinking, new symbols, a new syntax, new features and the limits of the language. At the same time you will be learning a set of tools and libraries. Can you really say that you have mastered the languages that you know? The first library I learned about in C++ was iostream. Why you may ask? I needed a way to print results to the screen in order to learn certain features of the language. In short, you follow a series of steps. It's a bit like a recipe in which the ingredients are what I enumerated.
Partial
@Peter Lawrey: Now, I am having trouble to make a link between my comment on Objective-C++ and your comment. In Objective-C you will use C++ to optimize your application and to use its features when you will see the limits of Objective-C. I am not suggesting to learn both C and Java. I would rather go with C++ first and then learn some Objective-C. If you want to know why please read my answer http://stackoverflow.com/questions/143820/i-can-learn-either-c-or-java-which-one-should-i-choose-first-should-i-take-them/2437206#2437206 .
Partial
+4  A: 

"learn the basics and fundamentals of programming" pretty much implies learning C. Pointers are a very important concept, fundamental to any work done at low level. All the higher level languages use them under the hood - pointer to pointer to functions that return pointers to etc.

Maybe about 99% of all programmers are using Java, .NET, Python and more abstract or specialized languages, where pointers just don't come up. If "references" come up, those are really pointers wearing intellectual costuming. In Java, every object is really a reference, so you're really doing a lot with pointers.

Still, for the most part you could probably ignore the idea of pointers - except that when performance matters, or memory usage needs to be tightened, or in trying to resolve an unusually tricky tough bug, or just to reduce the sense of mystery of what's going on under the hood - in order to an extraordinarily good programmer - you gotta understand pointers and related concepts that matter to OOP, such as virtual method tables. If you have two containers each holding the same item - is it really the same item, does one container point to the item in the other, or do they both point to that one - questions like these are easily understood with pointers and related concepts as part of one's "mental furniture" to arrange as needed. Without an understanding of the infrastructure, many of the rules for handling objects, ownership thereof, memory managament may seem arbitrary.

Even at the end-user applications level, if you ever do debugging of any kind, to understand what exactly is a stack trace, segment faults and to glance at register contents and actually have a useful thought follow, it is good to understand things at the C level, and maybe also assembly, but that's going outside the scope of the original question.

The advantage of Java or C may be in getting quicker to OOP concepts, organizing large programs into modules, and getting quicker to a practical working app, but the disadvantage is reliance on huge libraries that are practically "black boxes" you wire into the app and don't know what's going on inside.

Anyone with any interest in the infrastructure of computing - operating systems, device drivers, memory management, threading, and interpreters for higher level languages and unix shells and more - nearly all of that is written in C.

I've dwelt on pointers, but also it's good to know how integers, floats, strings, and other fundamental data types are stored and manipulated. C lets one get close to those kinds of details.

Although, i admit I may be biased, since i was the kind of kid who took my toys apart, and put them back together. Also, my first language was assembly. Not everyone craves to know what's inside, how it works. YMMV

DarenW
99% seems a little high for me. There are still a lot of C++ and C programers out there.
bruceatk
A: 

YMMV , we all have different brains, but i'd avoid learning two languages at the same time, or in the same year. Too often i mix up details, like using a Ruby idiom in Python. I learn better by forcing myself to do everything in the one language i'm learning, even tasks best done in other languages - until i've really nailed that language from having tried doing so many differnt things in it.

DarenW
+7  A: 

Joel Spolsky has this to say on the subject. C is the Lingua Franca of computer science. If you want to know how and why your Java program behaves as it does, knowledge of C is a must. (What is your average JVM written in?)

If you have some programming experience, learn C first, then Java. If you don't, do it the other way around.

JesperE
I disagree with this. If you have no programming experience, either Java will probably put you off the idea for life, or, if it doesn't, you're probably better off doing something else.
Brent.Longborough
In that case, starting with C would not have helped.
JesperE
I wish we had a way to vote up comments... If there was, I would definitely have voted Brent's. "Either Java will probably put you off the idea for life, or, if it doesn't, you're probably better off doing something else" So succintly put... :)
sundar
+8  A: 

I definitely wouldn't take both language intros concurrently. If it's worth your time to study a language at all, it's worth your undivided attention to focus on it exclusively and learn it really well. If you take both at the same time you're just going to get a generalized understanding of their basics but not be particularly adept at either.

If you have aspirations of developing iPod/iPhone applications you're definitely going to want to learn C. Objective-C, the native language in which iPod/iPhone applications are implemented, is a strict superset of C. Having a strong foundation in C will help you immeasurably.

Fhoxh
I disagree as a CS student I am taking C and Java, have a internship in PHP and am learning Ruby on the side. But maybe it depends on the individual.
Mark Lubin
A: 

I had to think quite hard about this one. I think it all comes down to:

  1. Is it a good idea to postpone learning OO concepts?
  2. Is low-level memory management and data structure navigation valuable this early in your studies?

To which I answer, yes to the first, no to the second.

The more you train your mind to think procedurally, the harder it will become to make the paradigm shift to OO. I had a bear of a time shifting to OO, and you can save yourself my pain by adopting it earlier. Avoiding OO forever is not an option.

C requires your programs to look after memory very carefully, even to do pretty simple things. The data structures this creates have perfectly reasonable analogues in Java, in a slightly more forgiving environment. I think if you've implemented (say) a binary tree in Java, then it won't be so challenging later in C -- where you have to take the extra step of explicitly freeing memory you don't need any more.

While of course it's great to understand the fine details of how a computer works, and for some programmers (compiler/interpreter writers, driver implementors, game engine developers, etc.), remember that MOST programmers work a couple of layers higher than this, where it's actually important to ignore the nuts and bolts of what happens behind the scenes. When you code in C, you shouldn't usually be thinking about the target CPU - that's the compiler's job (although you should be thinking about avoiding constructs that are not portable between CPUs!). When you're programming in Java, you shouldn't usually even be thinking about the OS your code will run on.

slim
+2  A: 

Both of these languages are of different programming types and will broaden your horizon and help in future. Directly jumping to Java will narrow your horizon and you wont appreciate the concepts of Pointers and power of C. Plus if you are more geared towards mobile applications than learning C/C++ will be plus. I would definately take C as the first course and than jump on to Java. Java is an object oriented programming language so the mindshift to an Object oriented language will be a bit tough initially but you will get over it. I think every programmer must add these types of languages in his skillset to broaden his horizon

  1. Functional programming lanugage like LISP
  2. Object oriented language like Java
  3. Scripting language like Python/Javascript
Kalpesh Patel
+17  A: 

Summary

  • Programming is a passion for you: Do learn C, and as soon as possible, move to another, more complex languages (C++, Java, C#).

  • Programming will be your job, but you'd rather do anything else than play with compilers at home: Do learn Java. Some low level understanding will be missing, but hey, no one needs knowing how a car really works to use it as part of his job.

Why C would be a good/bad idea?

C is very low level, but not too much. You have variables, functions, a stack and a heap. You'll have pointers, dynamic allocation and, some C glitches are interesting to know if you want to have some edge over other developers.

But C breeds bad habits. For one, it breeds arrogance. Nothing is so much nerve-wrenching and at the some time amusing than a C developer trying to tell you how much his language is better than yours, because it is faster (usually a lie), and better (lie, again). With C, (as with C++), standard libraries are so poor it is an eternal source of frustration (of course, there are a lot of libraries around the web, but then, they're out of the standard...). Despite what is promised elsewhere, C won't give you all the basics about programming. Its object-oriented features are non-existent, and if you stick too much to it, you'll fossilize your mind and everything you'll learn will be criticized about how you could do it in C, instead of what this new way of thinking to make your programming experience richer.

Conclusion: Do C only to learn from it. Do not keep yourself constrained to C. Either move to C++, as C++ can be a low level as C, and can be almost as high level as C# or Java. Or go even further, and move to C# or Java.

Why Java would be a good/bad idea?

Despite what some people would tell you, despite its higher language status, Java (or C#, for they are of the same language family) is quite efficient, and now are able to reach efficiency level of C/C++ in code execution. It is object oriented, and its libraries are so complete it'll just blow your head off (don't be intimidated, though). For the average developer, it is more "cross platform" than C or C++ because its standard library is present on any Java Runtime. So, if you do a C GUI program on Linux, and want to see it executed on Windows, you'll have to learn some tricks (I did not have the patience). For Java, just copy your jar files on any computer with a JVM, et voila.

Now, Java is no silver bullet. Sometimes, it can just be slow, and some processing will have to be done in C or C++ through JNI bindings. And if Java will teach a lot about statically typed object oriented programming, it will do little to teach you about low level programming, pointers, memory, etc.. It's difficult to explain, but, as a C/C++ programmer, I like to see a Java or C# program and instinctively know what processing will be slow, and what will be fast. It's pleasing to start my first brush of C# with ".NET/C# optimization" and understand a digest easily everything explained there. This is the kind of feeling someone who started with Java, C# or (gods help them) Visual Basic can't ever start to perceive.

Conclusion: By going straight to Java, you'll avoid some chores from C. The problem is that some knowledge lost among this low-level language will perhaps be missing when you need them.

So what?

For now, from what I perceive around me, the mainstream programming is done using C++, Java and C#, C++ losing its edge as easier programming languages reaches its speed (JIT is just marvellous). So, by the time you'll be searching a job, perhaps C++ will be outdated (or not... We'll see if C++0x will keep its promises).

My take: If you're the kind of people who like programming, and would do it on their own time, for pleasure, then do C, and then move to C++, Java and C#. If for you, programming is just a job, and the idea of trying this new feature or new language is kinda alien for you, move to the practical, and learn Java and stick to it.

paercebal
"C developer trying to tell you how much his language is better than yours, because it is faster (usually a lie), and better (lie, again).)": It is faster and it is better for **certain** problems.
Partial
"With C, (as with C++), standard libraries are so poor": Do you have some sources or some arguments to explain that statement?
Partial
@Partial : "It is faster and it is better for certain problems". Python is faster and better for certain problems, too...
paercebal
@Partial : "[With C, (as with C++), standard libraries are so poor] Do you have some sources or some arguments to explain that statement?" : Please compare the STL and Java's or C# standard set of libraries. Even if we add Boost to the STL (and Boost is NOT a standard library, even if it is a must for all C++ code), the result is still poor compared to Java or C# standard library. The most blatant example: Want a GUI on Java? Use Swing. On C++... er... Look at QT, GTKmm, which are NOT standards.
paercebal
@paercebal: C++ is faster because it is a lower level programming language than Python, Java, C# and many other languages. Also, C++ is most suitable for certain problems like every language out there. I wanted to point out that C/C++ can be better for certain situations. Why would it be a lie that C/C++ is better for certain problems?
Partial
@paercebal: Java is bloated with libraries and has a GUI framework called Swing. So what? C++ does not have that burden. What comes standard with C++ are efficient libraries. If you want to do some GUI with C++ you go get a framework that best suites your needs. You could do some MFC for Windows, some gtkmm for a Unix based OS or Qt for a cross-platform GUI. It will enable you to create a faster GUI than what is possible with Java. The price for performance is the time it will take to develop the application. This sacrifice can be justified.
Partial
@Partial: First, I should say that I prefer C++ to Java or C#. Still when you write "Java is bloated with libraries" you can call it as you like, Java has a full, complete STANDARD library. The word "STANDARD" was the one you overlooked.
paercebal
@Partial: As for the "speed thing", don't forget, "Premature Optimization is the root of all evil". Most GUI applications don't need the supposed full raw power of C or C++, and will work as fast on C# and Java, and will be coded magnitude faster. Please read http://www.codinghorror.com/blog/2005/05/on-managed-code-performance-again.html if you want an example by people who know a lot more than you and me...
paercebal
@paercebal: Okay, Java makes it a **STANDARD** of having a full set of bloated libraries! Sorry for overlooking that word. I invite you to have a look at these links: http://www.jelovic.com/articles/why_java_is_slow.htm and http://www.jelovic.com/articles/java_good_bad.htm (have a look at #7). The link you posted means nothing. Not to mention the article is referring to Visual C++. VC++ 6.0 was created 4 years before C# 1.0 was out and the technologies at the time of the creation of VC++ 1.0 to 6.0 were unlike what is available today. I would like to see VC++ 10.0 and C# 4.0 instead.
Partial
@Partial: So we agree that, whatever its quality, Java has a STANDARD library which is more complete than C++. Now, if you want to discuss the quality of Java's standard library, or the speed comparison between C, C++, Java and C#, I invite you to ask your own SO question, because this is now out of topic, as far as the current question and my answer are concerned. Thank you.
paercebal
@paercebal: The amount of libraries in Java's STANDARD is not the only factor to make it complete. The quality of these libraries is something you should weigh in before saying that the STANDARD of Java is more complete than the one of C++. In terms of quality, you can not argue that what comes standard with C++ is quality!
Partial
@Partial: Err... What word in the sentence "Now, if you want to discuss the quality of Java's standard library, or the speed comparison between C, C++, Java and C#, I invite you to ask your own SO question" you didn't understand ?
paercebal
And what about: "The quality of these libraries is something you should weigh in" the balance of how complete a standard library is? I am still in the same subject here! And I do not need to ask a question on something I already know.
Partial
@Partial: I won't change MY answer just because of YOUR viewpoint. You failed to convince me, sorry. So deal with it. Be constructive. Instead of debating in comments, please contribute to SO and provide a complete answer to the current question, with links, references, etc.. Thank you.
paercebal
All of this started because you wrote that it was usually a lie that C was faster and that it is a lie that C is not better than other languages. Also, you wrote that that C/C++ had poor standard libraries. I am giving my OPINION on your answer in comments. I will even clarify what I am trying to say by being more direct. Your answer is not impersonal enough, from my point of view, to make it a constructive and a valid answer. Not to mention that you do not have compelling facts explaining why C/C++ or Java would be a good or bad idea!
Partial
Now you are telling me to create a new question asking about performance issues between C/C++ and Java. Again, from my point of view, this is only more evidence of the weakness of your arguments in your answer! Let me quote you: "because it is faster (**usually a lie**), and better (**lie, again**)", "with C, (as with C++), standard libraries are so **poor** it is an **eternal source of frustration** ", "Java (or C#, for they are of the same language family) is quite efficient, and now are **able to reach efficiency level of C/C++** in code execution" and I could continue on!
Partial
You even state your ignorance on the subject: "So, if you do a C GUI program on Linux, and want to see it executed on Windows, you'll have to learn some tricks (I did not have the patience)". You contradict yourself when you said that Java is now able to reach efficiency levels of C/C++: "Now, Java is no silver bullet. Sometimes, it can just be slow, and some processing will have to be done in C or C++ through JNI bindings."
Partial
Do you want me to be even more constructive?
Partial
@Partial: I can believe you wrote 11 comments just to express your disagreement. Impressive... :-D ... As I am a very patient and agreeable guy, I'll repeat again: Please, if you disagree with my answer, please please please downmod me. Or be more constructive and provide your own answer, or even ask you own question.
paercebal
(I can't believe I begged some random guy to downmod me...)... :-D
paercebal
@paercebal: I am pointing out the aspects of your answer that are subjective, need explanations or need some sources. I have provided my own answer if you would condescend to read it. How is this not constructive to you?
Partial
+3  A: 

I'd also vote for C. I know Java "better", I like it more & am a big fan of it's object oriented nature but...

Even with all that said I wish I payed more attention to C in my college courses. Yes, it is a pain in the ass to understand some of the pointer and reference stuff but once you get a grip on all that you're way better off. Those lessons and experiences will pay off if/when you move on to other languages.

C helps you "understand" what's going on under the hood. When you deal with performance and scalability stuff later on you'll be thankful to have that knowledge.

arin sarkissian
+2  A: 

I have taught a variety of introductory and advanced courses, and here are my two cents, all under the assumption that you are already taking the all-important principles of CS course (data structures, algorithms, complexity, etc.)

The choice between C (or C++) and Java will ultimately depends on what you intend to do with them, and if you intend to work in the industry also on the companies that you are targeting.

If you are going to work on higher level things (GUIs, web based software, large scale interactive systems, etc.) Java (or C#) may be your better choice because it does hide all the details of the underlying computer system from you. You are "sandboxed" within the virtual machine, exceptions are always thrown, memory is managed for you, compilation and distribution is easier, etc. Java is a good entry point for all the "sandboxed" languages out there, including, for example, Flash programming.

If you are going to work on low-level things where you may want to interface with the hardware (e.g., device drivers, OS extensions, embedded systems) or just manage things efficiently and manually, you would want to focus on C and C++. Both languages in my opinion are more difficult to learn and use than Java because they not only require you to manage your own memory but also to master the art of the pointer. In some cases, it may be a headache.

In my humble opinion every "real" computer scientist and top programmer needs to understand and be capable of practicing the entire from low-level assembly language and hardware-specific optimizations to higher-level languages. In practice, if you're just seking to be able to do stuff, weigh carefully what it is that you want to do and pick accordingly.

Uri
A: 

At my university (this was in 2000) I started my Computer Science Degree learning Java. The university had JUST switched from teaching all their courses in C to teaching them in Java, since Java was (as I understand it) starting to become more popular / wanted.

Well, when I say all classes, that is a little misleading. The intro classes were in Java, the 200+ level courses were taught with C examples (since those in those classes started out learning C). The professors usually didn't care if you turned your work in C, Java, etc as long as it worked -- but all discussion and examples in the class were in C. I made it a point to take an intro course in C. It was a course taught to regular engineers, not computer science engineers, so it was really, really, really basic. But it was enough for me to be able to better understand what was being discussed in my higher courses. (I find I learn better in a structured environment, which was why I took the course instead of teaching myself, not to mention the easy A).

So for me taking Java first and then C worked out ok. But as others have mentioned, pointers will hang you up. I personally think that both languages are good starters to learn; C is more functional and Java is Object Oriented. However don't get too hung up on learning a particular language -- a good programmer can program in any language. If you've time and able, I'd look into taking an assembly class as well -- I loved my assembly class and got a lot of good from it.

And while I currently do mostly web development, a lot of the job ads I've seen recently want you to have experience in C. Web development tends towards Java.

Personally if I were to do it all over again I'd have taken C first and THEN Java. I got hung up a bit at first because I was used to being able to do STRING xyz in java and myobject.do_something, and C really doesn't have Strings. Strings are merely arrays of characters in C.

Leanan
+2  A: 

If you have the time and willpower, I suggest you learn C first. Many answers here suggest that you should avoid C because of its pointers, arrays, lack of explicit support for OO, and crashes when you do something wrong. I disagree. You have to become comfortable with pointers, arrays, strings, experience the pain of emulating objects, and understand what happens in memory, and how stuff works. Treat this as a mental exercise that helps you understand how computers work in general.

Once you are comfortable with C and all of its nitty-gritty, then you can move to Java/C# and actually appreciate all what they have to offer over C and even C++. The time you invest in C will help you be a better/efficient developer in any other declarative language.

Alexander
A: 

I'd go with Java. I personally started with C, and while it's a wonderful languages for learning how computers work on a lower level (memory management, pointer arithmetic, and other horrors), much of your work would involve creating your own abstraction layers to make up for the language's bare-bones nature. You'd write lists, strings, and other data structures and types just to get to the point where you could start solving the problem at hand.

Some people would consider this a good thing; writing your own doubly-linked list and string ADTs are something every programmer should know. And while you could do that in Java, being responsible for your own memory management and dangling pointers can be a good experience.

Thing is, though, I favor a top down approach to learning things, especially when starting from the bottom teaches you habits that are hard to change. A lot of C programmers who move on to learn new languages still think in C, and it takes time for them to make use of new language features. I know one college where Computer Science undergraduates start with SmallTalk, then Java, and finally C in their second or third year. That seems logical to me; higher level languages help you think in terms of the problem you're solving instead of thinking how the computer would process it.

I'm not sure about taking them concurrently, it depends on your way of learning things. It might be useful to compare the two languages at the same time, and depending on the pace it could help you understand each of them better. Or it could be too much for you to handle and keep up with the different language paradigms, and you'd end up not really understanding either because you didn't give them enough time to be appreciated on their own.

You should definitely not skip C altogether if you learn Java and is serious about programming. You may be able to do that with C++, but to be a good Java programmer you need to understand what happens under the hood. That's why you might also consider taking an assembly course at one point (even if it's pretty useless in real world).

Whatever you decide to do, good luck! :)

Firas Assaad
+2  A: 

In my experience, learning c/c++ first helped get the fundamentals of programming. I realized a few semesters later that the language you learn is not as important as the programming logic. As long as you grasp the essence of programming, you will only have to adapt it to the syntax of the programming language you want/have to use.

isc_fausto
A: 

I learned Java first. Now that I think about it, my interest in programming was on a steady decline until I ditched those perilous Java courses and instead took some low-level systems courses. There, I was introduced to C and assembler. When it was time to go finish up those data structures courses in Java, it was a very smooth transition.

My advise: Since you're just beginning to learn about general programming concepts, either take Java first or take them both at the same time. There is absolutely no reason not to take them concurrently, but I think being patient and learning longitudinally would be more valuable.

I know many would object to this heresy I'm about to say, but: Don't take C first. (unless its accompanied with an architecture or operating systems focus).

+1  A: 

I would lean toward C (not even C++). In fact, a great course (FREE) is provided online by Harvard at http://www.cs50.tv

Plus, knowing C will make you that much stronger in other languages such as Java, Objective C once you learn them too.

Cheers!

Justin Plants

Justin Plants
+1  A: 

I would like to start off by saying that C and Java are programming languages that are too different to pick either one or the other. Most concepts from each language are not found in the other. Of course you can learn the basics of programming in each like conditional statements, loops, etc. The problem you will quickly find is how limited you are in both of these languages.

In C you will be limited to imperative (or procedural) programming and perhaps an introduction to OOP with structured programming and in Java you will be limited by the philosophy of the language. By philosophy I mean the decisions taken by its developers on the core of the language. Java's paradigm is object-oriented, structured and imperative. Note that Java contains within itself the paradigm of C but you will be using a lot more object oriented programming than anything else.

What about that philosophy of Java? Java will limit what you can do for safety reasons. Unlike C, in Java you can not play directly with the memory of the system (like pointers) because its creators believe it is unsafe. Instead, Java has a lot of wrapping over memory management to do it for you with concepts such as garbage collection. Another limited feature would be inheritance. It is impossible to do multiple inheritance in Java. The reason for that is that programmers could do silly mistakes because it might become too complicated for them to handle. In a way, this is good because you need to think of your concept before anything else (like the use of interfaces), but it is also bad because it limits the architectural design of an application.

With all of this being said, I would suggest neither of these languages has a first programming language. I would prefer suggesting an alternative which is C++. You will find in this programming language the concepts of both C and Java, and more! Let me explain that for you...

The C++ language is based upon C and is a multiple paradigm language. You will find procedural, object-oriented and generic programming. This language is complex, but in return will give you a certain mindset for the future. In other words, you will be free in the jungle with this language and it might bite back in unexpected ways if you do not know what you are doing, but the knowledge that will come with it is priceless. Once you understand the mechanics and concepts behind C++ you will be able to apply your knowledge to other languages. I believe the complexity of the language will not pose a problem. Like any other language, you must start from the beginning and follow certain steps to understand. In the case of C++ you might need more steps but it will be useful in the end. You will see memory management like in C, you will find object-oriented programming like in Java and you will be able to see templates which is not present in those programming languages. What is also great is that you can mix all of those concepts together. To continue, C++ is available on many platforms like C and Java! You will be able to develop on your favorite operating system that it be Windows, Mac OS, one of the various distributions of Linux, etc. It is also possible to create a portable application with C++. You can particular idioms that are available only for C/C++ or to very little other languages. Certain idioms come to mind such as pimpl and RAII.

I know that C++ is not offered at your college has an introductory course and this should not stop you from learning it. Pick a course that you will like and learn when you have free time some C++. You can find some tutorials online, but the best way is probably to buy a few books on the subject. After, I firmly believe that you should take some C++ courses.

If you wish to learn Objective-C, C++ will be precious. Just like C++, Objective-C is based on C. What is even greater is that Apple's Objective-C compiler allows you to freely mix some C++!

If you do not understand certain terms or explanations, please, feel free to ask any question!

Partial
A: 

You have already determined you need to use XHTML, CSS, JavaScript, PHP, XML, ActionScript. Why not learn these languages? JavaScript shouldn't be confused with Java.

IMHO, The languages you describe as so different to Java or C you are likely to learn alot, but not use 90% of that knowledge. If you don't use it you will forget it. Don't assume that any knowledge is good for you.

There are views here that "Real Programmers" learn C first. Following this logic, you should just start with machine language and not use a compiler or a proper editor until you understand what is Really Going On (TM) like I did ;) And I can tell you that 90%+ of it will be a waste of your time.

Peter Lawrey
A: 

C - You'll learn a lot more about underlying, fundamental concepts. You'll need to learn them sometime, if you want to stay and advance in the programming field, and it's better to learn them early so you can apply them as necessary for the other languages you learn.

Java - Is more productive for actually doing most programming projects. But as a student, your focus is not on getting the most features working per time spent programming; it should be on understanding what can be done, how, and why.

So for the choices you presented, I'd recommend C as a start. Even better, though, if available, would be Scheme, Lisp, Erlang, or something similar. You'll be able to focus more on data structures and algorithms, less on the particular language's syntax. Once you've got a decent understanding of programming concepts (especially indirection and recursion, since they are frequently the most difficult to get), then take a C class for better understanding of how the machine works. By that time, you'll have also picked up a scripting language (e.g., Python, Ruby) or two and be able to be productive with other language syntaxes in short order.

mpez0
A: 

What I want to do is learn a complex language so that I can apply that knowledge to languages that I use, or will eventually use, in my current job building web pages: XHTML, CSS, JavaScript, PHP, XML, ActionScript.

I think you don't need to learn either! Since, you told you'd only need to use javascript/actionscript/php. You should start learning them directly. It would be better if you could contact with a person who knows these languages well and teach you. Forget about theory and 'complex language'. You don't want to be Alexandrescu do you? But yes, learning doesn't hurt, except you've time constraints.

Sazzad
A: 

It is not necessary for anyone building web pages to learn C. It's just not. Heck, for a great deal of 'web jobs' it's not necessary.

It absolutely is necessary if you want to be able to talk about computers with anyone who actually understands how they work. It is if you're going to build good, stable software. It is if you're going to need to understand how to do useful things in a Unix/Linux environment and those are much easier to understand if you understand 'C'. It is if you are going to do any robotics, medical devices, aircraft controls, video game development, satellite systems, etc.( it's unavoidable, in fact, if you go into those fields and try to tell MOST of the people who DO understand 'low-level' concepts - Ancient Geeks, for example, though many of us young 'uns are wising up now - why they should be using embedded java....be prepared to be laughed out of the building and dismissed as entirely ignorant ( rightly )).

But for work that, at most, requires you understand and can use a scripting language? Don't burden yourself paying for and being over-whelmed by a 'C' course in college. Don't worry about wether something's 'procedural' or OOP, because these concepts just won't matter to a web designer as much as a software engineer or firmware engineer or hardware engineer for that matter.

DISCLAIMER: Yes, I realize the OP long ago made their choice given they posted the question in 2008, but thought, perhaps, the answer may be helpful to the next novice trying to figure out if they should fry their brain right away on C, or wait a while.

Skip