how alike is java and c++

Started by
1 comment, last by JWalsh 17 years, 6 months ago
how alike is java and c++? if you learn java, are you automatically kinda learning c++ at the same time?
Advertisement
Eh.

It's like learning to play baseball, and then playing football. Some of the things carry over, but not directly: running pass routes is different from baserunning; and not specific to either: if you played soccer instead of baseball you'd still be better equipped for football than if you did nothing at all.
Programming languages are essentially made up of two components: syntax and semantics. Syntax are the actual rules about what you can place where - in order for it to be considered a valid program. Semantics are more the logistics and feature sets of the language.

Both C++ and Java are based on the C Programming language and as a result share similar syntax. There are a few divergences as Java was created more recently and is thus a "slightly" higher level language. Which just means it provides some niceties like a for-each style construct, imports without having to use include files, etc...but in general, the syntax of one is sufficient to give you a good head start in using the syntax of the other.

Additionally, both are object oriented languages with classes, inheritance, branching, looping, and functions. So as with before, learning the semantics of one will give you a head start in learning the semantics of the other. With that being said, Java is a bit more "object oriented" than C++, and does not support (does not allow) things such as globals. Everything must be contained within a class. As well, Java has built in memory management and garbage collection, where C++ requires you to do all of your own memory management.

Ultimately, the two languages are very similar, but are in fact, different languages. Learning one will definitely give you a leg up when learning the other, and the learning curve will be dramatically decreased. However, learning one doesn’t automatically mean you know the other.

In the end, I encourage you to learn as many modern languages as you can. It makes you more marketable, and gives you a better understanding of the intricacies of language design, and the strong and weak points of the languages you work with.

No language is a silver bullet, but how do you know which language is best suited to a task if you only know one language?

Cheers!
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints

This topic is closed to new replies.

Advertisement