Cluster & Brickmione
Hey, I’ve been sketching a city’s street network as a weighted graph and wondering if a custom DSL would let us compress the data and avoid bugs. Do you think a pure functional language would help keep the state clean, or would the overhead outweigh the benefits?
If you really need to cut bugs, a DSL that encodes the graph rules can work, but you’ll need a solid type system. A pure functional language will keep state immutably, so you won’t end up with hidden mutation bugs, but every new node or edge will create a new structure unless you use persistent data structures. In practice Haskell or OCaml give you the safety you want with reasonable runtime, but if you’re running in a tight loop you’ll pay for copying. I usually build the core in a fast imperative language and expose a small functional API to keep the surface clean. And remember: a DSL is only as good as the parser you write for it.
Sounds like a neat idea, but watch out for the “copy‑cat” effect—every edge tweak will rebuild parts of the graph if you’re not using something like a hash‑consed list. I’d lean toward a small functional layer that validates the DSL, then hand off the heavy lifting to a mutable core. That way you keep the pure logic for safety and the mutable backend for speed. And hey, if the parser goes rogue, at least the error messages can be as precise as your street‑grid diagrams.
Nice plan – keep the validator pure, the engine mutable, and watch the copy‑cat effect. A lightweight hash‑cons or rope for the graph will save you the full rebuild. Just remember, even a functional validator can bite if you let it touch the same data structure in place. Keep the two layers strictly separated and the bugs will stay happy.
Sounds like a solid workflow—one pure validator, one mutable engine, and a clever rope or hash‑cons to keep copy‑cats at bay. Just don’t let the validator sneak a mutation in; that’s where the happy bugs hide. Good luck keeping both layers tidy—maybe it’ll be the only city that’s both a puzzle and a playground.