avatar
Owen O’Malley @owenomalley.bsky.social

If you are trying to just solve the problem, regexs are great. The advantages of the manual parser are mostly no start up time and the fact that you have functions to create abstractions. You do end up with more code to validate and maintain.

dec 3, 2024, 6:47 pm • 1 0

Replies

avatar
andre 🍀 @notthatcomplicated.bsky.social

yeah. i wish more people understood how regex works internally. I've seen code in production that recompiles a uuid matching regex each time the uuid is used, when we already had a custom uuid checker in the codebase haha

dec 3, 2024, 6:50 pm • 0 0 • view
avatar
Owen O’Malley @owenomalley.bsky.social

Yikes. It is far to easy to recompile the regexs over and over again. Fortunately, #RustLang 's linter, clippy, has a check for compiling regexs in a loop. Of course, it doesn't catch all of the cases.

dec 3, 2024, 6:54 pm • 1 0 • view
avatar
Owen O’Malley @owenomalley.bsky.social

I've thought about using #RustLang 's macros to compile the regex to a state machine at compile time. That would remove the startup time that makes it hard to use in very fast applications like #AdventOfCode where I'm trying to get the run time for all 25 days to less than a second.

dec 3, 2024, 6:49 pm • 2 0 • view
avatar
andre 🍀 @notthatcomplicated.bsky.social

I've heard of docs.rs/ctreg/latest... but never tried it myself

dec 3, 2024, 6:52 pm • 0 0 • view