logoalt Hacker News

johnmwilkinsonlast Sunday at 5:43 PM3 repliesview on HN

> 4. Clarity is seniority. Cleverness is overhead.

Clarity is likely the most important aspect of making maintainable, extendable code. Of course, it’s easy to say that, it’s harder to explain what it looks like in practice.

I wrote a book that attempts to teach how to write clear code: https://elementsofcode.io

> 11. Abstractions don’t remove complexity. They move it to the day you’re on call.

This is true for bad abstractions.

> The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise. (Dijkstra)

If you think about abstraction in those terms, the utility becomes apparent. We abstract CPU instructions into programming languages so we can think about our problems in more precise terms, such as data structures and functions.

It is obviously useful to build abstractions to create even higher levels of precision on top of the language itself.

The problem isn’t abstraction, it is clarity of purpose. Too often we create complex behavioral models before actually understanding the behavior we are trying to model. It’s like a civil engineer trying to build a bridge in a warehouse without examining the terrain where it must be placed. When it doesn’t fit correctly, we don’t blame the concept of bridges.


Replies

kenferrylast Sunday at 8:45 PM

I agree with you re: abstraction - one of the author's only points where I didn't totally agree.

But also worth noting that whenever you make an abstraction you run the risk that it's NOT going to turn out increase clarity and precision, either due to human limitation or due to changes in the problem. The author's caution is warranted because in practice this happens really a lot. I would rather work with code that has insufficient abstraction than inappropriate abstraction.

show 1 reply
nazgul17yesterday at 8:35 AM

All abstractions drop some details. If you're unlucky, you removed details that actually matter in some context. You can only make educated guesses.

Another aspect is that some abstractions are too... abstract. The concept they represent is not immediately obvious. Maybe it's a useful concept, but if it's new, it takes time to be internalized by someone for the first time.

carimuralast Monday at 5:02 PM

I've found that clarity is likely the most important aspect of success in general. Clarity in communication, for example, makes people feel invovled, heard, aligned. Cleverness is lots of acronyms and fancy phrases like vis-a-vis instead of just writing out what you mean so everyone can easily understand.