5 ms·
You’d think it would be common sense when writing something that other people will read. We don’t see people writing books in acronyms or omitting words. How c
by skellera 7y ago
You’d think it would be common sense when writing something that other people will read. We don’t see people writing books in acronyms or omitting words.
How come so many people try to use code to show how smart they are?
- quaquaqua1 7y agoIt's terrible. People use deliberate crypticness to flex on everyone who hasn't seen x subniche of programming style before. They designed it to be like this to be the gatekeeper at their organization.
- pdonis 7y ago> How come so many people try to use code to show how smart they are? Writing clever code doesn't mean it's being done for that reason. As the article notes, Guido himself agreed that in the early stages of developing a piece of software, such as in an early stage startup, it probably makes sense to write clever code, because you can get it done faster and therefore iterate faster on improving the code to meet user needs. At this stage very few people are working on the code (often just one), so communicating with other developers is not a big issue. The need for making it maintainable comes later, when the product is mature and many more people are working on the code, so the need for clear communication becomes much stronger.
- Cthulhu_ 7y agoYou say that, but then there's more advanced writings like scientific papers which will freely use domain-specific terms and / or maths; I'm not saying that's bad, it's just that because I'm not at home with these terms and / or subjects I won't invest the time in trying to decipher it. Also because unlike with code, I don't actually have to of course.
- chipgap98 7y agoThat metaphor doesn't hold up. Literature is full of allegories, figures of speech, allusion, and other forms of imagery. I agree that code should be as straightforward as possible, but I don't think books follow that rule.
- aksx 7y agoSometimes it's not about show how smart they are, developers aren't clear about the code they are writing. when I write code for a concept i don't understand completely, it tends to be complex and cryptic. I'll go back to it after trying to understand the problem and the problem space more and be able to write simpler code.
- Grue3 7y agoWe don't use code to show how smart we are. We just assume that other developers are as smart as we are. >We don’t see people writing books in acronyms or omitting words. Math books written for mathematicians do this all the time.
- rurp 7y agoI didn't take the comment to mean that other developers can't understand clever code, rather that writing overly clever code just isn't the best approach when a more plain solution will do. Writing code that takes another developer an hour to read through and understand wastes a lot of time compared to code that can be read and understood at a glance.
- hinkley 7y agoThis is most important when scanning code. When I’m trying to add functionality of fix a bug, I’m going to read dozens and dozens of functions to winnow down to a handful of candidates. Simple code can be filtered quickly and cheaply. Clever code requires contemplation. Which clears working memory. Yes, I can understand your code. But I shouldn’t have to work for it.
- Rychard 7y ago> We don't use code to show how smart we are. We just assume that other developers are as smart as we are. I think it would be more accurate to say that we assume that other developers have the same amount of context about the problem as we do. Going back and reading my own code from even a few months ago makes this very evident, as I frequently realize that I'd made various assumptions that required a much deeper level of understanding than I anticipated. The difficulty in providing a sufficient amount of context is readily apparent to me as I go back and fill in the gaps I unknowingly left.
- mathgladiator 7y agoThe key difference being operational ownership and business continuity. If all mathematicians (and I say this as a mathematician and math lover) just up and had a heart attack, then the world would probably not notice (as a whole). If a critical service is experiencing growth and built on cryptic stuff, then the world may notice if no one can maintain it and it falls over.
- cytzol 7y ago> How come so many people try to use code to show how smart they are? It's tricky, isn't it? The original quote was about "clever code" versus "maintainable code", but they are not orthogonal: it's possible to write code that's more maintainable (because it's harder to use incorrectly) at the cost of being more clever (because you need to learn more of the language or standard library to understand it). One person's "more maintainable" is going to be another person's "too clever" — you're going to get a bunch of different opinions on where the line lies. Not everybody is trying to show off their brains.
- wutbrodo 7y agoHonestly, if you're smart, it's just really fun to make things dense and logically concise. Think of it like a minor form of code golf. My first CL at my first job out of college was writing a state machine at Google. I remember collapsing it into this dense, elegant representation by hinging on a couple of bits of state. It took me an extra half day, but I was really proud of the end result, and I remember being mildly put off by the request that I unroll it and make it explicit. Upon thinking about it for a bit, I decided it was entirely reasonable, and after a few more years at Google, I transformed into the kind of engineer insisting that every bit of code prioritize readability over everything else, in the absence of constraints like performance. Across the tech orgs and teams that I've run since, this has paid huge dividends. I'm writing a lot of tensorflow and C++ at a very fast-moving company working on a complex problem, and I don't know how anyone on my team would be productive at all without strictly prioritizing readability. Being good at coding and having good engineering habits aren't the same skill, and the latter is about discipline and patience (and occasionally thinking like a dumber person), which are inherently less fun than unfettered technical challenges.
- hinkley 7y agoMy best friend in college was a writer, pursuing a BA in Literature. I’ve been thinking again lately about little bits I picked up via osmosis and my own early creative writing experiences. In fact I was just noting a couple weeks ago how refactoring resembles an exploratory writing exercise. I think we need to embrace the creative writing similarities. Would we ever celebrate an author who published efficient, dense and cryptic text? Rarely. One of the things we do want is someone who paints a clear picture in a few well chosen words. Another is to be inspired. Tricked or bored are not on that list.
- therealdrag0 7y agoLove the analogy. I'm a SE with a English degree. Maybe that is why I care so much (more than those around me) about editing code and finding the readability sweet spot.
- egypturnash 7y ago
- notkaiho 7y agoThis is a really good comparison and one I'm going to use going forward. Thank you.
- dwaltrip 7y agoPeople enjoy doing something clever. It takes experience and careful reflection to realize the downsides of being overly clever. It takes maturity to not give in to the guilty pleasure. It can also stem from boredom or insecurity.
- hinkley 7y agoI’ve ratcheted this up a notch with jr devs. When are you having fun reading someone else’s code? You’re usually there trying to solve a problem. Your plans for the day have gotten away from you. You may even be having a Bad Day. And this is at least doubly true for failing tests. Take pity on the person.
- marktangotango 7y agoI've also begun to stress this in code reviews and mentoring interaction but the question is; how to present this idea in a way that "early in their career" developers (and not so early) can appreciate? Simply admonishing them about "keep it readable!" isn't effective in my experience. An example that frequently occurrs is decomposing a large method into smaller methods. Okay, there are now more lines of code (due to adding method declarations), but what was really gained? The gain that can be had is identifying common use cases and factoring some of those methods out to utility classes that can be referenced from the same source file and others. This can be difficult to identify unless one learns to really look for these oppurtunities. The approach I've been taking recently is presenting the idea as there's always a minimal level of abstraction, and code should try to achieve it. I'm interested to hear what others think about this.
- mark-r 7y agoOne of the things I love most about Python is the ease of decomposing functions. The ability to return an arbitrary number of objects at the same time makes it really easy. Python not caring about the type of a parameter makes it easy to share code too.
- skywhopper 7y agoMuch of 18th century English-language literature was an attempt to show how smart the authors were...