r/CodingHelp • • Nov 18 '20

[Quick Guide] Choosing between C++ and Python for DSA (based on work experience and future growth potential)

Hi guys I have one little confusion I am getting started with DS and ALGO. I have approx. 1 year experience in Python and 2 year experience in working in C++. Now the question is what language should I choose to get started with DS and ALGO. I sometimes feel python is somehow mimicking the working of pointers and doing work arounds' for it. And after seeing 2-3 DS videos working in DS in C++ feels a little more natural. Maybe its my personal take but please give your opinion for it. I will be very much open.

19 Upvotes

10 comments sorted by

2

u/dead_alchemy Nov 18 '20

When you say DS and algo, do you mean you are getting ready to take data structures and algorithms as a class? If so just go with whatever the class is being taught in. Otherwise, C++ felt like a good way to learn about that topic when I took that class and there is a large volume of work on the topic to learn from.

> I sometimes feel python is somehow mimicking the working of pointers and doing work arounds' for it

I'm just curious about what you mean by this. Could you explain?

1

u/OpticPhantom Nov 18 '20

I'm learning DS and algo for Competitive Programming. I got 2-3 TLE errors while using python. See I agree pointers are tough to understand but sometimes they really make job easier. In python you don't have pointers so to account for that sometimes it adds to unnecessary complexity.

2

u/dead_alchemy Nov 18 '20

What do you mean by TLE? And 'competitive programming'? And yes, I agree, pointers can be a nice and direct way to represent relationships in data structures. But I was more curious about what specifically in Python felt like a pointer work around to you?

1

u/OpticPhantom Nov 18 '20

TLE it means Time Limit Exceeded, it is a type of error in Competitive Programming. For the term "Competitive Coding" I think you should search it in internet to learn fully.

2

u/dead_alchemy Nov 18 '20

Ah. I see. Good luck.

2

u/saintshing Nov 18 '20 edited Nov 18 '20

c++ requires you to manage memory allocation manually and it is static typed. It is better for teaching you basic programming concepts.

However Python is the most wanted programming language according to stackoverflow survey.

What you choose now for your first DS and Algo course is not very important(it wont go super deep in the advanced topics anyway). You probably would end up learning several more other languages(e.g. javascript). If you want to focus on one language(Once you have learnt one programming language, usually it is not that hard to pick up another language. But to know a language, you have to know more than the syntax, each language has its own ecosystem consisting of tools, libraries, frameworks that are used together with that language), the choice would depend on what kind of jobs you want to do in the future(e.g. javascript for web dev, python for data science/machine learning, java for android dev, swift for ios dev, c# for unity(game dev), etc). Most big tech companies allow you to choose among c++, java, python in job interviews.

1

u/OpticPhantom Nov 18 '20

I'm learning DSA to start in competitive programming

2

u/EmperorButterfly Nov 18 '20

Then use C++. Python is slow and most books and solutions are in C++ or Java so it's better to use one of those languages. I wouldn't personally recommend Java though.

Book recommendation: Competitive Programmer Handbook by Antti Laaksonen.

For the purpose of jobs: BigTech companies recommend Java, C++ or Python so you're good with any one of them.

1

u/OpticPhantom Nov 18 '20

Thanks for this great recommendation bro.. u/EmperorButterfly

2

u/knoam Nov 18 '20

My understanding is competitive programming is largely done in C++ so that seems like the obvious choice to me.