Live data from Hacker News

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

news.ycombinator.com

61–70 of 93 posts

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

#61

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…

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

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

#62
Learn both at the same time :)

But, the twist is start from a higher level algebraic problem, like a generalized N-dimensional distance function.

Get started with enough Python to do it in two dimensions, then translate the core of your algorithm to Cython and compare the benchmarks. This will get you up to speed with the build processes progressing towards pure C in comparison to plain old interpreted Python.

Are you using floats or integers? How accurate is it compared to using a calculator etc. as the numbers get much bigger or have many more numbers after the decimal point.

Then, what about the median distance of two arrays of 2d coordinates? Again, benchmark, try out some different approaches to the problem in both languages and see where the different strengths lie, wrapping your head around how programs interface with each other internally across domains - because that's what it's all about right?

Now... what about 3 dimensions? Or four?

I hope you see where I'm going here, if you're looking for a fundamental understanding then you need to get into the nitty gritty - albeit with a conceptually very straightforward problem.

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

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

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

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

#64

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…

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.

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

#66

I would say it depends on what you want to do. I would choose Python for fast prototyping and proofing-of-concepts, C for performance-intensive apps.

I'd really rather recommend Nim [1] for performance-intensive apps. Its syntax resembles Python, it is far and away safer, but it complies (via generating C) to a full binary, and the resulting binary is very fast. Don't let the fact that it has a garbage collector scare you -- you can turn it off if you don't like it. 1: https://nim-lang.org/

Python has a much stronger relationship to C than Nim. Thus many would argue it would be a better recommendation to learn C, if a Python user. In the case of Nim, it would arguably be a language to learn instead of Python, as oppose to somebody who is already an advanced Python user.

Other strong choices of newer languages to choose from would be Golang, Rust, Red, or Vlang.

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

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

From https://news.ycombinator.com/item?id=28709239 :

> From "Ask HN: Is it worth it to learn C in 2020?" https://news.ycombinator.com/item?id=21878372 : (which discusses [bounded] memory management)

> There are a number of coding guidelines e.g. for safety-critical systems where bounded running time and resource consumption are essential. *These coding guidelines and standards are basically only available for C, C++, and Ada.*

> awesome-safety-critical > Software safety standards: https://awesome-safety-critical.readthedocs.io/en/latest/#so...

> awesome-safety-critical > Coding Guidelines: https://awesome-safety-critical.readthedocs.io/en/latest/#co...

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

#68
Most Python programmers will struggle with the lack of comparable functionality in the standard C lib. How do you tell a Python programmer that in C to use sets or a hash or a dictionary, that you need to implement them yourself or find a third party library? Also, how do you explain the C compile-link-run process to a Python programmer who only knows that Python just runs? A lot of basics are missing in C and in Python Programmers.

Maybe guide them to C++ for standard template library equivalence. But then you have another ocean of pain because C++ is the kitchen sink.

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

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

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.

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

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

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 things done you naturally pick up a deeper knowledge of the tech you're using.

Of course this is different for everyone.

Post reply on HN