Live data from Hacker News

Compiler Development: Rust or OCaml?

hirrolot.github.io

101–107 of 107 posts

Re: Compiler Development: Rust or OCaml?

#101
post #82

Earlier quoted context omitted.

This is sort of a flippant response, but I'll answer it seriously. The premise of this question is incorrect: you can't not use the borrow checker in Rust. Instead, you are satisfying the borrow checker by ensuring at the point of use (deref of the ID) that there is valid data by providing a provably-live reference to the arena in which it was allocated. In another language like C/C++, you'd just use a raw pointer, w…

But compilers deal usually with trees not general graphs.

Even with a tree structure, you probably don't want your nodes owning their children just for the sake of being efficient with your allocations.

Re: Compiler Development: Rust or OCaml?

#103
I was going to ask, but the author answers this in the end:

> Other alternatives to consider is Haskell and various Lisp dialects. If you have already “tamed” Haskell (my congratulations and condolences), probably learning OCaml just for writing a compiler is not going to be worth it; if you have not, OCaml is a much more approachable language.

This is an interesting claim, as I thought Haskell and OCaml were more or less equivalently inscrutable.

Re: Compiler Development: Rust or OCaml?

#104
post #36

Earlier quoted context omitted.

Can you explain what Menhir does better than other parser frameworks? For what it's worth, I'm not a huge fan of parser frameworks. I tend to prefer hand written parsers, either via a combinator library or fully manually. Rust has a pretty darn good ecosystem too btw. chumsky for parsing, rowan for syntax trees, salsa for incremental computation, miette for errors, inkwell/walrus for code generation.

It can generate elegant and efficient parsers for LR(1) grammars. > I tend to prefer hand written parsers, either via a combinator library or fully manually. That’s common with people used to languages which provide poor parser generators.

>That’s common with people used to languages which provide poor parser generators.

lmao

Re: Compiler Development: Rust or OCaml?

#105
post #90

Earlier quoted context omitted.

That's great and I agree for these use-cases a parser generator makes sense. But that doesn't answer my question about what makes these parsers particularly elegant. Nor does it seem to be a benefit specific to Mehnir, since any parser generator has the quick iteration speed. I don't mean to blame you for that; you are answering a question about something that you did not say. But I find it frustrating that Mehnir se…

> with a good example of how it's better than any other parser generator. I already told you that it has full support for disambiguating LR(1) grammar and still generating a parser which is easy to read. How do you want me to paste a full parser in a HN comment? Most generators only support LALR(1) grammar which is limiting and don’t deal with corner cases as gracefully. I get that you are hell bent on wanting Rust t…

[flagged]
Post reply on HN