Simplicity vs Complexity

Several different definitions of 'complexity' at work here, of course. The relevance of each is just a function of the practical context.

  • In terms of formal time complexity (Big 0), the complexity of your draft there is increased by the repeated remeasuring of the length of the currently longest string.
  • In terms of space-state complexity, any use of an imperative mode is massively more complex than use of a declarative or functional mode, because the references of names like theLine, longestLine are going through a whole series of mutations.
  • In terms of operational complexity and code reuse, naked code is more complex to reuse than a wrapped function
  • In terms of single lines of new code required (sloc), 8 new lines is more complex than 1 new line

etc etc etc . Real 'simplicity' entirely depends on which part you need to simplify, and why, and for who.

In my context I usually need cognitive simplicity, and simplicity of reuse.

Just writing

maximumBy(comparing(|length|), paragraphs of the clipboard)

(and importing the rest) has one kind of simplicity,

8 sloc of fresh unwrapped imperative code ('first I set this, then I repeatedly do that, finally I return the other' etc, has another ...

'Simplicity' is more complex than it looks : - )

( and not always easy to disentangle from familiarity, which is often what people really mean by it )

3 Likes