Acorn BBC Micro Logo on Famicom
Acorn BBC Micro Logo on Famicom

A collection of notes on programming.

We use software because we have goals to achieve and things to do. The software we use is coded by programmers who have their own goals, sometimes these goals overlap with ours, over time these will diverge. The tools we depend on grow features we don't use or understand, introducing bugs that will prevent us from reaching our goals.

We have the choice of trying to understand the code and fix it, we have the choice of trying another program, and we have the choice of coding the software ourselves. All but the last path mean endless seeking, evaluating and further deviation from our goals.

Jen came in to see what incredible things the engineers and artists had come up with. Everyone was staring at a television set hooked up to a development box for the Sony Playstation. There, on the screen, against a single-color background, was a black triangle. ~

Programming is a form of worldmaking, in which the coder defines how that world operates.~

A programming language is a system of notation for writing computer programs.

I've collected here a handful of notes on the various languages that I've had the opportunity to use in the past.

Nowadays, my focus is principally on concatenative languages, namely Uxntal. In concatenative languages all expressions denote functions, and the juxtaposition of expressions denotes function composition, which I found was a way of programming that most resonated with how I think.

Point-free programming is a programming paradigm in which function definitions do not identify the arguments on which they operate. Instead the definitions merely compose other functions, among which are combinators that manipulate the arguments.

An operating system manages computer hardware, software resources, and provides common services for programs.

The price of reliability is the pursuit of the utmost simplicity. It is a price which the very rich find most hard to pay.~

Time is valuable and ten seconds' worth of it is well worth the investment of a day's happy activity working out a way of saving it. Douglas Adams

Various file formats used across projects.

Various data encoding schemes.

Types are a way to suggest or restrict the activities possible for an object of that type.

A type system defines how a programming language classifies values and expressions into types, how it can manipulate those types and how they interact. The goal of a type system is to verify and usually enforce a certain level of correctness in programs written in that language by detecting certain incorrect operations. Type inference refers to the automatic detection of the type of an expression.

Weak typing allows a value of one type to be treated as another, for example treating a string as a number. Strong typing raises an error on attempts to perform an operation on the wrong type of value.

Type Inference in Stack-Based Programming Languages

In an applicative language, things are evaluated by applying functions to arguments. This includes almost all programming languages in wide use, such as C, Python, ML, Haskell, and Java. In a concatenative programming language, things are evaluated by composing several functions which all operate on a stack, passed from function to function.

Concatenative programming is so called because it uses function composition instead of function application.

Type inference in stack-based programming language is done by checking the stack effect declarations of words before they can be run, against the cumulative stack state of each item in the definition of each word.

pop ( 1 -- )
swap ( 1 2 -- 2 1 )

Words that do not pass the stack checker are rejected and cannot be run, and so essentially this defines a very simple and permissive type system that nevertheless catches some invalid programs and enables compiler optimizations.

The simplest case is when a piece of code does not have any branches or recursion, and just pushes literals and calls words. Pushing a literal has stack effect ( -- x ). The stack effect of most words is always known statically from the declaration.

Typed Concatenative Languages

incoming language assembly