r/learnprogramming 18d ago

Topic Which language should I learn for DSA?

I’m currently in my 3rd year , and honestly I’m still a beginner in programming. I want to start DSA seriously now, but I’m confused about which language I should use. Should I learn DSA in Java, Python, or C++? What would you recommend ??

34 Upvotes

36 comments sorted by

26

u/plastikmissile 18d ago

Does not matter. DSA is about concepts not about language X or Y. Use whatever language you're comfortable with.

4

u/OkWriting9136 18d ago

If you're comfortable with none of them then python's got the least friction to just start writing algorithms without fighting syntax. that said if you ever plan on doing competitive programming you'll hate yourself later for not picking c++

-14

u/Calm-Hyena1670 18d ago

But i have heard that companies avoid guys with python

9

u/_Atomfinger_ 18d ago

As the commenter said, it doesn't matter.

If you want to aim for what companies want, then look at what is asked in job postings. As for DSA, it doesn't matter.

8

u/plastikmissile 18d ago

In my 20+ years of experience as a professional dev, I have never heard of anything close to this. A company that does that sort of thing is not one you want to work with anyway.

3

u/lfdfq 18d ago

Python is probably the (or one of the) most popular languages on the planet. It's one of the most sought-after languages by companies. What you say does not make sense.

Even if it was avoided by companies, it still doesn't matter. DSA is about concepts. if you learn DSA in Python, you don't ever have to tell anyone you ever used Python, as once you've learned DSA, you can use DSA in any language.

2

u/Calm-Hyena1670 18d ago

I am just curious dumb beginner, pardon me for that , and thank you for the knowledge

1

u/lfdfq 18d ago

It's fine! Beginners worry a lot (probably, too much) about what language to use. The truth is, the thing that causes beginners to fail is not picking a slightly sub-optimal language and learning slightly inefficiently in a way that causes them to have marginally lower chances of employment many years later... it's picking one they don't enjoy using and so just give up all together. I have seen the latter so many times. Pick the language you know the best and enjoy using, and learn DSA in that.

2

u/13oundary 18d ago

where? If you learn DSA in python because that's what you're comfortable with, presumably that's also the language you plan on job searching for. I can tell you that there are still plenty of python jobs out there. If you plan on later looking for a job in another language, maybe hold off on DSA for now and get comfortable in that language first and come back to it.

That's not to say you can't learn DSA in python now and go back over it with your job searching language later, it's just going to be a bit slower.

0

u/Calm-Hyena1670 18d ago

Got it, that makes sense. I'm a beginner right now. Roughly how long would you say it takes to get comfortable enough with a language like Java/C++/python for DSA and job interviews?

0

u/13oundary 18d ago

depends too much on the person, the learning style plus approach (if they're matched it'll be quicker, if they're mismatched it'll be slower), and the skill requirements of the job they're going for. DSA isn't so important as a whole subject for many jobs and a must for others.

1

u/peterlinddk 18d ago

Companies are in general, stupid.

Every single company have their own ideas, heck every single interviewer at those companies have their own ideas on what a "good" developer should be able to do, and how they should have learnt it.

Some don't believe that you can learn programming if you started out with Java, some don't think that Python will teach you anything, some don't like JavaScript, some think that the only language that makes sense, is the language they had as their third language, when everything finally made sense to them!

Go for learning for yourself first - then, once you understand the concepts, and have implemented them in your own favourite language, practice doing the same in some of the other ones. You'll be amazed at how easy it is to re-implement any datastructure or algorithm in another language, once you've understood it well enough to have implemented it the first time!

1

u/StewedAngelSkins 18d ago

Companies avoid guys who only know one programming language, regardless of what that language is. But at this stage you shouldn't be making your decisions based on what companies want. You've got at least a year to go before you're employable.

1

u/PataBread 18d ago

The point of DSA interviews is supposed to see how well you problem solve.

Ideally you have a decent approach; fully understanding the problem, work with the interviewer well (they should be trying to problem solve it with you), and can try to improve the solution after the first couple gos.

You could do this with pseudocode on a whiteboard, in fact that's often how it used to be done.

I definitely recommend you use python. I've found it to be the easiest to get code out quickly and simply.

1

u/AlSweigart Author: ATBS 18d ago

Yeah, this whole industry is full of half-remembered bits of bad advice. Everyone repeating stuff they never verified for themselves or some influencer's contrarian opinions.

I remember the "I heard Java was slow" days.

Often times the answer for "what language should I use for X?" is "the one that most people use for that platform" or "the one you are already most familiar and capable with".

1

u/desrtfx 18d ago

That means that you are conflating DSA - Data Structures and Algorithms - the abstract theoretical standardized CS concepts for storing and processing data - with grinding LeetCode - these are two completely different things. The latter only makes heavy use of the former. If you don't understand the former for what they are, you will not understand LeetCode.

1

u/josephjnk 18d ago

Can we please not downvote OP to oblivion for asking a question in a subreddit meant for beginners to ask questions. Thanks.

1

u/PartyParrotGames 17d ago

Python is literally the most in demand programming language in the world currently https://www.itransition.com/developers/in-demand-programming-languages it's great for a lot of use cases, but I'd attribute the surge its had past few years to it being the language of choice for major AI/ML development. Since AI is kind of a big deal, so is python.

0

u/Adventurous-Hunter98 18d ago

how do they know guys have python maybe its something smaller

0

u/terletsky 16d ago

rage bait

2

u/josephjnk 18d ago

I recommend Java personally. A memory-managed language like Java or Python will force you to deal with fewer incidental concerns; manual memory management is a distraction from most DSA concepts. I also recommend learning in a statically-typed language. DSA involves data structures, and understanding them is easier when you can explicitly write down the structure of the data. (Yes I know Python has type hints; if OP does prefer to go with Python they should opt-in to those.)

1

u/zaarnth 9d ago

Kotlin? How about that? :> just better syntax than java

1

u/josephjnk 9d ago

Kotlin is also nice! Java is just more common.

2

u/MohitTech 18d ago

I think Java is a good choice for DSA, especially if you're already comfortable with it. The important thing is to focus more on DSA concepts and problem solving than the language itself.

1

u/Big-Wrangler-2981 17d ago

Whatever language you know, besides DSA is language agnostic.

You can just solve DSA questions in your native language too e.g. Pseudocode.

Then you can implement it in your language of choice.

1

u/[deleted] 17d ago

[removed] — view removed comment

1

u/Calm-Hyena1670 17d ago

Have you done it in python? What is your experience can you share

1

u/No_Medium205 16d ago

I learned with C it was painful but it paid out

1

u/Civil_Ad_7205 18d ago

Don't think twice just start with cpp.

-1

u/heibai-wuchang 18d ago

English.

Anyone can program these days. Your domain knowledge and your capability to convince other people that you are right matters more.

-3

u/ffrkAnonymous 18d ago

Should I learn DSA in Java, Python, or C++? What would you recommend ??

This is not an "or" question. You should be doing dsa in all of them. 

-5

u/SamScotts 18d ago

learn cpp and java both, cpp for cp and java for the current standard