←back to thread

203 points dahlia | 7 comments | | HN request time: 0.721s | source | bottom
1. yakshaving_jgt ◴[] No.45153163[source]
I've noticed that many programmers believe that parsing is some niche thing that the average programmer likely won't need to contend with, and that it's only applicable in a few specific low-level cases, in which you'll need to reach for a parser combinator library, etc.

But this is wrong. Programmers should be writing parsers all the time!

replies(4): >>45153317 #>>45153402 #>>45153520 #>>45153674 #
2. WJW ◴[] No.45153317[source]
Last week my primary task was writing a github action that needed to log in to Heroku and push the current code on main and development branches to the production and staging environments respectively. The week before that, I wrote some code to make sure the type the object was included in the filters passed to an API call.

Don't get me wrong, I actually love writing parsers. It's just not required all that often in my day-to-day work. 99% of the time when I need to write a parser myself it's for and Advent of Code problem, usually I just import whatever JSON or YAML parser is provided for the platform and go from there.

replies(1): >>45153397 #
3. yakshaving_jgt ◴[] No.45153397[source]
Do you not write validation? Or handle user input? Or handle server responses? Surely there’s some data processing somewhere.
4. dkubb ◴[] No.45153402[source]
The three most common things I think about when coding are DAGs, State Machines and parsing. The latter two come up all the time in regexps which I probably write at least once a day, and I’m always thinking about state transitions and dependencies.
5. eska ◴[] No.45153520[source]
I think most security issues are just due to people not parsing input at all/properly. Then security consultants give each one a new name as if it was something new. :-)
6. nine_k ◴[] No.45153674[source]
I'd say that engineers should use the highest-level tools that are adequate for the task.

Sometimes it's going down to machine code, or rolling your own hash table, or writing your own recursive-descent parser from first principles. But most of the time you don't have to reach that low, and things like parsing are but a minor detail in the grand scheme. The engineer should not spend time on building them, but should be able to competently choose a ready-made part.

I mean, creating your own bolts and nuts may be fun, but mot of the time, if you want to build something, you just pick a few from an appropriate box, and this is exactly right.

replies(1): >>45154735 #
7. yakshaving_jgt ◴[] No.45154735[source]
I don’t understand. Every mainstream language has libraries for parsing into general types, but none of them will have libraries for parsing values specific to your application.

TFA links to Alexis King’s Parse, Don’t Validate article, which explains this well. Did you not read it?