Classic language in the classic environment
That scene from Rocky movie
Arguably the best scene in the classic Rocky (1976) movie, is when Mickey comes with an offer:
..Well, what ya need is a manager. A manager, listen to me. I know, because I’ve been in this racket for fifty years…I’ve seen it all, all of it.
and then
I got all this knowledge, I got it up here now, I wanna give it to you…I wanna take care of ya, I wanna make sure that all this sh*t that happened to me doesn’t happen to you…
Well, now I am that beaten up Mickey, the coach.
The drill
Here we re-read the classic books (really) in the classic setting (the GNU Emacs environment).
An important note: all the books are “available” from libgen. I won’t teach here the details of how to download them, but I would strongly argue that this is indispensable for us, third-worldlers. No one here would order anything from Amazon, you know.
The Pirsig’s book and Ayn Rand
The “classical mindset” has been popularized in the modern classic book “Zen and the Art of Motorcycle Maintenance” by Robert M. Pirsig. (If you haven’t read this book, you are on a wrong page (this page). Just stop right here and go and read the book).
The most important thing (of the “good philosophy” – the Ayn Rand’s term) is that there are “reasons” behind everything, since everything is within a single unfolding process, which we call Universe (and this is why contradictions do not exist, and one has to check one’s premises).
The Pirsig’s book is trying to “capture” the same fundamental notion. So was Ayn Rand with her Objectivism, which can be reduced to The Buddha’s “to see things as they are”. These are not some random coincidences.
There are, for example, some “deep reasons” why the mRNA (and the DNA) is a linear sequence with explicit start and stop markers and the early LISP guys intuitively “got it”.
Anyway, all the classic books have to be read many times (definitely, more than once). The first reading is, of course, from start to finish, and then one uses table of contents for the individual topics.
CLU
We should have started with the CLU programming language by Barbara Liskov, but unfortunately, it is imperative and “low” level, the way all Algol-based languages are.
There is the source code available for historians, but it cannot be compiled to anything executable and there is no editor support anyway.
The big ideas introduced in the book are language-independent, or, to be precise - more general than any specific programming language, which means they are universal.
All the classic language support Abstract Data Types in various ways, while SML and Ocaml, it seems, reached a local optimum.
The book
Barbara Liskov, John V. Guttag, Abstraction and specification in program development.
This is a golden classic, which basically explains the principles on which a serious programming is based upon in a clear language with remarkable clarity of a well-trained mind.
Emacs
The current version of GNU Emacs is a culmination of more than 40 years of continuous “hacking” by some of the smartest people on the planet, at least judging by an old-school mathematical and the classic EE and CS training (the MIT Scheme is another such manifestation, but it is much younger).
The “prog-mode”
The books
Elliot, James;Rosenblatt, Bill;Cameron, Debra;Loy, Marc;Raymond, Eric, Learning GNU Emacs, 3rd edition.
Mickey Petersen, Mastering Emacs, 4th edition.
MIT Scheme
Installation
emerge --ask mit-scheme
Emacs configuration
(require 'xscheme) (setq scheme-program-name "mit-scheme") (setq inferior-scheme-program "mit-scheme")
The books
Gerald Jay Sussman, Software Design for Flexibility: How to Avoid Programming Yourself into a Corner
SML/NJ
Installation
emerge --ask smlnj mlton
Emacs configuration
We do not have snippets, (which could be written easily), or an eternal code formatter (the ~sml-mode does basic indentation). The REPL assumes SML/NJ has been installed.
(use-package sml-mode :straight t :defer t :mode "\\.s\\(?:ml\\|ig\\)\\'") (use-package company-mlton :straight '(company-mlton :type git :host github :repo "MatthewFluet/company-mlton") :defer t :after company :hook (sml-mode . company-mlton-init) :config (add-to-list 'company-backends 'company-mlton-grouped-backend))
The book
Lawrence C. Paulson, ML for the Working Programmer, 2nd Edition.
This guy, by the way, is a sort of SPJ of the Standard ML world. He is author of the Isabelle, which is a generic proof assistant written in ML (using mlton
).
His textbook is a true classic, exceptional for clarity and a good style.
Common Lisp
Installation
emerge --ask sbcl asdf
Emacs configuration
One has to install quicklisp
by hand, following the instructions on the website.
(straight-use-package 'hippie-expand-slime) (use-package slime :straight t :defer t :hook (lisp-mode . slime-mode) :hook (inferior-lisp-mode . inferior-slime-mode) :init (eval-after-load "slime" '(progn (setq inferior-lisp-program "sbcl") (load (expand-file-name "~/quicklisp/slime-helper.el")) (setq slime-lisp-implementations '((sbcl ("/usr/bin/sbcl")))) (slime-setup '( slime-asdf slime-autodoc slime-editing-commands slime-fancy-inspector slime-fontifying-fu slime-fuzzy slime-indentation slime-mdot-fu slime-package-fu slime-references slime-repl slime-sbcl-exts slime-scratch slime-xref-browser )) (slime-autodoc-mode) (setq slime-complete-symbol*-fancy t) (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol))) )
The books
David S. Touretzky, Common LISP: a gentle introduction to symbolic computation
Poul Graham, On LISP: Advanced Techniques for Common LISP
Norvig
Miranda
The Miranda language is available, and could even be compiled for x86-64 Linux.
Mirandaâ„¢ source release version 2.066 of 31 January 2020 at http://miranda.org.uk/downloads
There is no Emacs support available, but to write a miranda-mode
is a good exercise and a worthy effort.
Installation on Gentoo
tar -xzf ../Downloads/mira-2066-src.tgz
cd miranda
vi Makefile
You need to add the -fcommon
flag to the CFLAGS in the Makefile
for a modern gcc
compiler
CFLAGS = -m64 -march=native -O3 -fcommon
and, perhaps, change the installation paths to /usr/local
BIN=usr/local/bin LIB=usr/local/lib MAN=usr/local/share/man/man1
and then the usual
make && sudo make install
The book
Richard Bird & Philip Wadler, An Introduction to Functional Programming, Prentice Hall 1988.
This is another golden classic, which was way ahead of its time. Like all the other great books it is language-agnostic, meaning that it uses a particular language only to illustrate the general principles and universal notions.
Erlang
The book
Joe Armstrong, Programming Erlang: Software for a Concurrent World, second edition.
Everything written by Joe Armstrong is worth reading and re-reading. Understanding and appreciating Erlang
is a whole separate topic in itself.
Ocaml
Installation
Fitrst we need the compiler (which in turn compiles the runtime with gcc
).
emerge --ask dev-lang/ocaml
The Ocaml language has a lot of legacy tooling, which looks unusual but it is still remarkably good. One has to install opam
in the /usr/local/bin
(or $HOME/.local/bin
):
git clone --depth=1 https://github.com/ocaml/opam cd opam ./configure --prefix /usr/local --with-0install-solver --with-vendored-deps make -s all && sudo make install
Then we have to create and initialize (with a switch) a local opam
environment.
opam init --bare opam switch create 4.14.1
The version should match the one of the installed ocaml
compiler. In this case opam
will not install a local copy of it.
From now everything is easy because opam
resolves all the dependencies.
opam install ocamlfind ocp-indent user-setup mernin tuareg utop ocamlformat opam user-setup install
Emacs configuration
Then one has to configure Emacs with something like this:
(use-package merlin :straight t :defer t :after company :config (add-to-list 'company-backends 'merlin-company-backend) (setq merlin-completion-with-doc t)) (use-package tuareg :straight t :defer t :hook (tuareg-mode-local-vars . merlin-mode) :hook (tuareg-mode-local-vars . lsp) :hook (tuareg-mode-local-vars . tree-sitter) :config (setq tuareg-prettify-symbols-full t) (setq tuareg-opam-insinuate t) (tuareg-opam-update-env (tuareg-opam-current-compiler))) (use-package flycheck-ocaml :straight t :defer t :after merlin :hook (tuareg-mode . flucheck-ocaml-setup)) (use-package merlin-eldoc :straight t :defer t :after merlin :hook (merlin-mode . merlin-eldoc-setup)) (use-package merlin-imenu :defer t :after merlin :hook (merlin-mode . merlin-use-merlin-imenu)) (use-package ocamlformat :straight t :commands ocamlformat) (use-package ocp-indent :straight t :defer t :hook (tuareg-mode . ocp-setup-indent)) (use-package merlin-iedit :straight t :defer t) (use-package utop :straight t :defer t :hook (tuareg-mode . utop-minor-mode))
The book
OCaml Programming: Correct + Efficient + Beautiful
This is a most resent SICP-level textbook for the ML-family language. It champions an unusual classic mindset clarity and conciseness in wording and lacks bullshit.
One has to just go through it, writing down every piece of code one sees, including those on videos. By just writing down other people’s superior code one learns.
Haskell
Simon Peyton Jones
Simon L Peyton Jones, The implementation of functional programming languages
Richard Bird
Richard Bird, Thinking Functionally with Haskell
Graham Hutton
Graham Hutton, Programming in Haskell
Scala
Clojure
The book
Michael Fogus, Chris Houser, The Joy of Clojure: Thinking the Clojure Way
This is a difficult book to read due to intolerable narcissistic style, in which the authors literally scream at you – just look how smart we are.
There, however, the universal notions of principled immutability and persistence (of data structures) has been outlined, among the rubbish, and their implications explored.
Python
Well, Python can be considered as one of the classic imperative languages, and also of its own kind.
We included it because it is a defacto standard and because things like Pytorch
.
Emacs configuration
The books
Allen B Downey, Think Python: How to Think Like a Computer Scientist
John V. Guttag, Introduction to Computation and Programming Using Python