Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

From an educational perspective, regular expressions are also a great way to teach about state machines, computational complexity, formal languages, and grammars in a way that has direct applications to tools that are long-lived and ubiquitous in industry.

It's also this context that reveals how much simpler strict regular expressions are than general purpose programming languages like Python or JavaScript. That simplicity is also part of what makes regexes so ubiquitous: due to its lower computational complexity, regex parsing is really fast and doesn't take much memory.

When I say regexes are simple, I'm not really talking about compactness. I mean low complexity in a computational sense! As someone who rather likes regex, I think it would be totally fair for a team to rule out all uses of PCRE2 that go beyond the scope of regular languages. Those uses of regex may be compact, but they're no longer simple.

I'm also someone who is sensitive to readability-centered critiques of terse languages. Awk, sed, and even Bash parameter expansion can efficiently do precise transformations, too. But sometimes they should be avoided in favor of solutions that are more verbose, more explicit, and involve less special syntax. (Note also that Bash, awk, and sed are also all much more complex than regex!)





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: