▲ | arn3n 9 days ago | ||||||||||||||||||||||||||||
“In other languages, it would be considered overkill to write a full parser when a simple regex can do the same thing. In Haskell, writing a parser is no big deal. We just do it and move on with our lives.” I see a long code file filled with comments and long paragraph-level explanations. I think I’d rather just learn and use regex. | |||||||||||||||||||||||||||||
▲ | layer8 9 days ago | parent | next [-] | ||||||||||||||||||||||||||||
Whenever I write a regex, I end up with a comments roughly ten times longer than the regex. That being said, regular expressions are often the right tool for the job (i.e. parsing a regular language, as opposed to a context-free language or whatever), just the syntax becomes unreadable rather quickly. I’m sure you could build a nicer regular-expression syntax in Haskell. | |||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||
▲ | bazoom42 9 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||
Sounds like you think the comments and explantions are the problem? You can write regexes with comments and parsers without. Regexes are not generally known to be self explanatory, except for trivial cases like \d+ | |||||||||||||||||||||||||||||
▲ | OneDeuxTriSeiGo 9 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||
I mean that's the nature of article code no? You are writing for a generic audience and want to be very explicit as to what your code is doing to teach the audience. For your average haskell programmer you could drop all of those comments since the code isn't really doing anything that couldn't be determined by just reading it. | |||||||||||||||||||||||||||||
▲ | codebje 9 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||
The main advantage of recursive descent parsing is readability. Forget the machinery of the parser, which is (a) trivial enough that AI will generate correctly it for you with next to no prompting, and (b) widely available in libraries anyway. The win is writing a parser that reads like the grammar it implements, which means changes to your grammar are easy to apply to your parser. Regexes are effectively write-only. If you change the grammar parsed by a regex, you're probably going to discard the regex and make a new one. | |||||||||||||||||||||||||||||
▲ | sayamqazi 9 days ago | parent | prev [-] | ||||||||||||||||||||||||||||
[dead] |