Live data from Hacker News

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

news.ycombinator.com

41–50 of 93 posts

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

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

Ideally you'd teach python to build a c compiler. ;)

That said do people know more about the innards of Java ? It shield you from a lot of details too. From memory layout, to polymorphic calls.

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

#42
post #25

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.)

> Those are all vastly more complicated than C. C's simplicity is an illusion. The vast quantity of footguns and edge cases make writing correct C extremely complicated. > And on top of that you have to learn three instead of just one! You don't need to learn all of those, select one based on what your goals are. And it's not like gaining a surface-level understanding of any of these programming languages would take…

They aren’t necessarily advocating learning C so that they can write lots of production code in C. They are advocating learning C to better understand lower layers of programming.

The basics of C are easy and illustrative. And given that the main Python interpreter is written in C, can be helpful to know.

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

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

I agree with everything you said, and feel exactly the same way; except my university switched from C to Java mid-way my attendance... so it probably just goes to show something or the other :->

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

#45
post #15

Earlier quoted context omitted.

There are certainly some advantages to be gained from greater mechanical sympathy and an appreciation of static types. However, in the modern day, I wouldn't suggest a Python programmer learn C to achieve either of these things. For a Python programmer who just wants to learn about static type systems, learn Typescript. For a Python programmer who wants to learn about static type systems and mess around with pointers…

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.)

> Imagine trying to learn Rust without experience with C. Oh man.

I don't think it's that bad - primarily because error messages are way more helpful, but also because it'll error about things that C would just choke on at runtime.

(I learnt/continue to learn Rust with only 'university C', fwiw.)

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

#46
Yes! Or at least a language that gives you access to manual memory allocations.

I learned python, JavaScript, and Java before C, and it wasn’t until I learned about manual allocations, pass-by-value, and pointers that the garbage collected languages made sense. It had never really clicked why all object params are references in those languages until I learned C and C++

Now, I don’t think it’s essential, but learning more about how computers and memory operate doesn’t hurt!

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

#47
I think you should learn nim programming language against C. Yes, because nim can exporting C code when you write python syntax like nim language. Not all of them, also you can port as javascript and C++. Just try it out. Easy to learn, better way to write C and absolutely worth.

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

#48
A friend just finished a beginning Scheme + Java class, and asked me: How are languages like C++, golang, Rust, Lisp, Scala, and Python different.

Any pointers to a good video on the topic? "Overview/Survey of features in programming languages"? Thanks.

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

#49
Yes, but in my experience it will teach you more about the layer beneath (the machine) than it will about the layer above (Python.)

The technology we call “C” is not just the language — it’s the whole system of language, preprocessor, compiler, linker, assembler and debugger that comes together to produce and inspect machine code. In terms of computing machinery, there is no more fundamental target than this.

Accordingly, you should learn enough about the C ecosystem to be able to debug a C program. It’s enough to be able to read code in C, but you will want to write some to get a feeling for the culture (passing the address of where you want the result of a function as a function argument is the big one, and it’s accompanying subtasks around memory management and pointers.)

You don’t have to go inside the compiler itself but I would recommend looking at some simple machine code and trying to assemble some yourself. You could do this on arm or x86, or on an emulator like this one for high school students: https://www.peterhigginson.co.uk/AQA/info.html

Once you build a sufficiently complex bit of assembly code you’re going to want to extract out common “functions” and give them names, and develop a convention for how to use memory, which registers do what when you call a function.

That’s what a C compiler actually does.

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

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

It seems like many of these problems were holes in the curriculum more than weaknesses in Python. However, modern python has type annotations, which help a lot with checking the program for correctness.

I would say every one of these concepts can be taught with effective curriculum using modern Python.

Now, I still think one studying computer science would be well served to learn C at some point! But Python is a great replacement for Java in the curriculum.

Post reply on HN