3 ms·
It is often the case that the simplest solutions require the greatest skill in achieving. Thus, I agree immensely with avoiding unnecessary complexity whenever
by userbinator 9y ago
It is often the case that the simplest solutions require the greatest skill in achieving. Thus, I agree immensely with avoiding unnecessary complexity whenever possible, but not "We should endeavor to write code that a novice programmer can easily understand without explanation or that a maintainer can understand without significant time investment." --- which tends to lead to extremely verbose, inefficient, and dumbed-down code.
In other words, if you only ever use the very simplest features of the language, you are effectively reducing micro complexity but increasing macro complexity. One of the best examples of this is the classic arguments over the use of the ternary/conditional (?:) operator --- those against say it's hard to read and should always be replaced with if/else, while those for say it simplifies the code by removing redundancy and should always be used in place of an if/else with a single assignment statement with the same LHS in both clauses.
Similarly, if you believe programmers are almost completely incapable of understanding operator precedence, or that it "makes code hard to read" and restrict expressions to only one operator (and mandate that variables be created for all intermediate results), then you will get code with all the verbosity of Asm but none of the benefits.
In other words, good code may not be immediately obvious; but your reaction when you do understand it should be one of pleasant enlightenment, and not "I can think of a simpler way to do this."
A somewhat related article: http://typicalprogrammer.com/what-does-code-readability-mean http://typicalprogrammer.com/what-does-code-readability-mean
- quickthrower2 9y agoYes definitely. If you code using a VB6 style subset of your language you'll probably end up with spaghetti. That's easy to understand at an individual procedure level but pretty hard to refactor and maintain.
- flukus 9y ago> If you code using a VB6 style subset of your language you'll probably end up with spaghetti Unless I'm remembering incorrectly I'd say the opposite, vb6 had a pretty sane feature set comparable to "modern" languages like go and rust. Coding with that feature set will give you simple and understandable code, if a little verbose at times. The spaghetti code it's famous for was mostly a result of the event driven, drag and drop nature of the IDE and community. If you want real spaghetti code then try vb.net which suffers from the same problem but allows devs to pile on a bunch of OO features that obscure what code is doing.
- quickthrower2 9y agoI disagree. I think OO can make things a lot simpler. But the fact that I disagree is just an example that there is no one 'correct' style, it depends on taste and the team should decide based on their needs.
- majewsky 9y ago> vb6 had a pretty sane feature set comparable to "modern" languages like go What's not sane about Go's feature set? (Except for its debatable omissions.)
- juki 9y agoI think you misread that. They said "comparable to" (equally sane), not "compared to".
- SatvikBeri 9y ago> It is often the case that the simplest solutions require the greatest skill in achieving. Totally agree, and I think this is what a lot of the "keep code simple" articles miss. To create something simple, you almost always have to create something complex first. All the best designs I've seen created were the result of 10+ iterations and several major refactors.
- TeMPOraL 9y agoSeconded. It's getting ridiculous at times. I've seen cases when people complained about "too complex" features in a language, where it would take them literally two hours to acquire necessary understanding, and become more productive forever. But no, it's easier to keep wasting much more time complaining. It smells of extreme anti-intellectualism. Code is meant to be read, yes, but to be read by educated people. Programming is a profession, and it's unreasonable to artificially handicap everyone in a company just because some people can't be bothered to spend even just a little time learning if they don't understand something.
- diaz 9y agoI like the idea of "Simple doesn't mean it's not hard". For a newbie in a number of subjects many things may seem complex but are actually quite simple once you study enough of the concepts or theory behind something. Sometimes to see the beauty of simple there's not other option then learn more. And I'm against of trying to avoid people to learn something that is worth it but may be new just to keep the status quo of any anybody should be able to understand it even without any knowledge of things making it more complex instead.