3 ms·
>Q: Should I write clever or obvious code? A: Always be obvious! I love this. I feel like so much JavaScript code I've seen over the past few years fails on th
by irrational 9y ago
>Q: Should I write clever or obvious code?
A: Always be obvious!
I love this. I feel like so much JavaScript code I've seen over the past few years fails on this account.
- bottled_poe 9y agoIt's about maintainability more than anything. I want a different developer to be able to jump in an understand a code base as quickly as possible. In my experience, unless there is a lot of duplicated code, it's usually much more cost effective in the long term to repeat yourself a few times (heresy I know).
- mhd 9y agoWhat's obvious to some is obtuse to others. Take iterating and filtering as a prominent example. For some, the functional approach highlights the operations themselves and avoids boilerplate. For others, the indentation of traditional loops and conditions alone is worth that. Usually there's a certain language culture attached to that. A Perl programmer sees "map sort map" and knows what's going on, everyone else is just going "Schwartzian what?". A big problem with JavaScript is that it doesn't have a culture that points in a specific direction, so you're bound to encounter all kinds of approaches, and none is really "native". Swift probably isn't as bad, but it'll hit the same cultural barriers from time to time, depending on the previous experience and general environmental conditioning of the programmers.
- kccqzy 9y agoI wholeheartedly agree. I’ll just mention that this is especially acute in Haskell. Haskell is widely considered to be a language with a steep learning curve, but for experts and experienced ones it is easy to lose track of how advanced the code really is and how obtuse it is to a beginner. The lens library is the best example. I often write extremely concise data structure manipulation code that composes lenses, prisms, getters and traversals, sometimes using (->) other times using Indexed as the profunctor. It’s obvious to me but I’m sometimes told at code review time that it’s too hard to understand.