I’m eager to try programming. I’ve heard that Python is a good choice to start?
Traditionally, programming classes started students off with C/C++ or Java. This is the route I went. Frankly, I think that is a good way to turn people off from programming. They are difficult languages to learn how to use correctly and they aren’t very forgiving. New programmers are not only struggling with the basic logic of programming, they are also fighting with the language itself.
For example, C/C++ require the programmer to know about memory management. With the number of exploits in the wild that rely on buffer overruns, even the experts don’t get it right all the time.
Java, on the other hand, is object-oriented, so you are not only having to learn to think like a programmer, you have to jump right into objects. The first time I learned about them, I had no idea what I was doing; my programs worked in spite of my knowledge, not because I knew what I was doing.
When I decided to learn Python, it was like a breath of fresh air. All the things I hated about the other languages was removed. Curly braces to demarcate blocks of code? Gone, replaced with simple indentations. Memory management? Python uses garbage collection (so does Java). Ease into object-oriented programming? Python allows you to use procedural programming or objects. You can even mix the two in the same code.
In short, Python is my favorite language and, unless there is a legitimate reason to not use it, I will push it for any programming project. The versatility and ease of Python makes it popular for many different applications.
Personally i would like to suggest you to start with C language and then switch to C++(If you wanna outperform in Competitive programming). Python is great and has been in more demand specially for projects and other higher application. Thus, it depends upon your interest that you wanna make it.
I think Python is a very good language to start. Competitive programming is mostly about designing an efficient algorithm for specific problems. In most cases having a good algorithm is much more important than having a fast programming language. The same bad algorithm in C++ instead of Python will maybe run 20x faster, but many cases that will still be too slow. A good algorithm in Python will often be much faster than a bad algorithm in C++. C++ is much harder to learn and use well. However, usually only hard problem will require the extra speed or flexibility provided by C++. Learn to code in Python first and if you like it and got to three stars rating already, then think about learning C++. Before that, spending more time on algorithms and data structures is likely a better idea.
I would advise against C for competitive programming. Even rather simple problems require the use of data structure such as dictionaries, heaps, dynamic vectors or sets and while those things are directly available without extra coding in Python or C++, you would need to provide your own implementation in C. If you decide against Python, directly start with C++. You can try to skip over the object-oriented part of C++, but at least learn about the C++ STL and builtin containers such as vector, deque, (unordered_)map, (unordered_)set, priority_queue as well as the nice things from the algorithm header such as sort, binary search with lower_bound/upper_bound and set operators.
@nanoalpaca But learning python without knowing the internal function is useless you will definitely pay for it in interview and other exams. That’s why C/C++ comes into play where you will learn about how the particular function works, how memory management handles, how the optimisation works by writing a modifying a single statement and much more that you will not get in python.
Python is only useful for higher application and projects where C/C++ would not work like that. Hence there are many pros and cons of each and every language.
As far as language is concerned, in my view:
- Learn Python if you’re totally new in programming and haven’t planned to dive into competitive programming right away, because it’s awesome, easy and full of libraries.
- Learn C/C++ if you want to be wizard at competitive programming( preferred C++ because of speed and STL) or want to be a system programmer(preferred C, close to hardware) because these two languages are very low level language.
- Java can be your second language to learn if you want to start with competitive programming(C/C++) or Web Dev(python). But you must learn java if you want to start with Android Development.
For Competitive Programming:
There is a one major difference I see among C/C++, python and java- python and java have build-in support for big integer types but C/C++ does not have any such build-in big integer types.
Despite all, good coders are never limited to any programming language because languages are only tools at the end of the day. Every language has its own pros/cons, so idea of exploring(once you have a good grasp on one language) would be better.
personally , i will say C is nice to start with and then you proceed to C++ . It will be good for your programming part . Then , afterwards you may learn any programming language you wish to . They will be a piece of cake for you . All The Best .
I think that python is the best language to learn for begineers. I also started python firstly. It’s very easy and useful. So, I suggest you to learn python first properly.
U shud basically learn algos before giving a kickstart. Better read data structures first and obviously design and analysis of algorithms. This will give u a kickstart! Also don’t try things randomly. Just stick on one! I prefer java more than cpp in many cases just coz I am more familiar to java than anything else. So my best choice is always java but the main thing is will I be able to pull off the algo I just read/thought of in java. Answer need to be yes! Else have to look out for cpp.
How can you say that C++ is much harder to learn and use well?
@bansal1232 Codechef not Cocechef(1st Line)!
There are many pitfalls related to memory management and pointers in C++, error messages in C++ are often multiple pages long and hard to understand without detailed knowledge into how C++ compilers work, etc. And really good, fast C++ code for more complex problems often requires insight into what a C++ compiler can optimize well and what not, how caches work, understanding of move semantics, etc. C++ is extremely powerful, but can at the same time be overwhelming. Python on other hand, has a very clean syntax, dynamic typing, usually easier error messages, easy to use builtin datastructures.
Thanks for pointing out the mistake
By programming do you mean competitive coding Or more than it?
Personally, i feel that for competitive coding, any of C++,python or Java are fine, as its algo which are of prime importance. But if you wish for beyond competitive coding, each language has its own pros and cons which guide you for the choice.
As a beginner, python is good, but in the end you will find yourself learning all 3. Its actually good to be flexible and knowing multiple languages, so dont stick to only 1 language!
Concluding, python is a good choice, if you arent being taught java/C/C++ by ur school/college.
Nice answer dear. Agree with this!
@nanoalpaca Why not start from C++ itself, and python is well suited for more complicated task than CP, CP is all about capability of problem solving, knowing only a subset of C++ helps, specifically knowing C and STL more than enough for doing CP. Python isn’t meant for CP, it is a scripting language and it is used for more complicated tasks which can’t be coded from scratch by a single person single handedly using C++ or C.
@neilit1992: Scripting languages such as Python focus on programmer productivity instead of execution speed. Especially at the beginning and in short contests, this is often more important than execution speed. Python has many features, that are nice for CP: int is automatically converted into an bigInt, if required, itertools can be very useful, dictionaries, lists and sets are native data types, etc. C++ is clearly a great language, but is it really the best language to start? I’m not against learning or using C++, I just think that is better for learning to start with Python.
I’m so agree with you but however, mastering C/C++ as a first language for newbie can’t be a cake walk.
yeah … that’s true . so be it a difficult task but it’s worth it . As i said earlier , after learning C/C++ , learning any other language will be a cake-walk .