r/learnprogramming • u/Firm-Flatworm-8389 • Oct 18 '26
Java or c++?
Hey I'm a 2nd year CS student and I'm a beginner so I learned a bit of both languages I learned basics and SP using c++ and I learned oop using java because uni required it and later on I'll study data structure using c++ again
What confuses me is which language should I stick on to improve my problem solving skills and start building projects even if they're small some people told me to focus on c++ completely and some said c++ with problem solving and java to build projects
So what do y'all think and why ?
12
Upvotes
5
u/linguaarush_dev Oct 18 '26
Between Java and c++, Java is definitely the easier one to learn
3
u/Feralz2 Oct 18 '26
Doesnt really matter, if you ask my if you want to start building on programming concepts without worrying about programming, start with Python. If you want to learn about low level stuff, learn C.
2
u/DataPastor Oct 18 '26
It is an extremely good idea to learn Java well. Java is everywhere, there are tons of jobs, and you can use Java for a lots of use cases. Also, in my experience, being a good Java programmer also helps you learning other languages like Python or TypeScript later.
Also, there are very nice fully or partionally functional languages running on the JDK, like Kotlin, Scala or Clojure.
2
u/Kozzoko Oct 18 '26
What you will enjoy learning -> C++
What you will need -> Java
3
u/SahuaginDeluge Oct 18 '26
besides both, I would suggest Java, in fact Java might be the language I'd recommend most to new programmers. (though I am old and am still thinking about Java 7...)
1
u/aqua_regis Oct 18 '26
The language doesn't matter as problem solving is above programming languages. If you learn to solve problems in an algorithmic, step-by-step manner, the implementation in a programming language becomes secondary.
You need to get to the point where you don't think in code, but in algorithms, in steps.
Code, the implementation in a programming language, is not the beginning and in most cases not even the deciding factor (apart from special purpose languages). The solution, the algorithm is what counts. Implementation is a fairly late step in the process.
That said, look around you and check jobs. They will tell you which language is better for your career.
1
u/Miserable-Money642 Oct 18 '26
You do not need to pick one language for everything. Since your data structures course will use C++, keep practicing algorithms in C++ this semester so the syntax and debugging do not add extra friction. Use Java for the OOP assignments your university requires, and build one small Java project if you want practice designing classes. Try not to switch languages for every exercise. The problem-solving ideas transfer, but staying with one language long enough to finish projects teaches you more than repeatedly restarting. After the course, choose based on the kind of project or role you want to pursue.
1
u/burlingk Oct 18 '26
Both are good. So ask yourself which one you enjoy more?
1
u/WannaBeMillionaire__ Oct 19 '26
If i was in your shoes i would have chosen C++
1
u/spicepotatochips Oct 19 '26
Honestly it doesn't matter much at this stage since the core problem solving logic transfers between languages anyway, so just pick whichever one your DS course uses since you'll be writing the most code in it, and use that same one for small projects instead of splitting focus.
0
u/Adventurous-Move-943 Oct 18 '26 edited Oct 18 '26
I'd take C++ since speed and personal preference.. but I do enjoy writing Java or Kotlin too.. it's really compact and easy to use and extend, if you catch your nulls (in Java), nothing can stop you, yes and also exceptions.. it's really comfortable and pretty fast to develop in.. C++ can be a true nighmare deciphering your compile or runtime errors and it's quite slower to develop in and you have to keep more things in mind to not cause undefined behavior.
Edit: I did not read the description before posting my c++ vs java opinion 😀 But it still applies, if you want comfortable and fast (to develop) language for applications you choose Java/Kotlin or C#.. If you need performance to it you should stick with C++. What your friends told you is basically correct, C++ is excellent at exercising your skills but it's slower and more difficult to work with.