4 ms·
When did "clever" become synonymous with "overcomplicated"? To me, clever code is maintainable code. If you can't understand code, either it is not maintainabl
by palata 3y ago
When did "clever" become synonymous with "overcomplicated"?
To me, clever code is maintainable code. If you can't understand code, either it is not maintainable, or you don't master the language at the required level.
The thing is that it depends. "Ternary operators are too hard" is not an absolute truth. I would argue that sometimes they are more readable, sometimes not. Same for recursion and everything. The art is to find the balance, and even there, there is not one universal truth.
If my interns need to learn things, that's not a problem for me. The goal is not for the interns or my grandmother to maintain my code. The idea is that the maintainers maintain it. If they find it maintainable, then it's hard to argue that it is not.
- adhesive_wombat 3y agoIt's one of those tongue-in-cheek mis-statements that make it into common usage, lose their scare-quotes or italicisation and become a different definition of the same word. Other examples: * "Literally" used in a way to refer to something that's clearly figurative * "Non-trivial" used in a way to refer to something that is clearly extremely complicated Much as I like to decry abuse of language¹, at some point one has just accept that a headword has gained a new bullet-point in the dictionary and move on. 1: and speaking, or, rather, attempting to speak, the Queen's^W King's English, the modern American-centric world certainly delivers opportunities for that!
- teddyh 3y ago“Articulate”.
- peteradio 3y agoIt's like when the electrician comments on some of my own electric handiwork. I believe he called it "nifty".
- palata 3y agoSure, I'm fine with that. I guess my point is that those posts, to me, just try to convey that one should write good code, and that good code is not necessarily using all the tricks in the book (rather not). But then they tend to go as far as to say "never use this concept, because it's too complex", or even go towards wishing that the language did not offer any "clever" features, which I disagree with. Yes, write good code, as in "maintainable". But don't say that a concept is always bad (be it tertiary operators, recursion or templates). It depends on the language, project and situation.
- drewcoo 3y agoSmart code good; clever code bad. Smart code is maintainable. Clever code is not. Smart code takes complex problems and simplifies them in a way that makes them easily understandable by the whole team. Clever code, whether the original problem was complex or not, presents a complex solution that's difficult to follow. Have you ever poured a lot of work into something only to have a coworker say "how simple - I thought that would be a lot harder?" That's smart code, but your coworker was expecting clever. Those are the meanings people are using in the conversations about clever code.
- palata 3y agoRight, I'm completely okay with that. I guess I just don't understand why there are regularly blog posts trying to explain what should be common sense: "write code that it nice to read and maintain". The thing is, getting to the point where you can write good code takes experience, not blog posts that say that recursion and tertiary operators are always "clever".
- dragonwriter 3y ago> Right, I'm completely okay with that. I guess I just don't understand why there are regularly blog posts trying to explain what should be common sense: "write code that it nice to read and maintain". Because “nice to read and easy to maintain” is a goal, not something trivial to evaluate while writing (especially the easy to maintain, which, among other things, is dependent on what the actual future needs will be), and acheiving that involves balancing competing factors, opinions on how to do it conflict, experience of what works varies, and clear and applicable science about both the broad trends and what explains specific variations from the trends is sparse.
- theshrike79 3y agoI have been the maintenance programmer for multiple legacy projects. I don't have the time or motivation to "master the language at the required level". I want to get in, fix the code, test the fix and get out. That's what I get paid for, not spending weeks to become an expert in Language X's clever code tricks and hacks. "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." You can be clever and terse in your own projects, please write readable code with comments. Even if something is 150% clear to you while writing the code, it might not be for the next person - or yourself 5 years later.
- palata 3y agoAgain, you are assuming that I mean "overcomplicated code" when I say "clever". To me, clever code is meant to be readable. Sometimes a recursion is more readable, sometimes it is not. I am just saying that the choice of what is "overcomplicated" comes to the maintainer. My project, my rules. If you don't want me to use lambdas in the project you maintain, that's your choice (and it is my choice to contribute or not). I just don't agree when people say "don't use tertiary operators ever, because I don't like them". Interestingly, I go further than you: good code to me mostly doesn't need comments. Comments are there for the more complicated parts, but most code should be readable as-is. I guess we mostly disagree on what is too complicated :).