Live data from Hacker News

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

news.ycombinator.com

81–90 of 93 posts

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

#81
NO!

You should learn some more fundamental aspects of programming:

1. What's the stack, what's the heap, why do I get a stack overflow from recursion?

2. In C, what's a pointer, how does it relate to arrays?

3. What's garbage collection, and how does it work?

And that will eventually lead you to the inevitable:

4. Why is Python so slow? (haha - getting ready for the downvotes!)

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

#82
post #63

Earlier quoted context omitted.

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…

Introduction to Algorithms is a classic that every serious programmer should read cover to cover.

at my first programming job (now almost 30 years ago), I remember implementing the red-black tree algorithms in C from that book. It is chock full of really useful ideas that will make your systems better.

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

#83
Let me ask that same question from the other direction:

If you're a (reasonably proficient) C programmer, is learning to use Python worth the effort? Or is it just redundant education?

I can see that learning Python is probably worth it for a new programmer, but is it worth it for a proficient C programmer?

[Let the flame wars begin!]

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

#85
post #64

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…

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.

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

#86
No. Would you then learn assembly to understand C better? Once you have the basics of syntax and semantics your next step is the OOP and FP paradigms used in Python for simple programs. Then a deep dive for a solid grasp of data structures and algorithms would be the last step. After you have these 3, you should be able to write mid to high level programs comfortably.

Which of these 3 aspects do you feel C would help you understand better?

Maybe you are asking this question because you want to understand programming languages and how they work in which case a course in compilers and programming languages from a MOOC would help.

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

#87

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

I agree with you, and at the same time, I notice your username says throwaway.

It seems liking the C language is frowned upon in this site.

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

#88

Let me ask that same question from the other direction: If you're a (reasonably proficient) C programmer, is learning to use Python worth the effort? Or is it just redundant education? I can see that learning Python is probably worth it for a new programmer, but is it worth it for a proficient C programmer? [Let the flame wars begin!]

I'm very comfortable with both, and there are definitely still use cases where I'll reach for Python.

E.g., Jax "just works" for a wide variety of numerical problems, handles the automatic differentiation and operator fusion and whatnot and figures out how to efficiently shove it onto whichever coprocessor(s) I want to target.

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

#89
I think it's more about the projects you work on than the language you use. C is a system programming language and most appropriate projects are compilers, operating system, classic console programming, embedded system programming and other low level stuffs.

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

#90
Yes, because learning C will teach you about computing and how your computer works. However C is not the only language that could teach you and you don't have to become fluent in it to understand enough to help your Python. Learning enough about a few languages (i.e being able to write something in them) will help you appreciate what Python does for you behind the scenes, but also how Python limits what you can do with it. Ultimately, if you master Python, you may want to write some packages for it that aren't written in Python and then C is a sensible choice.
Post reply on HN