tags:

views:

5297

answers:

13

Many of my friends who are graduating from college ask me, "should I learn Java or C++? Which will help me in the long run?"

Both languages have their merits and demerits, but what would you guys suggest these college graduates learn?

I am sure there is no correct answer for this question, but I would like to get the community opinion on this.

+17  A: 

They are graduating from college and don't know Java or C++? Surely, these are not computer science majors right? The answer is clearly "both." Despite what many will see, I think not knowing C and C++ (which are not the same thing) is an impediment. I think all programmers should have a working knowledge of C and C++. And of course, knowing Java is important. I think to be a good programmer, you really need to have a catalog of languages.

BobbyShaftoe
I would argue that C and C++ are so radically different now that they should no longer be dumped together. Knowing C does not mean you can program in C++.
Martin York
Well, yeah I wouldn't suggest that they are. However, I think once you learn C, you should go on to understand C++. Both languages represent a huge portion of the code that exists out in the world.
BobbyShaftoe
COBOL represents a huge portion of the code that exists out in the world but I don't think anyone would recommend learning it at this point.
tster
I don't think you can compare COBOL to C. Most of the things you use are ultimately running off of some C or possibly C++ code base (be it the compiler for your choice of language, the operating systems you use, and many, many other applications). The same cannot be said for COBOL.
BobbyShaftoe
I always felt C++ should have been called D (besides the syntax they are basically different languages)
Itsik
+1  A: 

Why should your graduating friends know either Java or C++? I can't see any reason for it. If they have chosen fields of endeavor, they should learn whatever their future colleagues will be using. On Wall Street that might be APL or Smalltalk (or Excel). In biology it will probably be Perl. Do physicists still use FORTRAN or have they switched to C++?

If they just want to understand computers, they should learn C++ because it is less magical, but it would be even better to learn C. As a bonus, if you start from zero C is much easier to learn than C++.

If they just want to learn some programming they should learn a well-designed scripting language like Lua, Ruby, or Python. Not Perl.

Norman Ramsey
if you learn c first you'll always programm c++ like a c programmer. Be carefull with that one. The language you work with most will form the way you think, and the way you progame in other langs. (avoidance takes time and practice)
baash05
well said, baash05.
Adeel Ansari
I learned C before C++ (and Java before C), and I do not believe that I will always program C++ like a C programmer. I'm not sure I currently program C++ like a C programmer. The first real language I learned was Perl, and I sure don't program C like a Perl programmer.
Steve Jessop
baash05, I know exactly what you mean. It took me a couple of years to break C habits and fully embrace C++ idioms. Now, if I can just the rest of my team to do the same ;-)
Ferruccio
"always" is a little strong. I learned assembler first. Then BASIC and C. Fortran, etc. Years later I taught myself C++. I've now been programming in Java for 8 years. I think that I've gotten past "writing C in C++".
Darron
For heaven's sake, if you want to learn OO learn Smalltalk or Simula-67. Learn C to be close to the machine. C++ is a chimera intended to be all things to all programmers working in 1985.
Norman Ramsey
+3  A: 

It depends on what they want to do. If they're going into IT then Java or C# is a reasonable choice. If they're going to write device drivers, then C is better. If they're going into game development, then C or C++ is probably better than Java. Those are just examples to make the general point that the language or languages they'll need depend on their goals.

Willie Wheeler
If they're going into IT, Python, Perl, and Ruby are better choices. In IT, you'll typically be writing glue code, data munging, and formatting reports from DB queries. The thing that matters most is completing tasks quickly. Scripting languages are better tools for this.
ceretullis
I can agree to a point--I definitely see this as being the direction the industry is going, as opposed to doing heavy in-house development. However where I work (and it's an IT shop) we do in fact do quite a bit of development. The teams are Java/.NET teams.
Willie Wheeler
+9  A: 

You mean they don't know what they should learn. Surprising! surely, they are driven by job market. So, it depends what is hot at the time of their graduation. My suggestions to date,

  • C is a must, IMO.
  • OOP is another good. Java or C# is a better candidate here. C++ yeah its worth to know it
  • Dynamic languages are another helpful thing. I would recommend Python and JavaScript
  • Functional programming, you must taste it, at least its fun. Haskell is good here
  • Common Lisp, for my love sake
Adeel Ansari
I agree that C is a must. Even places where you are not going to write C will ask you C questions in the interview. They want to see if you understand pointers and arrays and basics like that and C is the most widely understood language for that.
tster
+1 For mentioning C as 'a must'.
Andrei Ciobanu
+5  A: 

In the long run what language you learn first makes no real difference (mine was BASIC as was common among many in my generation and I survived)

  • It's the concepts you pickup that are important
  • And any bad habits your programming langauge of choice encourages

But that said, given a choice of either c++ or Java, either is a good choice. Java is probably easier to pickup as it has less legacy stuff like pointers and memory freeing and is probably less likely to get you into trouble bad habit wise

Maybe visual basic or c# would also be good choices (visual basic is supposed to be the worlds most known programming language due to its use as a scripting language in various apps)

Long term being exposed to many different languages is more valuable

  • the long winded but interesting record handling of COBOL
  • the low level power of various assemblers (RISC and CISC ideally)
  • object models of C++ and JAVA
  • the interesting threading constructs of ADA
  • the massively parallel ideals of OCCAM
  • the elegant simplicity of some solutions in functional langages such as LISP or ErLang(?)
  • modern extensions such as lambda functions in Ruby or c#
  • the interactivity of scripting languages such as Perl, ksh and powershell
  • and even the specialized shader languages used with a lot of todays graphics hardware
love this answer
baash05
+3  A: 

C++ is a language that supports many programming paradigms. First, procedural programming like in C, object oriented programming like in Java, a fence of functional programming (and soon including lambda expressions) and generic and generative programming like what you've not seen before (current draft is 1340 pages long). For this reason, i wouldn't recommend C++ to a newcomer (people that hardly knows some computer language already). You should probably first learn one of Java or C# which enforce some OOP style of programming and are quite popular (so you have a big community if you have questions).

If you have learned a language, then you could get your hands on C++, which allows you to do nearly everything you want, including shooting yourself in the foot. I'm myself a big fan of C++, but i also see its inherent danger to newcomers, indeed. It has big power to someone knowing how to use it to build amazingly fast applications, still making clean interfaces and class hierarchies.

But this all is no reason you should only learn one of them. It makes quite a lot of sense to learn both of them, as others stated, or even more languages. So for example you see how the strict object oriented language Java copes with the not so strict language C# (including lambda and linq). It doesn't have to mean bad stuff if some language includes fewer possibilities. It's the way the language makes use of them and how these features integrate as a whole into it.

Assuming they ask for themself, i think i agree with BobbyShaftone. Someone coming from college, possibly having graduated in CS, should really know C++ and Java.

Johannes Schaub - litb
A: 

Learning languages takes time.

So your friends should ask themselves how much time they want to invest in learning languages, and what for...

Do they want something easy, fast and powerful. They should learn Java, or C#. With their gigantic standard library, they'll be able to write almost any application but for some very limited cases. C# has more features, but for now, I feel more confortable with Java's write once, run everywhere than C#'s "hey, you have Mono on Linux, too"...

But Java won't give them familiarity about things work under the covers. For that, familiarity with C and C++ is a good start. By own experience with C++ is that most C-like languages comes easily once you have average expertise with C++. The opposite cannot be said.

So, if they want to learn a language to do things for a living, Java (or C#) is a good choice. If they want to go deeper, and are willing to invest time (including personal time) to learn, starting from C, and then moving to C++ would be a good idea (the transition from C to C++ is not always smooth, so be prepared to unlearn some C concept when moving to C++).

paercebal
A: 

A college graduate should know either Java or C++ really well. At least, if it is a reputable school...

However, I would recommend that C++ be learned if they don't know C. You need to know your memory model to really understand your tool.

If they have a solid machine background, but not so hot at the VM world, Java is a decent choice.

However, I would suggest that the most employable language today is C#, and probably the easiest to work with.

Paul Nathan
A: 

C is procedural language. C++ is a good blend of both Procedural and Object Oriented. C# is very abstract leaning heavily on both Object Oriented and the .NET framework. Java is also very abstract and leans heavily on Oject Oriented processing. By going directly into Object Oriented programming you will miss some basic concepts and also may find the learning curve difficult and frustrating.

You want to walk before you run so if you have no programming experience start with C. If you have programming experience such as Pascal, Fortran, Assembler, PL1, Cobol etc then move to c++ and then on to C# and or Java.

Just my way of doing the carrer path.

A: 

It depends on what field they are going into. If they're going into a standard business shop, then, based on my experience to date, knowing C++ isn't really going to help. 90-99% of applications needed for internal use by a business or external use as a provided service don't require the level of control or system knowledge given by C++. If this is the field they are going into, I'd recommend Java or C#.

Now, that said, every shop is different; and knowing how C and/or C++ works will be worthwhile, if only to get rid of magical thinking.

CoderTao
A: 

For those who are still interested in this question, I recommend reading the following paper from adacore.com:

A principled approach to software engineering

Thursday February 5, 2009

This paper examines the use of Java as a first programming language, in the light of well-established principles of software engineering, and the increasing concern with correctness, performance, and maintainability. We argue that Java is markedly inferior to Ada or C++ as a language for introductory Computer Science courses, and that its widespread use in the training of tomorrow’s software engineers is counterproductive.

Sergiy
A: 

You can't learn to program if you don't know how to correctly handle your memory allocations. So don't start with Java, it'll just leave to confusion later. Imagine using a string class in Java, then switching to C++ and having to remember to call delete when you're done with it.

Mark Ingram
A: 

You should ask yourself, why are you trying to learn a language,

  • Is it to get a job? I suggest Java may have more jobs in your area than C++, but learning both is better.
  • Is it for general knowledge? If so learn both and many more.
  • Is it to find a cool, fun language? If so, neither are a good choice. There are plenty of cooler lanugages to learn.
Peter Lawrey