by wolframhempel · 3y ago · 0 comments
- Are you bad at regular expressions, but feel you could get away by just processing text with some loops and split statements? Don't. Use RegExes - every single time until you are good at it.
- You don't really understand database joins and normalization, but you feel you could just make two queries and merge things in your backend code? Nope - go learn joins properly.
- You're overwhelmed by large CSS stylesheets and are tempted to write some inline style or important! statement? Nope - read up on CSS taxonomies and structures...
etc...
I'm quite proficient with regular expressions but rarely reach for them outside of throwaway scripts. I'd much rather use some loops and split statements, frankly.
A few times i've seen a number of lines of code that was easily replaced with a single line of regexp matching and value extraction via named capture groups. The amount of code that comes out of "some loops and split statements" quickly turns into spaghetti code, especially when you need to extract values and/or reference what would be other capture groups.
In my experience, as long as you provide (at least) one sample of the expected input, a regexp is essentially self-documenting.
But then once I worked in a few startups, I realized the point was to just ship as fast as possible. I lost the Hard Way mindset and settled into a life of wide, shallow knowledge. As a result I now feel like a glorified plumber, not at all what I set out to be. So I’m trying to figure out how to get back to that state, but it’s difficult to slow down once you’ve gotten used to moving fast.
For many people the only time they can "practise" RegEx (etc.) is outside of office hours.
There is probably significant overlap in a Venn diagram of "1% engineer" and "20-40 year old single person with no children or social life"
In all seriousness though, I agree. Maybe I’m just sad that I’m getting older (39) and don’t have the time or energy to toss away an entire weekend on some new tech, meanwhile watching all the young kids have all the fun. I miss it a bit.
Ehh, i disagree about regex
Regex is great tool with shitty API, at least when used in code, not in config files
When things arent trivial I suggest writing parser, so your loops and splits instead of ugly monsters