Hacker News new | ask | show | jobs
by wrs 451 days ago
I agree with the spirit of the argument, but I don’t think you’re taking into account the scale of “typing” we’re talking about now.

For example, yesterday I needed a parser for a mini-language. I wrote a grammar — actually not even the formal grammar, just some examples — and what I wanted the AST to look like. I said “write the tokenizer”, and it did. I told it to tweak a few things and write tests. It did. I told it to “write a recursive descent parser”, and it did. Add tests and do some tweaks, done.

The whole thing works and it took less than an hour.

So yeah, I had to know I needed a parser, but at that point I could pretty much hand off the details. (Which I still checked over, so I’m not even in full vibe mode, guess.)

3 comments

This is a cool use case that probably saved you some time, but writing a recursive descent parser is something freshman CS students do for a lab assignment.

It isn’t exactly breaking new ground or doing anything you couldn’t find with a quick google search.

You want me to do a Google search for a parser for the language that I just invented?

If you have a parser generator tool that can go from zero to parser based on a few examples rather than a grammar, I’d love to hear about it.

> If you have a parser generator tool that can go from zero to parser based on a few examples rather than a grammar, I’d love to hear about it.

That's the part where the LLM would be useful. Turn the examples into a grammar, verify the grammar, and use a parser generator for the rest.

You know the code does what it should and you get there in minutes.

I'm pretty sure it could have done that equally easily, but this grammar is small enough that a parser generator is overkill. (I made that decision before I asked the LLM to write the parser.)
"add tests and do some tweaks"

there's the snake in the grass - you're asking the LLM to write tests after the code is generated, so naturally, it will write passing tests - including tests which enforce buggy behavior

if not now, then you're lucky; watch out for next time.

Isn't that what tools like antlr [0], bison[1] do?

[0]: https://www.antlr.org/

[1]: https://www.gnu.org/software/bison/

They typically generate generic LALR parsers, not custom recursive descent parsers. I'm no expert, but my understanding is that custom recursive descent parsers have advantages in terms of readability and error message generation.