This web page was created programmatically, to learn the article in its authentic location you may go to the hyperlink bellow:
https://smallcultfollowing.com/babysteps/blog/2026/02/08/fun-with-dada/
and if you wish to take away this text from our website please contact us
Waaaaaay again in 2021, I began experimenting with a brand new programming language I name “Dada”. I’ve been tinkering with it ever since and I simply realized that (oh my gosh!) I’ve by no means written even a single weblog submit about it! I figured I ought to repair that. This submit will introduce a few of the primary ideas of Dada as it’s now.
Before you get any concepts, Dada isn’t match to be used. In reality the compiler doesn’t even actually work as a result of I preserve altering the language earlier than I get all of it the best way working. Honestly, Dada is extra of a “stress relief” valve for me than anything – it’s enjoyable to tinker with a programming language the place I don’t have to fret about backwards compatibility, or RFCs, or anything.
That stated, Dada has been a really fertile supply of concepts that I believe may very well be relevant to Rust. And not only for language design: taking part in with the compiler can be what led to the brand new salsa design, which is now utilized by each rust-analyzer and Astral’s ty. So I actually need to get these concepts on the market!
I took a break, however I’m again child!
I ended hacking on Dada a couple of yr in the past, however over the previous few days I’ve began engaged on it once more. And I noticed, hey, this can be a good time to begin running a blog! After all, I’ve to rediscover what I used to be doing anyway, and writing about issues is all the time the easiest way to work out the small print.
Dada began as a gradual programming experiment, however not
Dada has gone by many phases. Early on, the objective was to construct a steadily typed programming language that I assumed can be simpler for folks to study.
The concept was that you can begin writing with none sorts in any respect and simply execute this system. There was an interactive playground that will allow you to step by and visualize the “borrow checker” state (what Dada calls permissions) as you go. My hope was that folks would discover that simpler to study than working with sort checker checker.
I obtained this working and it was truly fairly cool. I gave a talk about it at the Programming Language Mentoring Workshop in 2022, although skimming that video it doesn’t look like I actually demo’d the permission modeling. Too unhealthy.
At the identical time, I discovered myself unconvinced that the steadily typed strategy made sense. What I needed was that once you executed this system with out sort annotations, you’d get errors on the level the place you violated a borrow. And that meant that this system needed to observe numerous further information, type of like miri does, and it was actually solely sensible as a instructing instrument. I nonetheless wish to discover that, however it additionally felt prefer it was including numerous complexity to the language design for one thing that will solely be of curiosity very early in a developer’s journey.
Therefore, I made a decision to begin over, this time, to only deal with the static sort checking a part of Dada.
Dada is sort of a streamlined Rust
Dada immediately is like Rust however streamlined. The objective is that Dada has the identical primary “ownership-oriented” really feel of Rust, however with quite a bit fewer decisions and nitty-gritty particulars it’s important to cope with.
Rust usually has sorts which might be semantically equal, however completely different in illustration. Consider &Option vs Option<&String>: each of them are equal by way of what you are able to do with them, however in fact Rust makes you fastidiously distinguish between them. In Dada, they’re the identical sort. Dada additionally makes &Vec, &Vec<&String>, &[String], &[&str], and plenty of different variations all the identical sort too. And earlier than you ask, it does it with out heap allocating all the pieces or utilizing a rubbish collector.
To put it pithily, Dada goals to be “Rust where you never have to call as_ref()”.
Dada has a fancier borrow checker
Dada additionally has a fancier borrow checker, one which already demonstrates a lot of the borrow checker inside, though it doesn’t have view sorts. Dada’s borrow checker helps inside borrows (e.g., you can also make a struct that has fields that borrow from different fields) and it helps borrow checking with out lifetimes. Much of these items may be dropped at Rust, though I did tweak a couple of issues in Dada that made some elements simpler.
Dada targets WebAssembly natively
Somewhere alongside the road in refocusing Dada, I made a decision to focus solely on constructing WebAssembly elements. Initially I felt like concentrating on WebAssembly can be actually handy:
- WebAssembly is sort of a actually easy and clear meeting language, so writing the compiler backend is simple.
- WebAssembly elements are explicitly designed to bridge between languages, so that they clear up the FFI drawback for you.
- With WASI, you even get a full featured customary library that features high-level issues like “fetch a web page”. So you may construct helpful issues proper off the bat.
WebAssembly and on-demand compilation = compile-time reflection virtually without spending a dime
But I got here to appreciate that concentrating on WebAssembly has one other benefit: it makes compile-time reflection virtually trivial. The Dada compiler is structured in a purely on-demand vogue. This means we are able to compile one operate all the best way to WebAssembly bytecode and go away the remainder of the crate untouched.
And as soon as we now have the WebAssembly bytecode, we are able to run that from contained in the compiler! With wasmtime, we now have a top quality JIT that runs very quick. The code is even sandboxed!
So we are able to have a operate that we compile and run throughout execution and use to supply different code that might be utilized by different elements of the compilation step. In different phrases, we get one thing like miri or Zig’s comptime without spending a dime, basically. Woah.
Wish you can strive it? Me too!
Man, scripting this weblog submit made ME excited to play with Dada. Too unhealthy it doesn’t truly work. Ha! But I plan to maintain plugging away on the compiler and get it to the purpose of a dwell demo as quickly as I can. Hard to say precisely how lengthy that may take.
In the meantime, to assist me rediscover how issues work, I’m going to attempt to write up a sequence of weblog posts concerning the sort system, borrow checker, and the compiler structure, all of which I believe are fairly attention-grabbing.
This web page was created programmatically, to learn the article in its authentic location you may go to the hyperlink bellow:
https://smallcultfollowing.com/babysteps/blog/2026/02/08/fun-with-dada/
and if you wish to take away this text from our website please contact us
