What I did in 2023

2023 was a very strange year for me, in many ways I feel like the year came & went, but to my surprise looking back I actually did a lot that I’m proud of!

I made 2 programming languages, a structural editor, learned prolog & became a CSS nerd.

Coil

github

I made a programming language called coil which I’m quite proud of!

It’s basically my take on a “Better JavaScript” while staying highly compatible with js.

I originally wrote it in clojure with much love, but a few weeks in decided to bootstrap it & to my surprise the compiler became 10x faster! Almost all of which can be a testament to how fast JS engines are these days.

Here’s some cool things you can do:

-- iterate object literals!
{name: "marcelle"}.each(|key, val| [key, val].log())
-- extensible record syntax!
Map{name: "marcelle"} -- this creates a native JS Map
-- powerful iteration methods built off Symbol.iterator
let urgent_cards = document:querySelectorAll(".card .status")
  .filter(:textContent _.includes?("urgent"))
  .map(|elem| elem:closest(".card"))
  .into(Set[])

-- ^ this would be best done in css with a [data-status] attribute, but we'll get to css later :)

I haven’t given the language much love in the last few months, but I’ve put a ton of work into it (>500 commits) and it’s fairly stable for what it is. I’ve used it with vite & much of the JS ecosystem with great pleasure, it’s definitely my goto language when I need to use something with JS interop.

Coil Editor

demo

I made a small (barely-usable & bit-rotted) structural editor with coil for coil.

It’s a very simple translation from ast to html, with contenteditable for leaf nodes & all syntax highlighting and formatting done in css.

The original prototype was completed in a week, and I spent the week after doing static analysis with css selectors (use of undeclared variables, etc.) & clever use of ::after to show warning on applicable nodes. Unfortunately this demo is lost to time & bitrot as it was written in an old version of coil & I haven’t have the passion to rewrite it.

I gained a deep appreciation for CSS from working on this.

I still have deep desires to continue working on a structural editor, and have been designing a polyglot structural editor, but I still need to simplify the ideas more before getting to work so I don’t spend years on this project.

Prolog

blog post

I started learning prolog in 2022, but it didn’t really click until I started using prolog to store ast nodes from coil, and then it became apparent that a lot of the the static analysis I’ve been struggling to implement can be done almost trivially in prolog when the ast data is all connected as a graph.

This blog post got some attention, and I’m quite proud of it!

I have not taken this idea much further yet, but I daydream about prolog almost daily now.

Point

video demo github

Most recently in this past month, I’ve started a brand new language written in rust as an interpreter. I have written a few small interpreters before, but my comfort zone is writing compile-to-js languages, so it was fun & freeing to step outside my comfort zone.

It is a chaotic take on OO where message passing / method handlers mean data / pattern matching.

I did not desire to write an eso-lang but it’s become clear from trying to show it off that is very much in eso-lang territory.

-- hello world
"hello friends" :log;

-- defining Point type, and +
class Point
  def + Point{x; y;} ->
    Point{x: self :x. + x; y: self :y. y;};
end

Point{x: 1; y: 2;} + Point{x: 2: y: 2;};

-- global methods

def x -> x;

self 1; -- 1

-- pattern matching also does unification

def Point{x; y: x;} -> :same!;

self Point{x: 1; y: 1;}; -- :same!

It’s a strange language which I cannot completely explain the motivation, I’m developing it to chase a feeling & I’m having a ton of fun working on it.

Writing the language in rust has been a learning curve, but I’ve not been caring about performance or clean code and I was surprised to find that rust is more forgiving than I used to think (if one does not care about performance or clean code!). I have mixed feeling about rust, but generally positive now as this project as got me to appreciate it lot more.

CSS

CSS is a beautiful language, and with new features like @container and :has it’s become seriously powerful. I’ve been obsessed with pushing the boundaries of what’s possible/sane to do in CSS, and a lot can be in css instead of javascript!

I feel like CSS gets a bad rep because it has this notion that it is a beginner language, but it took me 5-7 years to actually learn CSS & respect it. I would say its easy to get started, but quite challenging to master since it is not an imperative or even functional programming language.

A lot of the things people hate about CSS I’ve grown to love like specificity, everything is global & debugging.

Programming CSS in text editors can be painful because its not obvious where to put the code & there’s close to 0 static analysis tools, but working on css in browser dev tools is a joy. So easy to enable/disable code, prototype, see what css rules are impacting this element.

The missing debug tool I am desperate for is to show the browser a query + rules, and show me which elements it applies to & how. You can sort of emulate this in the js console, but its not seamless.

Conclusion

I worked on a lot of fun things this year, and I grew a lot. Looking back what I’m most proud of is this year is that I learned to not guilt myself into “finishing” projects, or work on things I do not enjoy, and to my surprise it’s been extremely productive!