5 ms·
I'd have to be running that billions of times a day before I'd start to care about the extra nanoseconds. Clean-looking code makes me feel better than having my
by jazoom 8y ago
I'd have to be running that billions of times a day before I'd start to care about the extra nanoseconds. Clean-looking code makes me feel better than having my servers sit at 67.3% CPU instead of 67.4% CPU.
- williamdclt 8y agoI'd take cleaner code for half the speed quite often!
- neuland 8y agoI see that you too are a Python developer! /s
- acdha 8y agoThere’s a serious point: cleaner code makes high-level optimizations easier and those are usually far bigger wins. I’ve seen more than a few times where Python, Perl, etc. beat hand-tuned C because the C used so many clever tricks that nobody wanted to change it.
- neuland 8y agoI absolutely agree! I use python like 70% of the time, and accessibility is one of the big reasons for that. Just making a joke.
- acdha 8y agoYeah, wasn't criticizing you. I think one of the signs of experience is when people go from just laughing at that to laughing and thinking more deeply it.
- kungito 8y agoHow is a language which doesn't have a type checker a synonym for clean code?
- acdha 8y agoPython's readability helps a lot — I've seen a ton of code in statically-typed languages where a bug was obscured by the syntactic boilerplate and nobody noticed that, say, they were calling the correctly type-checked function with the wrong variable, casting it incorrectly, etc. If the language or popular frameworks encourage boilerplate that's especially effective at getting people to skim over important details. Newer languages with solid type inference help a lot for reducing that cognitive load, so this isn't saying that one side of the static/dynamic-typing debate is wrong but rather that it's an important design factor for programmer productivity.
- viraptor 8y agoCheck out mypy. It works well.
- fulafel 8y agoPython does a lot of type checking and complains loudly, very different from eg Javascript.
- coldtea 8y agoBesides, whether it complains or not about misused types, says nothing about the code being clean or not. One can write totally unreadable code in Scala and a totally readable version of the same algorithm in Python if one so wishes.
- coldtea 8y agoHow is a type checker or the presence of types synonymous with clean code? The two are totally orthogonal concerns. You can write highly obfuscated spaghetti code from hell in any type checked language you wish...
- taf2 8y ago0.01 is kind a big deal if you do that a few 1000 times though right ?
- rootlocus 8y ago0.01 is the resulting speedup in CPU usage (overall performance). It factors in the call count.
- jazoom 8y agoThis is what I meant. I suspect the 0.01 probably encapsulates ALL these little sub-optimisations I decide on in a code base, rather than just this one variable swap. CPUs are a lot faster than most people realise. It's usually other things that slow down a program, not whether the programmer uses array.forEach or a basic for loop. Disclaimer: I do tend to use for loops a lot since they can be quite readable.
- pjmlp 8y agoYeah even on the days when serious applications on the 16 bit platforms were written in Assembly I hardly felt the need to disable bounds checking in Turbo Pascal, except in cases when the solution was to re-write the function in Assembly anyway.
- noiv 8y agoWhatever leads to 60fps on client-side is welcomed.
- mlazowik 8y agoIf you hit a hot path the impact can be way higher. Especially if you're running client-side and want a fluid experience. Example: https://github.com/facebook/react/pull/12510 https://github.com/facebook/react/pull/12510 But definitely agree that cleaner code > performance in most cases. First make sure you really do need to squeeze that performance out.