Three Things Gained When Starting With C Instead of Python
While a language like Python is extremely powerful and has many use cases in the industry, a language like C is a better, but not easier, place to start.
No one will argue that it will be easier for a programmer or Computer Science student to start off with C than it is with Python — it most definitely is not. But, later into your career starting with a language like C could provide a better foundation on which to build. I’ll discuss a few reasons why I think this is the case.
More Rigid Syntax
If you’ve used both C and Python you’ll know what I mean when I say that C’s syntax is more rigid than Python’s. With both, you have to follow a set of rules but overall C’s rules are more strict.
If you look at line endings, C requires semicolons while Python does not. C requires if statement conditions to be surrounded by parentheses while Python does not. C has the idea of pointers while Python handles that all for you.
This isn’t a knock on Python — in many ways, it’s a benefit allowing one to get their production code up and running faster. But for someone starting out, having a solid set of rules that you think about when typing, rather than the lackadaisical rules of Python, will set you up better when you learn a new syntax or when writing code generally.
I previously mentioned that C has the idea of pointers while Python handles a lot of that for you.
C gives a much lower level understanding of what’s actually going on in your code as opposed to many scripting languages and even compiled languages like Java.
When writing C code you’ll really get a feel for what's going on in the memory as you’ll have to think about allocation, deallocation, and memory scope. In other languages, you can just create variables whenever you want and pass them wherever you want without much thought. Often this will work fine in simple programs, but when you start to get into more complex programs in any language, it will become very useful to really understand what is going on with your variables.
Idea of Type
In Python you do not give a type to a variable when it is created — you simply just set it to the value and the type is assumed under-the-hood. This is, again, a speed improvement for those experienced, they already know what types they need and want to set up their variables as fast as possible.
For a beginner, it's a good idea to think about variables in terms of their type. A beginner may become confused that there’s no distinction between a
String and an
Int in Python, as you just set both with an equals sign.
With C, in order to declare any variable, you must assign a type. This gives you a clearer understanding of what your variables actually are so your code and remains as clean and usable as possible.
One area where a beginner would become particularly confused in Python is when dealing with larger libraries such as
pandas. As they go about using variables from types defined in those libraries and calling functions in those libraries, it is very easy to get lost in what all of the variables actually are and what the functions really take in and provide. This is a cause for confusion. Because one is getting lost in using the libraries they may stop worrying about understanding what is actually going on and try instead to just get the program to work. This is a bad approach. You should always try to understand what’s going on at a lower level in your code. It could just be a type error that’s causing it, and in a language like C, it’s much easier to tell what each of your types are and what each function requires as parameters.
Future Learning Ability
With those three ideas in mind — rigid syntax, type, and lower-level understanding — it is easier to move to a new language starting with C than it is with Python. I believe this is due to the direction of movement. If you start with C, a rigid language, it is easier to become more relax and move to other languages. And if those new languages happened to have a hard syntax also then you already know how to cope with that because of your C knowledge.
If you start with Python, a more relaxed syntax, it is harder to add that rigidity on the fly. You’ll likely try to figure out how to do all these Python one-liners in languages that really aren't designed for that. As a result, that transition may be slightly harder.
At the end of the day, if you’re learning any programming language at all that's a great start. However, if I could make a recommendation to a new programmer it would be to start with a compiled language (like C) over a scripting language (like Python) for all the reasons I’ve mentioned so far.