4 ms·
My understanding is that in production compilers, hand rolled parsers are the norm. Parsing libraries are cool, but just aren’t used for big projects.
by steveklabnik 7y ago
My understanding is that in production compilers, hand rolled parsers are the norm. Parsing libraries are cool, but just aren’t used for big projects.
- tomasato 7y agoExcluding the lens library (as per the article) is unusual, it provides natural getter/setter and row polymorphism type functionality. More anecdotally, I’d argue parsing libraries are common, just look at the prevalence of attoparsec and others. But most parsing libraries in the ecosystem are parser combinator libraries which don’t support as performance and nice error messages that compilers need
- garmaine 7y agoThat was where I stopped reading. If a library like lens—used by nearly every haskeller in every project—was disallowed, I don’t know what the purpose of this exercise was.
- aliceryhl 7y agoI mean, it seems like it was an university course, and writing a compiler from scratch is probably a decent exercise in a compiler course.
- garmaine 7y agoRestrict the students from using a parser library. I get that. But allowing nothing except that standard library? That’s stupid. It also makes the language comparison useless. Python has a standard library that is continuously improved and people reach to that when writing programs. Haskell, like C, ossified it’s standard library when it was created and people use the external packages for equivalent up to date libraries.
- Ericson2314 7y agoParsers are not the interesting parts of compilers.
- pyrale 7y agoLens is far from being used by everyone in the space. On a sample of 5-6 professional users I talked with at this zurihac, most didn't use it.
- tathougies 7y agoI dunno, libraries like earley in Haskell, provide pretty nice error messages.
- sanxiyn 7y agoBoth OCaml and GHC use parser generators. It is incorrect to suggest production compilers hand roll parsers.
- steveklabnik 7y agoTwo counterexamples does not disprove “a norm”. There are always exceptions!
- nybble41 7y agoRight, to prove or disprove the norm one would need much more information. Two counterexamples does, however, disprove that "Parsing libraries ... just aren’t used for big projects." GHC and the OCaml compiler are both big projects, and they use parsing libraries.
- fnord123 7y agoI think big here means impactful.
- grumdan 7y agoDescribing two well-engineered compilers of two relatively used languages as not impactful is quite a statement. In particular, given the good performance results they achieve, for languages that are quite far away from the normal execution model of the machine they produce code for.
- fnord123 7y ago>two relatively used languages Relative to what? Haskell and OCaml are important languages for PLT but not in the context of "production", or as I understood "production" to mean: shipping products with features. To call them anything but niche players in this context is not accurate in my opinion.
- 7y ago
- willtim 7y agoIt depends entirely on whether the big project still has an elegant and complete formal grammar. Hand-rolled parsers are only common in industrial languages because many have grown to be far too complex and ad-hoc, requiring e.g. additional analysis and disambiguation during parsing. It is not a situation to aspire to.