UP | HOME

Quality and craftsmanship

High quality programs are such that are reliable and also reasonably easy to understand, modify, and maintain.

Ease of understanding does not only imply readability, which in turn implies composition of small functions from small, specialized modules, but also an adequate mappings (arrows, literarally) from the major concepts of the problem domain to corresponding algebraic types (records and tagged disjoint unions).

Proper structuring of the code contributes to more convenient modification and maintenance, but the main tool is an advanced type system which assist in catching dumb errors, typos and saves a lot of time in general.

Defining functions by universal (which means function clauses and every binding in general) pattern-matching goes even beyond a type-system, by providing means of talking about shapes of the type-tagged values, where data-constructors correspond to type-tags.

Having just these techniques alone provides a potential order of magnitude improvements in overal code quality over verbose, crappy imperative languages.

The classic study in which Haskell code tends to be 10x shorter on average is well-known, and similar findings come from the Erlang world. I can bet my reputation that Ocaml projects (Jane Street or Tezos) have the same properties.

John Carmack, who advocates obsession with quality, never settling with anything less than doing your absolute best, and hard work (he is indeed Mike Tyson of imperative programming), would’ve benefited greatly if it was possible for him to use really well-researched and just decent languages.

But, fortunately, we are not hardcore game-devs, so we can easily escape the abomination of C++ or rigid idiocy of Java and OOP mass-hysteria in general - no, not everything should be an object and to have a unique id, while uniformity, as in Smalltalk, is, of course, the right, universal principle.

(Mentioning javascript is the same disgrace and low taste as mentioning porn or PHP).

So, quality begins with decent high-level pure- or mostly-functional languages of the ML family, which in turn, are descendants of early Lisps (at least conceptually and semantically).

Author: <schiptsov@gmail.com>

Email: lngnmn2@yahoo.com

Created: 2023-08-08 Tue 18:40

Emacs 29.1.50 (Org mode 9.7-pre)