In my opinion it's better to start learning Python.
I found it easier to learn then C or C++. It has libraries to do virtually anything you might need, and can do essentially anything.
The only reason to use a more difficult language like C/C++ is if you need the performance or are writing code for an embedded system. They are not, however, what you should be learning initially.
C# is a fine language, but nothing beats Python for ease of use.
The scope of Python is quite broad, here are some examples:
- Create a website (Django, etc.)
- Create scripts to do tasks ranging from image manipulation to server maintenance
- Create GUIs (Tkinter, etc.)
- Create games (pygame)
- Scientific computing (SciPy)
Python can interact directly with arbitrary C code, meaning anything which can be done in C, can be done in Python with a little work. Python is popular enough that an interface has been created for virtually everything already.
For a better look at what can be done with python out of the box, take a look at the standard library which comes with python: http://docs.python.org/library/
In short, if it can be done with a computer, and doesn't require the speed of C/C++, it can be done with Python.
Answer from Wouter on Stack OverflowAsk HN: Is it worth it to learn C to better understand Python?
Should I learn Python or C?
Is it worth learning C/C++ before learning Python? - Stack Overflow
First programming Language : C or Python? - Computer Science Educators Stack Exchange
Videos
I am a high school student. I want to become a "good" software engineer in future. I want to learn programming due to my interest in computers and technology. I don't have any specific goal or interest, like web development or any other.
Some say to start with Python, as it will help to start easier, then learn other languages.
Some say to start with C, as it will teach me basics of programming and will make it easier to learn other languages. Python will make it difficult to learn complex languages, like C++, and I will learn bad habits from Python, as it is very easy.
I know I may be wrong, but I don't have much knowledge about programming. Please help me decide between Python and C.
In my opinion it's better to start learning Python.
I found it easier to learn then C or C++. It has libraries to do virtually anything you might need, and can do essentially anything.
The only reason to use a more difficult language like C/C++ is if you need the performance or are writing code for an embedded system. They are not, however, what you should be learning initially.
C# is a fine language, but nothing beats Python for ease of use.
The scope of Python is quite broad, here are some examples:
- Create a website (Django, etc.)
- Create scripts to do tasks ranging from image manipulation to server maintenance
- Create GUIs (Tkinter, etc.)
- Create games (pygame)
- Scientific computing (SciPy)
Python can interact directly with arbitrary C code, meaning anything which can be done in C, can be done in Python with a little work. Python is popular enough that an interface has been created for virtually everything already.
For a better look at what can be done with python out of the box, take a look at the standard library which comes with python: http://docs.python.org/library/
In short, if it can be done with a computer, and doesn't require the speed of C/C++, it can be done with Python.
I would say it depends on what you want to achieve (cheesy answer...)
The truth is, learning language is a long process. If you plan on learning a language as a step toward learning another language, you're probably wasting your time.
It takes a good year to be proficient with C++, and that is with basic knowledge of algorithms and object concepts. And I only mean proficient, meaning you can get things done, but certainly not expert or anything.
So the real question is, do you want to spend a year learning C++ before beginning to learn Python ?
If the ultimate goal is to program in Python... it doesn't seem worth it.
The question is actually more complex than it might appear, and really the answer can depend on the context. For example, at what age are the students when they are first taught to program? Is this in Primary School, High School or part of an undergraduate programme? The answer might be different in each case.
It also depends on the purpose of teaching the initial programming language (IPL). Is the purpose to lead towards a practical skill (vocational programming), or is it to enable the teaching of some knowledge of algorithms (pedagogic programming), is it to enable the functioning of some devices (engineering programming) or is it to prepare students for further study? Each of these questions could lead to a different language as an IPL.
For a very early age start of programming one does not have to worry about employment or future curricula so something engaging is important, so tools such as MIT Scratch have a role. For later childhood Python fills a nice niche, particularly as it can run on a wide variety of inexpensive platforms (such as Arduino's, Raspberry Pi and so forth) which provides accessibility and make it within the reach of the classroom and individual students.
Conversely, if one is looking at an undergraduate IPL then it may depend on which degree programme is being considered. Is it a degree in Computer Science, Engineering, Biology, Chemistry or Physics? One would then need to take into account what graduate employers might be looking for and tailor to that market.
Python might have value in some of these programs but the students would also have to learn other languages at some point. For example, Computer Scientists would need a wider experience that would embrace C#, C++ (among others). Electronic Engineers might need C, but Computer Scientists less so. Biologists might need R, Chemists and Physicists might still need Fortran!
However, I would say that I might never recommend C as an IPL, and would start at C++ even for the most hardened Electrical Engineer. I only show Computer Science students C in specific contexts (like working with flex and bison)!
One thing I say to my students in the course where I look at Languages is that there is no one best language. The choice of language for any particular situation is so very context dependent on resources available, skills available, the purpose of the programming and the end goal of the task, and for an IPL that advice still holds true.
I started teaching Python at NCSSM in 2004. Here are some reasons I chose it.
It is direct and simple, and there is not a whole ton of boilerplate to deal with at the beginning. Hello, World looks like this
print("Hello, World")
We all know what it looks like in Java (enclosing class needed) and C.
Delimitation occurs via whitespace. Students who begin with Python tend to have excellent formatting habits when they learn other languages, because Python requires them. There is a direct visual connection between the flow of a program and its appearance.
It's a professional tool. Students don't "outgrow" Python. It has a rich standard library and numerous third-party libraries that make it an awesome tool.
It supports OO, functional, and imperative programming paradigms
Memory management on the heap is largely abstracted away.
The built-in types provide a significant creative palette. We teach our students to "use wheels, not re-invent them." An exception to this is when we are "dissecting" something to gain an understanding of how it works.
It runs on everything and web interfaces for it are freely available.
Long experience shows that Python is an excellent language for beginners.
C is not great for beginners. However, it is very important. In many ways it is the "Latin" of computer languages. Every programmer should know it, because it lurks beneath the surface in so many places. We teach it to students who are already proficient programmers.
I knew C before I knew Python. No offence intended, but I don't think that your C knowledge is that big a deal. Unless you read very, very slowly, just set out to learn Python. It won't take that long to skim through the material you're familiar with, and it's not as if a Python tutorial aimed at C programmers will make you a better Python programmer - it might teach you things in a different order, is all, and raise some specific things that you would do in C but that you should not do in Python.
Strings in Python actually are somewhat different from strings in C, and they're used differently. I strongly recommend learning them "from scratch", rather than thinking about them in terms of their differences from C strings. For one thing, in Python 2 it's best not to use Python's "string" class to represent strings: there's a separate unicode string class and for practical Python apps (pretty much anything involving user data), you need that. (Python 3 fixes this, making the str class a unicode string). You need to establish a good working practice for unicode/byte data and decode/encode.
A common mistake when learning a second programming language, is to think "I know how to program, I just need to translate what I do in C into Python". No, you don't. While it's true that an algorithm can be basically the same in different languages, the natural way to do a particular thing can be completely different in different languages. You will write better Python code if you learn to use Python idiomatically, than if you try to write Python like a C programmer. Many of the "tricks" you know that make sense in C will be either pointless or counter-productive in Python. Conversely many things that you should do happily in a typical Python program, like allocating and freeing a lot of memory, are things that in C you've probably learned to think twice about. Partly because the typical C program has different restrictions from the typical Python program, and partly because you just have to write more code and think harder to get that kind of thing right in C than you do in Python.
If you're learning the language because you urgently need to program a system/platform which has Python but doesn't have C, then writing Python programs that work like C programs is a reasonable interim measure. But that probably doesn't apply to you, and even if it did it's not the ultimate goal.
One thing you might be interested to look at because of your C experience, is the Python/C API. Python is great for many things, but it doesn't result in the fastest possible computational core of scientific apps [neither does C, probably, but let's not go into FORTRAN for now ;-)]. So if you're aiming to continue with scientific programming through your move in Python, and your programs are typically memory-bus- and CPU-bound doing immense amounts of number-crunching (billions of ops), then you might like to know how to escape into C if you ever need to. Consider it a last resort, though.
You do need to understand Python reasonably well before the Python/C API makes much sense, though.
Oh yes, and if you want to understand OOP in general, remember later on to take a look at something like Java, Objective-C, C++, or D. Python isn't just an OO language, it's a dynamic OO language. You might not realise it from comparing just C with Python, but dynamic vs static types is a completely independent issue from the OOP-ness of Python. Python objects are like hashtables that allow you to attach new fields willy-nilly, but objects in many other OO languages store data in ways which are much more like a C struct.
I learned everything I know about Python from the official documentation: http://docs.python.org/
And it's free.
I'm a beginner in programming and I saw several people saying that it will be easier to learn Python or any other programming language to start by learning the basics (C). Does it really make a difference?