3 ms·
> when it comes to day-to-day production code, here's the barometer I like to use: will a junior developer, someone at the very start of their career, struggle
by yawboakye 3y ago
> when it comes to day-to-day production code, here's the barometer I like to use: will a junior developer, someone at the very start of their career, struggle to understand this code?
this is one of the stupidest things ever said about any piece of code. how about you give that feedback to beethoven (and other great composers)? hey beeth, can you please make your music piece so simple that a junior pianist can play it? this thing over here requires too much study and virtuoso to play, and that's not something we want to aspire to.
or to euclid: hey can you remove this _pons asinorum_ here? i have a beginner whose struggling to understand the isosceles triangle. clever code is art to be studied and enjoyed. they are the vehicles of growth, of new and important ideas. holding them off for the sake of a proverbial junior is stupid.
- wk_end 3y ago> clever code is art to be studied and enjoyed. Cool, great, save it for the Obfuscated C contest. The less time I spend “studying” someone else’s idea of cleverness while trying to fix ticket #51483 or implement some weird business logic corner case the happier I am.
- cookieperson 3y agoPretty sure 99% of the world agrees with you here. If someone wants to write twenty nested closures that compose some category theoretic construct in some ancient academic paper instead of two function calls using an already imported library they can go to their museum or whatever to be studied. The rest of us have shit to do...
- endisneigh 3y agoYou say it’s stupid but don’t really elaborate on why. You imply there’s some excellence cliff that presumably cannot be reached if you cater to beginners but that’s hardly the case. Simplicity and complexity, beginner and expert are not inclusive things.
- yawboakye 3y agoapologies. please refer to https://news.ycombinator.com/item?id=36117455 https://news.ycombinator.com/item?id=36117455.
- okl 3y agoWriting code in a way that it can be understood by coworkers is a prerequisite for collaboration.
- wizofaus 3y agoSurely that's completely missing the reality that the reason code is hard to understand is virtually never because of whether you're using some particular syntactical feature like ternary expressions* - it's because the features you're working on are complex and there's a bunch of interactions between lots of different parts of the software, and it takes a while to get your head around all of them. On the other hand, poorly named functions and variables, poorly constructed interfaces, tight (but non-obvious) coupling between different units of code and a lack of a straightforward way to walk through various paths of the code (e.g. via unit tests) are the sorts of things that make code especially incomprehensible and hard to work with, and for that reason, the sorts of things I'll flag in a review. If I see syntax I think looks a little ugly or unnecessarily "clever" I'll usually add a comment and a suggestion but it still generally gets a tick. (*) even the example given in the article of an obviously unnecessary use of "reduce" is pretty rarely representative of the sorts of reasons code is hard to understand, though I have come across similar things in 3rd party open-source libraries and the like - I would say though these days you could almost certainly get ChatGPT to explain particularly obscure uses of map/reduce etc. Whereas it's never going to be able to explain high-level behaviour that requires the entire codebase.
- leetrout 3y agoI think you are proving the authors point quite well. Composing music to be performed if very different than sharing the composition of it with many composers. There is meter and scale and notation but only so many ways you can express things with the most complex being complicated meter. Now performing that - yes - more complexity but not in the composition. We dont need programmers to "perform" in every CRUD app on the internet. We arent all writing game engines, gpu drivers, etc etc. There are Beethovens out there doing things that require phenomenal skills (that can be learned) but its not 1:1 with composing music with performers limits in mind when the composer didnt HAVE to collaborate.
- symmetricsaurus 3y agoMaking code simple is not easy. In your analogy I think the listener should be the junior programmer. Music by Beethoven can be appreciated by many more than just the people who can compose on that level. In the same way you can write code so that also junior developers can appreciate it. The challenge lies in clearly expressing solutions to complex problems.
- smarkov 3y ago> clever code is art to be studied and enjoyed. they are the vehicles of growth, of new and important ideas. I don't think you quite got the idea this article was trying to convey. Here's a simplification: Don't make simple things look hard. Hard problems require convoluted solutions, however those solutions can still be broken down into simpler steps. Don't obfuscate the simplicity, allow all the simple parts to work together to create something complex.
- yawboakye 3y agohard problems don't require convoluted solutions, i think. the nature of simplicity is that, if aspired to, it could be realized in the small as well as the big since it really is a description of cohesion. i understand that starting a conversation about simplicity will lead us nowhere: there are as many opinions/definitions of 'simple' as there are people in the world. in this statement lies the fact that regardless of level of experience (related or unrelated), a priori intelligence, and general disposition towards new things, we have our expectations of simple. that can't be right! we need to learn new simpler forms that require higher intelligence to grasp. to the initiated, einstein's equation is simpler than newton's because it allows a lot more derivations that were impossible with newton's. i suggest that we deliberately move people towards einstein's as the new simpler forms. in the example code the author showed, they appeared to identify advantages that are on net better for any software application. they should adjust their expectation of what simple is, and make an effort to help so-called juniors move up a level or two so that they can develop more powerful simple forms.
- vlzdr 3y agoI wouldn’t use such strong words, but you’re right. Not everything needs to be made for beginners. I keep remembering what Rich Hickey said that seems relevant: We should not sell humanity short by trying to solve the problem of beginners in our stuff. We need to make things for people to use, and we need to teach people and trust people to be able to learn how to do that. https://youtu.be/QCwqnjxqfmY?t=1914 https://youtu.be/QCwqnjxqfmY?t=1914, https://youtu.be/QCwqnjxqfmY?t=2063 https://youtu.be/QCwqnjxqfmY?t=2063