Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This question already has an answer here:

Since Python was written in the C programming language, does it mean that if I know C I will learn and master Python faster than it would take me to learn it without prior knowledge of C?

Or will Python coders find it easier to learn C than programmers from other languages not related to C?

share|improve this question

marked as duplicate by MichaelT, gnat, Dan Pichelman, TZHX, GlenH7 Sep 17 '13 at 14:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

12  
Learning Russian will allow you to learn German faster because you have more experience adapting to new foreign languages, but it would make no sense to learn Russian as a warmup if you really just want German. –  Brian Gordon Nov 2 '11 at 3:32
add comment

5 Answers

Languages built on others can operate in fundamentally different ways, introduce new concepts. Just because every operation in Python must be translatable to an operation in C doesn't mean that that operation is feasible or good practice in normal C. The time you expend learning C won't really help you with Python, relatively speaking.

share|improve this answer
    
Python code written like C would be very bad Python. For a beginning programmer, learning C might even slow down the acquisition of Python skill. –  Steven Burnap Sep 15 '13 at 2:15
add comment

Python syntax is nothing like that of C. So having prior knowledge of C really has nothing to do with how well you will learn python. Just because under the hood there is C code doesn't mean that you will learn python any quicker because you know C. As a python programmer you are dealing with the syntax of python not C.

share|improve this answer
8  
The syntactic similarities or differences are irrelevant. What matters is the different semantics. –  DeadMG Nov 2 '11 at 4:33
add comment

The reference implementation of Python, CPython was indeed written in C, but saying that Python is written in C is an oversimplification:

  • There are implementations written in other languages, like Jython (written in Java), IronPython (written in C#), PyPy (writen in Python), CLPython (written in Common Lisp), Psyco (also written in C), Stackless Python (written in C and Python) and Unladen Swallow (written in C++)
  • Although the CPython interpreter is written in C, it is possible to write modules for it in C++ or Cython (not to be confused with CPython), as well as C
  • What language a language's interpreter is written in is only important if you want to write modules / extensions to the interpreter itself, it has nothing to do with the language

Several languages (like Java, PHP, C# and others) are referred to as belonging to the C family, that has nothing to do with what language tools (compilers, interpreters) for said languages are written in but it means that they have very similar syntax to C. Python's syntax is very different from C, not only does it not belong to the C family, its actually quite far from it.

Apart from the CPython interpreter, the only other relation that Python has to C is that they are both multi-purpose, multi-paradigm programming languages.

Whichever one you choose to learn first will greatly help you learn the other one, and that's true for every programming language, as the one you learn first will introduce you to programming concepts and ways of thinking that are common in every language.

Python is generally regarded as a higher level language, whereas C as a lower level language, meaning that Python is closer to what we humans consider friendly and C closer to what the machine considers friendly, so Python is a little bit easier for beginners to start with.

share|improve this answer
1  
I just discovered PyPy. Python written in python? :o –  popandcrackle Nov 2 '11 at 10:39
add comment

Abstraction is precisely supposed to allow you to work without knowing the underlying implementation. Therefore knowing the underlying implementation won't help you to grasp the abstraction. Of course in real life this doesn't alway work this way (The Law of Leaky Abstractions) but it's still true.

share|improve this answer
add comment

Python and C arguably share many concepts, so learning one of these languages will definitely help you with the other one (they belong to the same category of imperative languages, even though they do differ significantly on some points). Here are a few common concepts:

  • "Control structures": loops, tests
  • Function calls and return values
  • Variables have a type (both languages are strongly typed), and operations must respect these types
  • Basic variable types: integers, floats, strings, etc.

That said, Python is both simpler and much more expressive than C: programs written in Python are usually 2-10 times shorter than equivalent C code, and Python offers more useful data structures than C (namely: lists, dictionaries, sets, objects,…).

So, I would strongly recommend that you learn Python first. C will be much easier to learn afterwards, because Python will allow you to grasp the right programming concepts much faster.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.