3 ms·
Good succinctness is, to me, not having to deal with things irrelevant the context of whatever you're trying to accomplish. For example for (Iterator<Thing
by red_admiral 2y ago
Good succinctness is, to me, not having to deal with things irrelevant the context of whatever you're trying to accomplish. For example
for (Iterator<Thing> it = items.iterator(); iterator.next(); !iterator.done()) { Thing t = it.current(); ... }
is worse code than
for (Thing t : items) { ... }
in most cases (though there are exceptions such as if you need to call `it.remove()` or something like that in the loop occasionally).
Bad succinctness is when, for the sake of shorter code, you have to introduce rather than remove concepts that are not directly related to the goal you're trying to accomplish and that cause extra mental load next time someone's trying to work with that code. To avoid saying anything too controversial, I'm sure everyone can think of their own examples here.
- bad_username 2y agoI like to say that the best solutions tend to "look like" the problems they are solving. Solutions can't be succinct if the problem isn't succinct. But they can limit any new concepts to a minimum, reusing the concepts of the problem space as much as possible, and thus being succinct in that way. A great example of this is OOP (admittedly out of fashion today), which reuses the natural concept of "object" and its traits, making it easy to map the problem space to the code that provides a solution.
- jauntywundrkind 2y agoI've long long wanted a code-mod that can go add explicit typing to a file, and another that can turn it off. Yeah you can go poke around at your IDE and hover over things to see implicit types, but being able just read on the screen what everything is can be super helpful to newcomers or someone returning after a long weekend. It's also wonderful seeing the ripple of changes across the codebase as functions start returning different things, seeing explicit types update. Ideally we could write & get the succinct form, but be saving in code in explicit form. IMHO.