5 ms·
"Simple code" -> very difficult to decipher use of SIMD intrinsics. Yikes. He may have deleted 1000 lines of code, but he'll need a 2 hour inline video (with a
by aetherspawn 5y ago
"Simple code" -> very difficult to decipher use of SIMD intrinsics. Yikes.
He may have deleted 1000 lines of code, but he'll need a 2 hour inline video (with a 1000 line transcript) to explain how it works.
- dralley 5y agoEven if he had stopped before hand-rolling the SIMD, it'd still be a multiple order of magnitude improvement. I do think it would have been useful to demonstrate that before going straight to hard mode.
- werner1886 5y agoHe measures code 'simplicity' by how much work it makes CPU do, and not some made up metric like 'readability'.
- philosopher1234 5y agoHow exactly is readability made up?
- werner1886 5y agoWe might be thinking about different things here, so let me first ask this: What do you want to measure?
- RedShift1 5y agoSimple example: I love the ternary operator and use it quite a lot in simple "if/then" scenarios. However some people hate them because they consider them harder to read than the fully written out if/then form. Those people would judge my code less readable.
- dsego 5y agoTernary operators are better for expressions, which yield a result, since you don't have to declare or initialize a variable with a dummy value first. If/else is better for general branching. Using ternary without assigning or passing the expression would imho be misleading. I've seen ternaries used for branching and it's a smell imho, they're not really meant for that use case.
- generichuman 5y agoIt is not made up but different people can have different opinions on what's readable and what's not. If the metric is supposed to be objective, then number of CPU cycles used is probably the simplest metric there is for computers.
- meheleventyone 5y agoRight it’s a communication problem because calling code simple conjures different ideas in people heads. Code that is simple for computers (principle of least work) is not necessarily simple (principle of comprehension?) for humans.
- flohofwoe 5y agoThere is a high overlap though, it's often harder to understand how highly abstracted code actually works than 'unrolled' verbose code composed from simple operations (which is closer to machine code - thus the 'overlap'). It might be easier to understand the 'intent' of highly abstracted code, but this doesn't mean the code behaves as intended, and IMHO 'readability' is about understanding what the code actually does, not what it is supposed to do.
- meheleventyone 5y agoI think all these things are aspects that are interrelated. A principle of abstraction is another good one. Others I can think of are principle of least surprise and principle of least work done by the compiler (lol “zero cost” abstractions).
- matiasmolinari 5y agoThis is a good question to ask, if not rhetorical. When practicing rigorous measuring, quantities need to be quantifiable aspects of the world. For example, you can quantify how much physical space your code or compiled output takes up in memory, and use these quantities as base units to derive others. By branching from a quantifiable root, you can derive metrics such as lines of code or number of CPU instructions, and they’d still retain those quantifiable aspects. Meaning there’s a clear path to the quantifiable root. Needless to say, readability, as a metric, is not branched from quantifiable aspects of the world. So in a sense, it is still a “made up” metric because (as of today), there’s no way to trace it down to the quantifiable measurements.
- meheleventyone 5y agoI’d note that because something is hard to measure doesn’t make it “made-up” or unimportant. And that concentrating on things that are easy to measure doesn’t make them more important and in fact can bias things badly.
- dsego 5y agoI think the poster is using the term “made-up” in a stricter sense to categorize it, not just to be dismissive.
- MikeDelta 5y agoReadability can be quantified and it done by static code analyzers into a metric known as cognitive complexity [0], which measures things like amount of branches in your function. The thing is, you can make code of low complexity but still hard to read. [0] https://tomasvotruba.com/blog/2018/05/21/is-your-code-readable-by-humans-cognitive-complexity-tells-you/ https://tomasvotruba.com/blog/2018/05/21/is-your-code-readab...
- matiasmolinari 5y agoSure. You can trace branches to quantifiable roots, but you can’t trace readability. To me, readability means something different than what it means to the author of that article.
- flohofwoe 5y agoCode readability is at least extremely subjective, one person's highly readable code is another person's incomprehensible mess.
- bruce343434 5y agoHow can you objectively quantify it?
- deleted 5y ago[deleted]