I have several design goals for the Chrysalis Programming Language:
1. It should be as easy as possible to convert Chrysalis code to C99 code that
is indistinguishable from code written in C to begin with.
2. Pretend all of the core C philosophies are good. Ignore the issues with
declaration-follows-use, textual macros, `#include`, goto, type declaration,
and implicit casting. These ideas have been proven flawed by history, but
they are still solid enough that we can build good software on top.
3. A complete Chrysalis compiler (text-to-instructions) should be embarassingly
simple to write, and easy to read and understand. Not only is this nice from
a systems design perspective, but [[very open systems]] fit within the ethos
of a [[language machine]].
These design goals simultaneously synergize and conflict with each other. The
language and compiler design emerge from that relationship.
The goals work together because C is simple. It avoids convoluted industrial
language features, like inheritance, colored functions, or garbage collection,
and it also lacks small systems langauge conveniences, like tagged unions,
generics, and modules. Because all types must be declared up-front (i.e. via
headers), it's one of the only langauges that can be compiled in a single pass.
That's why `#include`, type declarations, and textual macros make sense. C's
design is less about cleanliness and more about providing syntax for common
machine code patterns. As Richard Gabriel put it:
> Old programs read like quiet conversations between a well-spoken researcher
> and a well-studied mechanical colleague, not as a debate with a compiler.
> Who'd have guessed sophistication bought such noise?
> - Guy Steele & Richard Gabriel, 50 in 50 Keynote, YOW 2010 Melbourne
There's a sense of feature starvation in C. Code is never 'too clever' - there
isn't enough in the language to be clever with. This ethos seeps into the rest
of the ecosystem. It's much easier to write a compiler for a language you can
fully understand. It's easier to interface with the compiler, too. In many
ways, C's philosophy lends itself perfectly to a language machine.
This is the great C that sits entirely in my head. Hopefully, it sits in your
head too. Unfortunately, it does not exist. In the real world, languages are
made by committees, governed by imperfect proceses and fallible humans. In the
real world, we have C89, C99, C11, C17, and C23, which have accumulated a
greater volume of historical mistakes for each revision. Today's versions of C
*cannot* be reasonably compiled in a single pass - not because of any large new
features, but because of odd edge-cases and backwards compaibilty buildup. C's
philosophy is great for simple compilers, but C's implementation is not.
I originally wanted to be a superset of C99. On a whim, I removed the [static
keyword for arrays], which I can't stand. Then I changed `offsetof` to be a
keyword instead of a builtin, because it should be. Eventually, I decided to
ditch the standard entirely. My priorities changed from `1 > 2 > 3` to `3 > 2 >
1`. Making a fun, open compiler & language is most important to me. Chrysalis
is my attempt to realize that ideal C. It isn't quite a C99 superset or subset -
it's just a language that's *a lot* like C - philosophically and syntactically,
but not mathematically.