UNIX philosophy: a praise for functional programming
Tags: Functional programming, UNIX February 14, 2014

It is often stated that UNIX philosophy consists in writing small programs that do a single thing right and that are composable. For instance, Douglas McIlroy describes it as follows:

This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.

Except for the last part of the quotation about text streams being universal (he meant ASCII text streams, before the encoding hell era), it is exactly the approach followed in functional programming. Indeed, we write small composable/modular functions with clear interfaces (statically typed, indicating whether side-effects occur, etc.).

So what does it mean? We could imagine a kind of shell where the separation between programs and functions is blurred. Oh wait! This is called a read-eval-print-loop (REPL) and we already have GHCi for instance (interactive interpreter of the Glasgow Haskell Compiler (GHC)).

So what could be the next steps?

  • Blur even more the difference between scripting and programming
  • Get rid of crappy shell scripts (bash syntax anyone?) and use modules such as Shelly
  • Build an enhanced shell/repl with integrated completion, enhanced output, etc.
    • For instance, Terminology is able to display pictures and videos directly in the “console”
    • Plush aims to provide enhanced HTML console output