Hacker News new | ask | show | jobs
by ticviking 3872 days ago
Why would you want to do that?
2 comments

There are a lot of advantages to a declarative approach, and a lot of risks and problems with hand written parsers and state machines.

A good example is the http code Zed wrote with ragel. From what I remember it was contracted by verisign because they wanted an implementation that actually followed the spec in detail, unlike all other code available at the time. That ragel code has been reused by a lot of embedded http servers in many languages now.

The thing I keep finding problematic about declarative approaches is that nobody knows them. That means if you're not a lone wolf on a project, the people editing your declarative state machine are going to be unfamiliar with it. Aside from the complaints that gives (and the "look I rewrote it" issues), that means they make mistakes and don't understand what happens.

So they don't last. They're not all that maintainable in real teams. My experiences are mostly with ANTLR code (which has a debugger and lots of tooling and isn't that hard at all).

I'm at a loss for how to overcome this.

Keep using them is how you overcome this ;)
Same reason you would want to use yacc to write a parser. A grammar annotated with code is a nice way to express a parser. If the language happens to be regular, you can use ragel to generate a directly executable deterministic state machine. The code is simple and fast.