Live data from Hacker News

Ask HN: Is it worth it to learn C to better understand Python?

news.ycombinator.com

31–40 of 93 posts

Re: Ask HN: Is it worth it to learn C to better understand Python?

#31
I never got too far into C, but I took a course on assembly and learned Erlang and Golang to a decent proficiency. Erlang gave me an appreciation of loops and recursion, Golang made me more aware of types and error handling, and assembly just made me happy that I don’t have to write assembly. All this of this made me a significantly better Python programmer and made me appreciate what was going on under the covers a bit more. I also find value in challenges like advent of code, because it gives me a chance to tinker with a language in new ways.

Re: Ask HN: Is it worth it to learn C to better understand Python?

#32

Do we need to learn assembler to understand C well enough? That’s a litmus test for this question.

Well enough? No. To understand it better? Possibly.

Whether it is true for C and Python I don't really have an opinion.

Re: Ask HN: Is it worth it to learn C to better understand Python?

#34
Do you know any source to better study how python works? I mean something which are the steps to understand the internal CPython bindings and so on? I really want to step-up my Python skills but this part seems really hard for people with a non CS related background.

Re: Ask HN: Is it worth it to learn C to better understand Python?

#35
I think every coder who have the time to do so should learn C. Preferably before anything else. Maybe I'm biased by my education, since I started with almost a year of hardcore C(almost no libs, coding everything from scratch), I did code a bit before but nothing serious. After 1 year of segfaults, memory leaks, and random buffer overflows, everything else seems pretty easy, and everything make much more sense.

You won't just get better at python, you'll get better at pretty much anything involving programming or understanding how a computer works.

I've seen a lot of people say that if you learn C well, you're basically employable for the next 30 years. I think I agree with that.

Re: Ask HN: Is it worth it to learn C to better understand Python?

#36
Once you start hitting Python’s limits, understanding how the interpreter works (which is implemented in C) will be of great help.

You could take weeks 1-5 of CS50 [1] to learn enough C to get by. The course continues from week 6 with Python so it’s the perfect intro.

[1] https://cs50.harvard.edu/x/2022/weeks/

Re: Ask HN: Is it worth it to learn C to better understand Python?

#37
post #9

In college I used to tutor students in computer science. Mid-way through my college career my school switched the curriculum to teach Python instead of Java. I found that the students who took Python lacked what I considered a basic appreciation for and understanding of how the language actually ‘does’ something. For instance, when you only need to write two curly braces to create a “dictionary” (of course behind the…

>when you only need to write two curly braces to create a “dictionary” (of course behind the scenes this is a hash table) many of the nuances of that data structure are hidden from you. You have no idea that accesses are on average O(1) but worst case are O(n). Well, that is wrong. Single value accesses are O(1) amortized. Also, Java is a lower level language but I don’t think simply programming in Java instead teach…

Updated the original comment accordingly.

I suppose that’s also fair. I would say that Java at least makes you aware that there is magic afoot. You have to explicitly write that you’d like to use a HashMap, at which point someone writing or reading the code might wonder “what’s that?” Instead, python hides behind the abstraction of a “dictionary” when it should be in my opinion broadcasted from the high heavens that this is a hash map in disguise.

As far as the remainder of your comment, I agree wholeheartedly. Learn computer science. It makes you a better programmer.

Re: Ask HN: Is it worth it to learn C to better understand Python?

#39

I learned C and have worked with C++ professionally in the past and that knowledge doesn't help at all with understanding what Python is doing internally. Sure, CPython is written in C, but that fact doesn't tell you anything about the details of how it's implemented or what it does when it runs.

are you saying that if you want to learn the internals of cpython you don't need to know c before hand? i think learning c is a must for this case
Post reply on HN