Hacker News new | ask | show | jobs
by kibwen 1608 days ago
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, learn Go.

For a Python programmer who really wants to get elbow-deep in a natively-compiled language with a fairly sophisticated type system, learn Rust.

For someone who doesn't want to actually use C and just wants to learn concepts, C doesn't really have any advantages these days. Its type system is anemic, its compilers are unhelpful, its abstractive capabilities are poor and leaky, and its claims of being close-to-the-metal are overblown on modern processors. There are plenty of good reasons to learn C, but IMO "to become a better Python programmer" is not one of them.

3 comments

This is a fair point. Most of my response is driven by the fact that I think there is value in understanding a lot of the behind-the-scenes things that the language does, so I mostly agree. Really, I’d suggest learning as many languages as possible - they influence the way you think about the code you are writing and having the different perspectives allows you to broaden your horizons and see what else is possible. Eventually, this is how you form your opinions on what makes a programming language “good” and allows you to contribute to the decisions we all make daily over what technology to use and what becomes popular.

I still do think there is value in learning C, though. Of extant languages (disregarding assembly), I believe C is the ancestor of nearly every programming language today. From a historical perspective, understanding C and it’s shortcomings allow you to understand the motivations that created even higher level languages. Similarly, it would be hard to understand a lot of the decisions the C language makes without an understanding of assembly, why assembly instructions are as they are without understanding computer architecture, etc.

There is also an argument to be made that C is still extremely ubiquitous. I like Rust as a language very much and think there is a great deal to learn from it, but it is still so immature (though it has come a long way) that I would feel disingenuous suggesting it to someone who only knows python as a way to gain a better understanding of programming languages. I imagine it would be akin to encouraging a Buddhist to practice Lutheranism shortly after Luther’s schism rather than learn about Catholicism first - someone who does so would be blindly ignoring all the history and motives that drove that change in the first place.

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 is a good beginners language anymore with all its complexity. Maybe Go or Java.

> I don't think Python is a good beginners language anymore with all its complexity

It's not like the simpler parts of the language have gone away in recent versions. You can still program in python like it's 2.7.

Just as you can still program in C++ using C paradigms.

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.
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.
Good points. Though it would be a good debate that Go would be a better beginner language. Java's forcing of class based OOP would cause an avalanche of other kinds of problems that Go and C don't have to deal with.
Other than the 3 lines of boilerplate for the main method, Java ain’t forcing anything. You can write FP with it as well.

Also, it is probably better to get started with the much more common nominal typing over structural.

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

> 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 more than a week to a month anyway.

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

It's quite the opposite. Rust is a dream to learn compared to C. The Rust compiler is like having a personal tutor at your beck and call to teach you systems programming best-practices. Without exaggeration, these days I would not suggest someone start learning C until they have learned Rust.

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.

Thank you. This was well explanined. Once again thanks for this. I am learning and will continue learning Python and Js. However, when I decide to pick a static language I will definielty be going for Go.