Ask HN: Learning C as beginner better than learning C just after python?
Freshman Year | Autodictact | Non-CS Major |Knows no programming language.
Looking forward to learn coding
for building with best design principles,
gaining efficiency of data structures and
thinking abstractedly in algorithmic rollercoaster of fun.
What is the cost benefit analysis of Going from 0 to C than Python to C?
33 comments
[ 2.7 ms ] story [ 51.4 ms ] threadcould you add some more details why you want to learn C as well?
I am dead serious in writing beautiful code at production level. I am from India and a blanket cloud opinion of Substandard Coders(TM) is already looming heavy. I want myself to notch up and get noticed by differentiating myself apart. Maybe to the levels of Russian/East bloc European countries when it comes to algorithms (I emphasised this is question details). I intend to do freelancing in web products for bread and butter at the start of my career.[I apologize, but I don't intend to be racist here with sterotypes.]
At the same time, due to time constraints, I just can't touch Assembly. So, C.
for algorithms, highly recommend https://en.wikipedia.org/wiki/Introduction_to_Algorithms book.. it uses pseudocode and thus language agnostic
choice of language at production level depends on lot of factors. for ex: you might choose C for speed of execution but Python would win hands-down in time taken for you to write the code, including testing...
getting used to programming takes long time and learning continues life long..
Thank you for the help.
Thanks!
I've actually been recommending HTML, Javascript, CSS, and git (specifically with github's "GitHub Desktop" application) to my friends/family that want to start programming. But of the two you'd mentioned, I'd vote for Python.
I am not intimidated by REPL/compile methods per se, but what path of learning these languages bring to the table. As emphasised in question details - "gaining efficiency of data structures and thinking abstractedly in algorithmic rollercoaster of fun.",for it, I will have to learn both. I will have to go through one door to another anyway, its just the order. Python-to-C or C-to-Python?.
Yes, I have operating systems in my bucket list. I must know the nuts and bolts without fail.
I see your point. Thanks!
Spent a few years writing Python, went back to C... and it was much easier to get right.
Your experience somewhat soothed me. Thank You.
So if you just want to play around, do cool stuff quickly and get moderately good in programming start with python, beware it might be hard for you to come back to C.
But if you want to become more than good and really understand what advantages python gives you, start with C. There is little extra effort involved: just implement every data structure in C once and learn about pointers. You will become a much better programmer. Also, you will enjoy coding in python more, once you know C.
I guess the shorter answer is to start anywhere. The longer answer is the question of whether you want to enjoy the act of programming or the results that you achieve with programming. In the former its start with C, in the later its start with Python.
SIDE NOTE: As caseymarquis said, if you want to go the python route, go for javascript. There is little lost in the process, but the value of doing something cool is exponentially increased.
I must learn C and Python without fail for learning Data Structures and Algorithms. I can't leave any one of them. It was just the order. I am getting more and more convinced with your line of suggestion as other's opinion keep pouring in.
Thank You!
1. https://cs50.harvard.edu
2. https://www.edx.org/course/introduction-computer-science-har...
Also, there's a very active community around CS50 on Reddit[1] where you can get help when ever you need it.
1. https://www.reddit.com/r/cs50/
Now to answer your question by looking at your goals. "Knows no programming language" lets me know that you are starting from scratch. In my opinion, this means you need to answer the following question first: do I even like programming? The best way to answer this is to not abuse yourself with C but instead start with python to get a real feel for what programming is.
"Learn coding for building with best design principles" means you want to learn good habits early on. Python has a stable style guide (pip8) and the zen of python, so at least some good habits can be learned quickly. I don't think there is a comparable zen of C, but maybe that's because I haven't looked.
"Gaining efficiency of data structures" means understanding why data structures are important in program design. Python has some pretty solid built-in data structures (i.e lists, sets, dicts, tuples) that are good for beginners who want to experiment with data structures. C doesn't have lists, sets, dicts, or tuples, but you can implement them if you try hard enough.
"Thinking abstractedly in algorithmic rollercoaster of fun"...I think what you meant is the freedom to think about an algorithm and to implement it with ease. Python is fantastic for this, while C requires a lot more thinking to get a thought manifested to code.
This post kinda struck a chord with me because I wrestled with the same question when I started 4 years ago. Python helped me more than C because I was more creation oriented. I wanted to implement a useful tool as fast as possible. With your questions in mind, I think python would be better choice than C as a beginner.
As I said in other comments before, I was apprehensive if I could deal with initial frustration due to subconscious comparison of how easy life was with python. I asked myself If I would trip off; will I be able to cope up; will my brain be malleable enough or get hardened against the higher cognitive load C poses comparing to python, etc. with no good answers. Hence this question.
Every other commenter echo with your respected opinion and I appreciate your well explained suggestion. I just needed my answers through other's experiences to the above questions.
I will be "starting out with python"(amazon<dot>com/dp/0134444329).
Thank You.
Learning about memory management might be better decoupled from learning "programming" in the very beginning.
It will feel slow at first, but you will learn more quickly overall.
Regarding algorithms, even developers who do things algorithmically heavy, such as for example data compression or procedural 3D animation, claim to work on the actual algorithms for maybe 10% of their time. 90% of the job is actually the "everything else" - testing, optimising, polishing, chasing platform bugs etc.
Thanks.
To learn the actual "art of compute". Go from bare metal and then up. In your free time casually learn about logic gates, SR latches and clock cycles. Then to Registers, ALU, Instruction Sets and pushing/popping things on stacks. Then to memory mapping and data buses.Work your way up to the C level of abstraction.
It is a long and brutal road, but it gives a great CS/EE foundation.
I am recommending this route since when they talk about pointers, references,heaps in the C world. It will give you a tangible foundation to built these abstract ideas on.
I vaguely learned the "art of compute" from college via Digital Logic, Microprocessors, and other related classes. Since your in college, I would just sit-in the EE/Comp Sci classes. It is much easier to learn from lectures when you don't care about tests/notes or labs. Then use the internet/office hours to supplement your curiosity/questions.
In conclusion,I recommend casually learning from bare metal and then go up to C then Python. But in terms of actual programming, do Python and work your way down to the assembly level as needed.
I like Python since their are "defacto" ways of doing things. Matrix Math -> Numpy. Lightweight HTTP framework -> Flask. Everything-include web framework -> Django. Web scraper->Scrapy. Need packages -> pip. I know there are other contenders for the things I mentioned, but based on my perception, this is what the Python community is rolling with.
I wanted to recommend doing Javascript/HTML/CSS. It's really cool to work on a project, then publish it on the internet for the world to use/see. But things change so fast, it's hard for a beginner to "sort" through what's needed/useful. React or Vue? Grunt or Gulp? Packages npm,bower,yarn? Async/Promises or callbacks? Don't forget about webpack. Ember or Angular? But wait. There is Typescript,CoffeeScript,JSX which needs to be transpiled. ES6? Here comes Babel. Want to make dev process quicker. Start hot reloading.
The point is,it is a little tough to "sift learn" when picking up Javascript and friends.. The community is moving fast, but it incredibily exciting to watch/participate. But I don't reccomend starting with it.
If you really want to learn HTML/CSS/JS. Start at the Mozilla Developer Network and use vanilla JavaScript. Ignore all the trick frameworks and tools until you understand the problems they are solving. Use them only if they solve problems that you are having.
To go from Python to C. Write some Python app. Profile it. Then write optimized C functions to replace the slow parts of your Python program. Make a Python wrapper with SWIG. Best of both worlds in my opinion.
I never knew programming community could be this gooood and welcoming.
Thanks a ton man!
Python's development cycle is so fast that problem solving and debugging is a breeze. (All you need to do is write some code and then run it. No compile/run phase.) But then there comes a time when Python is just plain too slow for what you want to do. For example Image processing/Backend for web/Game development with intensive graphics. After this I found that it was time for me to start learning a faster compiled language such as C. Moving from python to C is a real pain. This is mostly because of all the really nice built in types: dynamic lists, strings, etc. that you get with Python already.
What's really cool is that Python allows integration between C libraries and python code. (ctypes) You can write something that may run really slow in pure Python. After that you can find the slowest parts with a profiler and replace them with external C library calls. (That you've written.)
In the end you end up with the lightning fast Python dev cycle plus the great optimizations and speed that C/native code gives.
In short form, Python is a great first language. C is a great first language too. You can have the best of both worlds with ctypes.
C is worth learning just until you understand malloc and pointers. Know about garbage collection, memory allocation, what an array really is, a lot of the low level efficiency stuff. You'll understand how strings and hash tables work.
Great Resource for start learning Python Python for Non-Programmers https://wiki.python.org/moin/BeginnersGuide/NonProgrammers