Comment

Comment by rtpg

There's this general idea that I've found quite illuminating, where physical code size in itself can cross a certain limit and suddenly take more time to read.

Something like (+ 5 (* 3 2)) is, IMO, an easier think to parse than add(5, multiply(3, 2)). 5 + (3 * 2) obviously wins some points from being what we get taught for a decade.

So if you have these sorts of idioms that are meant to be within other idioms, stuffing them all in one line means there's less place for issues to hide, without paying size costs.

The real thing of course, is less the above example and more things like:

results = [2 * x for x in data]

turning into:

results = [] for x in data: results.append(2 * x)

Where in one version I immediately pattern match on a comprehension, so I can immediately determine cardinality and other properties, where the other one I gotta do a _touch_ more work mentally. This feels like it doesn't matter, but it all adds up!

Terseness is a quality, especially if everyone messing with the code speaks the same vocabulary.

parent rtpg 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton