3 ms·
Why would you want to do that?
by ticviking 11y ago
Why would you want to do that?
- jasonwatkinspdx 11y agoThere 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.
- iofj 11y agoThe 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.
- thurston 11y agoKeep using them is how you overcome this ;)
- thurston 11y agoSame 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.