Hacker News new | ask | show | jobs
by Clever321 4211 days ago
From someone not at all involved in the field of computer science where this might be applied... where might this be applied in industry? Very compelling stuff, but I don't have a particular use case...
4 comments

Any time you have to read a file format that doesn't have a library available already (or if you want to write that library). Plenty of industries have a de-facto standard file format that's basically text, but with some special command sequences or bracketing (e.g. recently I had someone ask me how to read "PGN" files, which turns out to be the standard way of recording chess games). Chess is a trivial example, but the "STL" format used by a CNC milling machine I've worked with is a pretty similar format.

So imagine I wanted to write a "middleware" piece for that milling machine - maybe it has a slight defect where its width measure isn't exactly the same as its depth measure (I expect modern machines automatically recalibrate themselves, but you can imagine weirder problems that this might not solve). Then I could write a program that would rescale models exported from a CAD application to match the weirdness of my particular machine, by reading the file, making the adjustments, and writing a new file.

For a less industrial example that I've actually done, I worked on a fan translation of a videogame. The scripts were, of course, in a weird format that the original makers came up with, with no publicly available libraries. So I wrote a parser that could separate the actual text lines from the timing information and so forth, allowing the translators to translate.

One example from Rdio's image server code base: https://github.com/rdio/thor/blob/master/src/main/scala/com/...

It's used to parse arbitrarily complex transformations to apply to an image in the URL.

It might be applied (but this isn't the only possible approach, and I rarely use parser combinators) every time you need to write a parser. And when you need to write a parser? Oh, I have to write parsers all the time, seriously. It's not like all data is passed using json or something like this nowadays, there're plenty domains where obscure, custom data formats (often intended primarily to be read by humans, not processed by machines) are used. So when you need to use such a system with a custom data format you ought to write your own parser.
I work in industry and I recently had to implement a special purpose templating language for our product. For various reasons none of the off the shelf ones quite did what we needed.

As a result I had to write a parser and interpreter. The thing about a lot of these computer science things is that you don't need them until you do. And then when you do it's nice to know about how they work.

Can anyone recommend an article for interpreters that is exactly at the level of the original link?
I guess http://norvig.com/lispy.html would be about right.