3 ms·
I keep to a simple rule: smart code is an asset, clever code is a liability. Smart code is usually simple and clear, while also being short and efficient. Achi
by nine_k 2y ago
I keep to a simple rule: smart code is an asset, clever code is a liability.
Smart code is usually simple and clear, while also being short and efficient. Achieving this is not easy, but reading, understanding, and using smart code is easy. (Otherwise it's not smart, but, well, ordinary.) An example of smart code for me would be the merge sort algorithm, or the Lisp interpretation loop.
Clever code is usually some kind of last-resort hack, a trick, applied in dire straits, or to achieve a unique effect. An example would be the inverse square root hack, or the Duff device.
Beside the actual writing time, code review time is good for making code smarter and less clever.