Learning C++ for Java Programmers?
The Real Joe Faith asks: "The O'Reilly book 'Java in a Nutshell' used to include a really handy introduction to Java specifically aimed at C++ programmers. It meant an experienced programmer could re-use their knowledge and get up to speed quickly. But what about going the other way? I know a fair amount of Java but, for my sins, have always avoided C++. Now I need to learn it. Fast. Not just the syntax, but also about the various standard libraries out there. Now that Java is the standard language on most computer science courses I guess there will be a few people in the same boat. Can anyone recommend a good book (or any other information source)?" For those Java programmers among us who have gone this route, what books did you use to assist you in the transition to C++? How well did these books work for you?
That's probably because C++ isn't object-oriented. It's object capable, and probably better programmed in a generic style.
Anyway, if you want to learn C++ fast, I suggest getting a couple good books, a lot of coffee, and a compiler. It'll take a short year or so, but it's completely worth it.
This is not a flame - I'm a C++ fan. It's my favorite language. But if you think you can learn it well in less than a year, you're kidding yourself.
Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
STL is MORE than important. Learning all about the STL is an activity that should occupy the time period from 1 to 1.5 years after a person starts learning C++.
Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
Please don't code anything in C++ after learning it "fast." It's not that kind of language.
My learning went from assembly ==> C ==> C++ ==> Java, and my advice to you is to not go from Java to C++. If you remember venn diagrams, imagine one circle as Java, Then draw circle next to it without intersection and call that one C. Now draw a circle that intersects Java and C, but also has its own distinct characteristics, and that circle would be C++. There is no way to learn C++ without learning C. If I were you, I'd learn C. Then once you learn C, your OO knowledge will make you question some things. Then C++ will make sense to bridge that gap. Learning C++, or C for that matter, is not going to be fast. And anyone who does learn it fast will be in trouble unless they're really talented. One thing is for sure, once you learn C/C++ you will REALLY appreciate Java. Good Luck.
mp3's are only for those with bad memories
Just be confident knowing that most of your basic skills will transfer, and get a normal C++ book. Personally, I recommend Stroustroup's book, and Dietel and Dietel is an oft used text. Most of those "Learn C++ in 24 Hours!" types of books are a waste of trees. Like others have said, it's crucial that you get something that covers STL (both the ones I mentioned will). It's C++'s version of a class library. You'll find it a little thin after working in Java, and that's where platform specific stuff enters the picture. You'll find most of your time is learning a new widget set (presuming you need GUI programming), or socket APIs (if you need 'em), or platform specific threading/synchronization etc.
Overall, coming from Java, you won't expect or know how to use fancy language features. That's Ok. Write C++ like you would Java (mmm, careful about that memory leak though). This assumes you're doing app development where you can afford to make every function virtual, every object a reference, and have accessor functions for every member variable. If that's not what you're up to and you need write tight C++, well, forget Java while you learn C++. Make sure you get your memory models straight--stack vs heap, by value and by reference, pointers vs reference, iterators vs pointers, reference counted, and on and on. You have to get the now classic "Effective C++" books by Scott Meyers. That's the best way to avoid classic stupid C++ mistakes. You'll find it a bit heavy going at first, but until it makes sense to you, you're probably writing bad C++. Good luck.
oop is a good solution. by no means the best, but good. the thing is certain problems are inherintly procedural, some are functional, others are oop, a few are logical, and even aspect oriented. the point is easy programming methodology has a use and as such should be applied where that use is best. if you told all AI programmers to stop coding and lisp and redo it all in C, they'd laugh at you.
computer science 101: pick the right tool for the job.
- tristan
I am sorry, I am a bit confused by your argument. Move away from C++ to what exactly. The only other languages you mentioned where Perl, Python, Ruby, or Scheme. I have yet to use Ruby or Scheme, but I did look up some things on them.
Most of those languages are scripting lanugages and aren't really what you'd program a major application in. I know I user perl for sys admin tasks and quick hacks to just 'get things done'
If you're going to beat up on C++ tell them to move away give a decent language to move to. And you never explained what Java had that C++ doesn't.
Please tell me why I want to move away from a language such a C++ or even its predecessor C. Those languages are solid, and fast. You can do most anything with them. And the cleanliness of the program is left to the programmer, so if you develope bad practices you'll write bad code. If done propertly I see nothing wrong with using C++.
Here's (on the top of head) what comes to mind when I think ab out moving from Java to C++:
In C++ you can place objects on the stack with no need to allocate an object on the heap.
The book my Koeing and Barbara Moo, Accelerated C++, is an excellent starting point in my oppinion. If you have previous programming experience, i suggest you pick this up, rather than a 500 page primer. It goes through a lot of stuff and a suprising rate. It also teaches you some basic algo's and uses STL right from the start, not the sort of backward teaching some other books use. It's very good, and i suggest you pick it up. You might also try Bruce Ekels Thinking In C++, they can be found for free (both volumes) on his site. Simply google the title and it will take you there.
objective-c is definitely NOT what C++ should've been. Smalltalk isn't what it shouldn't have been either, as arkane, and provincial as most other languages born of the 70's. C++ is reviled by java zealots and "alternative" object-ish languages alike because of your fundamental idiosyncratic failure to grasp even the most fundamental concept of power.
"With great power, comes greater responsibility".
Didn't ANY of you ever read Spider-Man ?
Part of why the current crop of developers has so much "faith" in java is because academia itself didn't see "fit" to teach principals of object-oriented programming in a language that they themselves didn't quite "get". Don't believe me, just ask how many CompSci majors are truly exposed to 'C', much less C++, by the time they're in their senior year in college.