Random notes about what I'd do if designing a programming language

I’ve just been reading http://www.paulgraham.com/hundred.html and it occurs to me that he has valid points, I’ve never really got the whole Lisp thing, and apart from my emacs init.el I’ve never written any. I guess you could say that Lisp is a darkspot in my programming language mindset, so I started thinking (which is always dangerous).

If I were to try and spec a language that I’d already like to be using I’d want something that removed implicitness (e.g. C++ pass by value of objects copying),

Any language provides a set of constructs, for
storing data,
controlling flow,
defining things
interfacing to libraries
performing mathematics

what I want is a language with minimal built ins. No pre-defined datatypes, no maths, how can we do this, how do we write the compiler. The compiler becomes a part of the language, to add a multiplication we would use a mapping from a method to an opcode.

Item storage


Item integer
storage 32; // always bits

method add shortcut + takes 1 parameter opcode(“mov.l storage, D0; adda.l parameter(1), D0; mov.l storage,D0”);

Item string
integer length;
storage dynamic;
method construct() length=1;storage.allocate(0);
method set(string v) length=v.length;storage.allocate(length);storage.copy(v.storage);

Item stream
{ receive message.output m { output(m.string); } receive message.close m { close(); }


string s(“hello world”);
stream op(stdout);
messagebus b;
message m(m.output, s);

core parts of the langauge:
lists, algorithms etc.

The list processing thing came to me in a flash whilst explaining calculus to my son.

Working with data is what we generally do, all the time, with code. There isn’t really much else to do, apart from jump about
between points in the code.

So, what we need in our new language is completely untyped data, yup, I know it sounds dangerous and possibly unfashionable
but it is really the only way to proceed. Years ago, whilst designing my event driven loosely coupled system

I had to come up with a way of moving data, any data, through messages. Couldn’t really have typed data, so I wrote a set of classes that effectively sat above the types and used a base class to access it. Completely undoing the type checking of the language. We have a DataItem class from which are derived such things as IntegerDataItem and StringDataItem (etc.).

working on two of the core parts (messaging)

On the other hand our maybe classes should typed, and type checked.

a list of data d=(1 2 3 4 5 6 7) a function f(x) = (+ 1) f(d) = (2 3 4 5 6 7 8)