Live data from Hacker News

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

news.ycombinator.com

71–80 of 93 posts

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

#71
I'd actually recommend learning a higher-level language, like Common Lisp, to better understand Python: knowing about the relevant algorithms and how they transfer should do far more to educate you than learning C, which shares no abstractions with Python.

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

#72

Earlier quoted context omitted.

Those are all vastly more complicated than C. And on top of that you have to learn three instead of just one! (Imagine trying to learn Rust without experience with C. Oh man.)

I think many programmers forget how it was to learn to program. Imagine the horror trying to make Rusts borrow checker happy without even understanding what an object scope or pointer is. C is a really good beginner's language, since any oop is explicit with function calls, kinda like Basic. No invisible destructors etc. Modern compilers even warns you on returning pointers to stack locals etc. I don't think Python i…

Agreed. C is a great starting point. It's a terrible continuing point though. Novice C programmers write seg-faulty code left and right, which is fine. That's not a problem; everything that's wrong is on the surface. In the mean time, they've learned how to implement a binary search tree or something, which is pretty cool when you do it in C. The intermediate two-star C programmer whose programs almost never segfault, that's the truly dangerous one. Precious few C programmers make it past that stage.

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

#73

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.

I can recommend https://realpython.com/products/cpython-internals-book/ as a decent initial documentation of cpython. I have a copy of this book at my desk for the few cases when I need to debug GIL or memory allocator related issues in cpython.

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

#74
post #70

Earlier quoted context omitted.

For many people (myself included), the ease of writing python jumpstarted my journey to eventually learning everything else you mentioned gradually. If I would have had to learn it immediately I most likely would’ve felt disinterested and overwhelmed and given up since I didn’t know yet why I needed to learn it.

This is my major gripe with the college courses I took. They start at the molecular level and build to the planetary scale. This works for some people, but for me I had the hardest time finding a personal interest until I got to the application. It was the application I wanted to build, and to do actual work you don't manipulate the molecules directly. Build an application, then as you need to learn more to get thing…

Agreed. I've found the insistence my college professors had on writing everything yourself and not using libraries or modules for common tasks to be in the end counter productive. Namely for the reason you described. To reference Carl Sagan, I didn't have the stamina in the beginning to build the universe before I made my apple pie.

Additionally, code is more collaborative than that, and it shows in a lot of engineering departments when people aren't trained on how to look at the shelf for existing parts before building something new.

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

#75
post #70

Earlier quoted context omitted.

For many people (myself included), the ease of writing python jumpstarted my journey to eventually learning everything else you mentioned gradually. If I would have had to learn it immediately I most likely would’ve felt disinterested and overwhelmed and given up since I didn’t know yet why I needed to learn it.

This is my major gripe with the college courses I took. They start at the molecular level and build to the planetary scale. This works for some people, but for me I had the hardest time finding a personal interest until I got to the application. It was the application I wanted to build, and to do actual work you don't manipulate the molecules directly. Build an application, then as you need to learn more to get thing…

Yup yup yup. I've been coming to this realization about myself so much recently too. It's how I taught myself web/app dev with hackathons, facing a huge project head-on and "backtracking" to learn stuff as needed. It's how I taught myself machine learning by jumping into a research project with a prof without ever having written PyTorch. And it's how I'm now teaching myself higher math, having just jumped into the homotopy type theory textbook and an idea I have for application in NLP, and going backwards to learn the required category theory and algebraic topology.

I wonder whether the fundamental structure of curricula could be changed to take advantage of this fact, because I think it's true for a lot of people.

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

#76
post #63

Earlier quoted context omitted.

>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…

You got me curious there. Do you have any resource recommendation to learn about the cost of different data structures/algos and such?

This is what big O (also little O and little omega) notation is all about. Unfortunately, all the resources I know of teach it as pure mathematics, so they require a firm grasp of mathematical proofs to understand the details and implications.

With that said I highly recommend the classic Introduction to Algorithms (CLRS for short) by Cormen et Al. It is written in clear and straightforward language. And the lectures on MIT OCW by Erik Demaine are outstanding.

By reading and watching the lectures I deeply understood stuff that I had just muddled through previously.

https://en.m.wikipedia.org/wiki/Introduction_to_Algorithms

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

#77
Probably. If you should look at the python implementation and the standard libraries it uses and the kernel you are using they are all primarily in C and in rare cases of other languages they are setup with FFI that favors the thought process of a C programmer.

When I look at a language like python or PHP I often just go down to the C code they call and use a tracer to watch calls to solve a problem without actually using the higher language.

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

#79

Earlier quoted context omitted.

I think many programmers forget how it was to learn to program. Imagine the horror trying to make Rusts borrow checker happy without even understanding what an object scope or pointer is. C is a really good beginner's language, since any oop is explicit with function calls, kinda like Basic. No invisible destructors etc. Modern compilers even warns you on returning pointers to stack locals etc. I don't think Python i…

Agreed. C is a great starting point. It's a terrible continuing point though. Novice C programmers write seg-faulty code left and right, which is fine. That's not a problem; everything that's wrong is on the surface. In the mean time, they've learned how to implement a binary search tree or something, which is pretty cool when you do it in C. The intermediate two-star C programmer whose programs almost never segfault…

Ye, unless you to electrical engineering/close to hardware embedded or something. However even those probably benefits from mastering some memory managed language, before going back to C.

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

#80
post #63

Earlier quoted context omitted.

>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…

You got me curious there. Do you have any resource recommendation to learn about the cost of different data structures/algos and such?

CLRS is the text, but for a more gentle introduction see Grokking Algorithms.
Post reply on HN