7 ms·
Show HN: Chirp, My constraint-driven metaprogramming language
- Chabsff 3mo agoHello HN. There's still a long road ahead for the project, but since I've recently closed the loop on bootstrapping the language's core within itself, I thought now's as good a time as any to throw it out there and start getting other people's takes on it. Chirp is my attempt at engineering a programing language from the ground up that packs together all my favorite bits and pieces into one tight and consistent package. It's got a bit of Rust, a bit of Zig, a LOT of TypeScript, and a lot more LISP than I initially expected. What sets it apart is its treatment of sets as a trait, and how they are used to express constraints on variables while keeping the code as boring and straightforward as possible. Here's a taste: let fizz = { x:int | x % 3 == 0 }; let buzz = { x:int | x % 5 == 0 }; let fb_range = 0 ..= 100; let eval(v: fb_range) = match v { fizz ∩ buzz => "fizzbuzz", fizz => "fizz", buzz => "buzz", `any => f"{v}" }; for (v ∈ fb_range) `print(eval(v)); To manage expectations: Code emission isn't ready yet. As things stand, it's effectively a scripting language with an intuitive set-centric syntax and runtime constraint checking. But, especially since scripting a compiler is what it's meant to do, I think it's still enough to show around a bit.