4 ms·
Is there a different, more robust way to describe code size than lines or perhaps even characters/size? Could we describe “ideas” or “logical units” in some wa
by Waterluvian 4y ago
Is there a different, more robust way to describe code size than lines or perhaps even characters/size?
Could we describe “ideas” or “logical units” in some way? Or maybe just count the number of keywords and operators?
I find that “lines” is so popular but almost always misrepresents simple code as being more complex, and complex code as being simpler.
Of course, lines, like in this post, can be a perfectly helpful answer to a question if the question isn’t “where’s all the complexity?”
- blowski 4y agoThe book "Your Code as a Crime Scene" has a number of interesting techniques and tools for this. https://pragprog.com/titles/atcrime/your-code-as-a-crime-scene/ https://pragprog.com/titles/atcrime/your-code-as-a-crime-sce...
- txutxu 4y agoAgree with this, but the openbsd codebase, tends to be pretty consistent in style conventions and layout. Fortunately, the word complexity was not used there, and it's nice to see if this subsystem, or protocol, or driver, etc takes two orders of magnitude more than the others.
- mejutoco 4y agoI like cyclomatic complexity, and Kolmogorov complexity. https://en.wikipedia.org/wiki/Cyclomatic_complexity https://en.wikipedia.org/wiki/Cyclomatic_complexity https://en.wikipedia.org/wiki/Kolmogorov_complexity https://en.wikipedia.org/wiki/Kolmogorov_complexity
- tialaramex 4y agoI guess technically Kolmogorov complexity is an answer to their question since they said "describe" but I expect Waterluvian was thinking "measure" and you can't really measure Kolmogorov complexity for real programs. It is mostly useful for proofs or thought experiments. You can try to measure Cyclomatic complexity, so that's more useful in practice.
- Aeolun 4y agoIf only someone posts tomorrow with somethhing similar to cyclomatic complexity.
- TheRealPomax 4y agoKolmogorov complexity is borderline useless if the idea is to describe code size or code complexity for humans, though. It only describes programs in terms of "what is the smallest (fully qualified) program that would generate something that ultimately leads to the original result", completely removing both the human, as well as the original code in question, from the equation. And to make matters worse, we don't actually know how to calculate the true Kolmogorov complexity of anything because humans are notoriously bad at figuring out what "the smallest program" actually is, so it's a great device for reasoning about complexity, but it's a near useless device for determining actual complexity.
- mejutoco 4y agoI agree with you and tialaramex above, and I was hesitating including it for this reason, but I think it is very useful as a thought experiment. I find it a very elegant concept about complexity (even if not very practical), and wanted to share it regardless to be honest ;)
- fennecs 4y agoUse a programming that is decoupled from stateful manipulations and control flow? Programming does not need to involve itself with the hardware, that’s just a tool for evaluation. A program is an idea expressed in a language. It’s some formal statement of intent. Sometimes we can evaluate it to produce an output. Sometimes these statements are muddied by underlying representations. The length of a declarative program seems a pretty good rough measure of complexity in the way you are talking about. Operational complexity of course, in the number of steps to actually evaluate it is a bit different, based on what you are using.