▲ | marginalia_nu 10 days ago | |||||||||||||||||||||||||
I think it's pretty tiresome that "smart authors" are blamed for writing complex code. Smart authors generally write simpler code. It's much harder to write simple code than complex for reasons that boil down to entropy -- there are simply many more ways to write complex code than simple code, and finding one of the simple expressions of program logic requires both smarts and a modicum of experience. If you try to do it algorithmically, you arguably won't find a simple expression. It's often glossed over how readability in one axis can drive complexities along another axis, especially when composing code into bite-size readable chunks the actual logic easily gets smeared across many (sometimes dozens) of different functions, making it very hard to figure out what it actually does, even though all the functions check all the boxes for readability, having a single responsibility, etc. E.g. is userAuthorized(request) is true but why is it true? Well because usernamePresent(request) is true and passwordCorrect(user) is true, both of which also decompose into multiple functions and conditions. It's often a smaller cognitive load to just have all that logic in one place, even if it's not the local optimum of readability it may be the global one because needing to constantly skip between methods or modules to figure out what is happening is also incredibly taxing. | ||||||||||||||||||||||||||
▲ | baobabKoodaa 10 days ago | parent | next [-] | |||||||||||||||||||||||||
When an article like this uses the term "smart people", I'm always a bit confused if they mean actually smart people, or not-that-smart-people-who-think-highly-of-themselves. Because there's a lot more people in the latter category, and in my view they are the ones building unnecessary complexity into codebases. To clarify, when I say "not-that-smart-people", I don't mean "stupid people". You need to be beyond some basic level of intelligence in order to have the capability to overcomplicate a codebase. For lack of a better metric, consider IQ. If your IQ is below 80, you are not going to work day-to-day overcomplicating a codebase. You need to be slightly above average intelligence (not stupid, but also "not-that-smart") to find yourself in that position. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | aDyslecticCrow 10 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
I like to call that a leaky abstraction. The author used "UNIX I/O" as a great example. It perfectly hides the complexity and abstraction is such a way that the programmer never needs to know the internals. It has sealed all the juicy complexity in a watertight container that the user of the abstraction never needs to peak inside of. The auth example may not be. You may need to do validatePassword(user) for passwordCorrect(user) to be true, which then forces you to open up a hole in the abstraction that is userAuthorized(request) and peak inside. userAuthorized() has leaked out its logic, it has failed as an abstraction. Its a box with 3 walls and no roof that blocks visibility to important logic rather than hides away the complexity. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | incognito124 10 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
You reminded me of a rule of thumb that says: Keep the complexities in data structures and simplicity in algorithms | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | weiliddat 10 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
> It's much harder to write simple code than complex for reasons that boil down to entropy -- there are simply many more ways to write complex code than simple code, and finding one of the simple expressions of program logic requires both smarts and a modicum of experience. Also effort, there are smart people who couldn't be bothered to reduce extraneous load for other people, because they already took the effort to understand it, but they don't have the theory-of-mind to understand that it's not easy for others, or can't be bothered to do so. > I have only made this letter longer because I have not had the time to make it shorter. - Blaise Pascal Good rule of thumb I find is, did the new change make it harder or easier to reason about the change / topic? If we go back to the concept of cognitive load, it's fine cognitive load goes up if the solution is necessarily complex. It's the extraneous bit that we should work to minimize, reduce if possible. | ||||||||||||||||||||||||||
▲ | st3fan 10 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
"Smart authors generally write simpler code" I don't like to generalize. You are lucky then. I've definitely worked with super smart engineers who chose incredibly complicated solutions over more simpler and pragmatic solutions. As a result the code was generally hard to maintain and specially difficult to understand. It is a real thing. And it generally happens with "the smart ones" because people who don't know how to make things complicated generally stick with simpler solutions. In my experience. | ||||||||||||||||||||||||||
▲ | peacebeard 10 days ago | parent | prev | next [-] | |||||||||||||||||||||||||
It’s really easy to generalize. Some smart people write simple, maintainable code. Some smart people find it fun to over-complicate. Neither is useful as a generalization in my opinion. | ||||||||||||||||||||||||||
▲ | zahlman 9 days ago | parent | prev [-] | |||||||||||||||||||||||||
> Smart authors generally write simpler code. It's much harder to write simple code than complex for reasons that boil down to entropy -- there are simply many more ways to write complex code than simple code, and finding one of the simple expressions of program logic requires both smarts and a modicum of experience. The people writing the complex code generally seem to think they're smart. That was me, once. And I was smart, but I was also applying my smarts very, very poorly. |