Sign in to follow this  

how alike is java and c++

Recommended Posts


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.

Share this post

Link to post
Share on other sites
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?


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this