News for hackers. Stuff that matters.
Re:Rules for Developing Safety-Critical Code (2006) [pdf] by kragen on Friday October 18, 2019 @02:10PM (#21293694)
Code made of 5-line functions is more flexible; it can be more easily made to do things its original author did not anticipate. Code made of 50-line functions is more verifiable; its author can more easily anticipate which things it can do.

Flexibility increases when there are more things the code can do. Verifiability increases when there are more things the code can't do.

Of course most code could be simultaneously improved in flexibility and in verifiability, but ultimately there's a tradeoff.

Re:Rules for Developing Safety-Critical Code (2006) [pdf] by marcosdumay on Friday October 18, 2019 @06:06PM (#21295442)
I do think you got the correlation correct, but causality inverted.

Abstract problems have the complexity removed from them, what leads to smaller code chunks (be them functions, classes, modules, declarations, whatever). Those are also more reusable and flexible, because they are focused on general features.

Concrete problems can not have the complexity removed from them. That leads to large chunks of code and an implementation that can not be used for different things. That is the code that is expected to specialize those abstracts chunks from above into something that solves a real problem.

All that people naively claiming that they've "seen short code and it is so much simpler to understand. Why can't everybody just write short code?" are completely missing the point.

Re:Rules for Developing Safety-Critical Code (2006) [pdf] by kragen on Saturday October 19, 2019 @01:35PM (#21299638)
You're describing indirection, not abstraction. Indirection is bug-prone, improves flexibility, and produces smaller functions. Sometimes it can be a means of getting abstraction, but it is not the only way.

As an example, DGEMM is a very abstract function, applicable to rotation in 3-D space, Markov-chain occupancy computations, finite-state machine simulation, ANNs, and numerous other applications. But it doesn't use indirection. And it's not a particularly short function. (The same is true of most of the rest of LAPACK.)