3 ms·
I like the idea, but I feel like as soon as I'm caring about performance and looking at Python code, something has gone terribly wrong.
by dilap 11y ago
I like the idea, but I feel like as soon as I'm caring about performance and looking at Python code, something has gone terribly wrong.
- aw3c2 11y agoNot really. You can write Python fast and slow, so if you do write Python code, you can perfectly well care about performance. Learning C takes months to years while adapting my Python code takes minutes to days.
- ZenoArrow 11y ago> "Learning C takes months to years" Where did you get this information from? Learning C is easy. K&R is under 300 pages long, you could get through it in a weekend: https://en.m.wikipedia.org/wiki/The_C_Programming_Language https://en.m.wikipedia.org/wiki/The_C_Programming_Language After that you could pick up another more modern book, or could just learn as you go.
- aw3c2 11y agoIf you have CS background, lots of experience and are willing to manually allocate memory, maybe...
- ZenoArrow 11y agoNo, you don't even need that. C was either my first or second programming language, learnt it around the time I learnt VB and I didn't feel overwhelmed, was probably around 16 at the time, a time when my main experience with computers was playing computer games. Part of the reason for its popularity is its simplicity. Memory management isn't as hard to grasp as you might think. It's really just an extra step when it comes to handling variables, if you make plans to handle errors then it is straightforward to manage, especially for small libraries, which is what you're likely to write to link up to Python.
- aw3c2 11y agoYou should really check out how random people code in the real world. C is absolutely not the right language for "Dad" while Python is very easy to start with and do advanced stuff with. I am not talking about "programmers" but "people who manage to automate things on their computer".
- ZenoArrow 11y agoI've programmed in Python before, it's a good language, very broad library ecosystem, and yes it's a good first language as well, but if you're already familiar with imperative-style programming from Python you are not going to struggle with C, I am confident you could learn it quickly. If you've put off learning C because it's too 'hardcore' or some nonsense then try it out, you may be surprised to learn you like it.
- oldmanjay 11y agoC would make a great video game, it's easy to learn and difficult to master.
- ZenoArrow 11y agoSure, I'd go along with that. What I'd also say is that you don't need to be a master of C to write faster code than Python. I understand the appeal of keeping a codebase in a single language, but it's worth remembering you pay a cost for doing so.
- deleted 11y ago[deleted]
- TazeTSchnitzel 11y agoYou can't get through K&R in a weekend unless you skip the exercises.
- ZenoArrow 11y agoThe decision on whether to skip the exercises or not should be based on how you learn. I've found the most effective way for me to learn a new language is to watch or read some introductions to a language (to get a feel for idiomatic usage), then explore further through playing with small projects written in that language. That's what works for me. K&R is sold as a concise introduction to C, so it has value for learners like me even with skipping the exercises. Of course for people who prefer to learn methodically doing the exercises will be more beneficial.
- usrusr 11y agoBut the basics are pretty much the same, no matter if it is python or assembly: does this one-liner run entirely or mostly in L1 cache, or does it have to wait for RAM access repeatedly? Does it have to wait for disk or does it have to wait for network? Repeatedly? People who fail at this won't be able to understand the difference between situations where python or not doesn't matter much and those where it does. Understanding that "computers are fast" (even in python!) is a very important step towards understanding where we make them slow and whether that is because of waste or because the task is naturally expensive. Based on your skepticism i assume that you just haven't had much exposure to people who are really bad at these thing, despite having all the formal education (and the paycheck to match). "I'm working in ${absurdly high level language}, of course i'm not supposed to care for performance" is what they tell you before venturing off to make a perfectly avoidable performance blunder that would be crippling even in fully vectorized assembly, followed by a few days spent transforming all their code a different, but perfectly equivalent syntactic representation that looks a bit faster.
- dilap 11y agoGood points. & probably there are more python coders out there that could benefit from developing this kind of thinking than C programmers, so it makes sense from that perspective, too. (Side note: It's a trickier exercise in python than in C, which is itself a trickier exercise than plain assembly.)