Skip to main content

Command Palette

Search for a command to run...

Java or C++? Things to consider when starting your DSA journey.

here's why Java is better

Published
2 min read
Java or C++? Things to consider when starting your DSA journey.
H

• 20-year-old CompSci student learning in public•🐢

Before deciding on the appropriate language, consider the path you wish to go in the future.

People tend to use CPP for competitive programming because it is faster and does not force object-oriented programming, among a few reasons.

Java, on the other, is a widely used language from a career prospect.

If you are a beginner, I'd suggest taking Java as your language before moving along the Data Structures path.

Here are a few reasons why:-

  • My own experience has been that Java is more legible and understandable. I wouldn't introduce an early student to C++'s more complex pointer semantics and memory management ideas. I was able to take up C++ very quickly after being proficient in Java, but going the other way would have been impossible for me.

  • Java has inbuilt libraries for many data structures like Priority Queues, Stacks, Vectors which might take more time to implement in C++.

  • Java allows you to take up open source and development early on, which in my opinion, are much safer options as they provide more opportunities as compared to competitive programming. This approach also allows you to earn money, and if you are in college, it will help a lot. The ambiguity with CP is not something I can recommend; you might make it or not. Java with the open-source options is a less risky strategy.

To sum up, for its beginner-friendly style, easy to learn approach, excellent career prospects and opportunities, Java is the language to go for when starting as a developer.

In no way I am saying that CPP is inferior, you will have to learn and use it in future, but to start on your coding journey, I'd suggest Java.

I am presently on my course to comprehend Data Structures and Algorithms. Learning in public is also something I am focusing on. If you want to follow along, connect with me on Twitter.

S

I have learnt C++ so should I learn java for DSA ?

H
Harsh4y ago

if you're already well versed with CPP, go for DSA in that language only. The use of pointers and the lack of inbuilt libraries in CPP will actually improve your basics of the topic, that's why I said Java is beginner-friendly but I don't think you'll have any issues. Go for it without any fear, I wish you well.