And yes, the modern URL routers usually use regular expressions and fancy stuff to make URLs pretty. While it does make it slower, a lot of these sites aren't going for performance, they're going for development speed, and I have both built and used "URL routers".
Their goal is to implement something in the language the developer is familiar in, making it easier for them to write code.
If you were expecting 10,000+ requests a second, then yeah, you wouldn't want a "URL router".
True, but the best routers should compile those regexps to have near zero overhead ✌🏾
Oh? You can compile regular expressions ... ?
Sure, for example:
Basically you turn the regexp into a cached internal object that has very little overhead during the pattern matching.
That's neat. Thanks! I didn't know you could do that. :D
It's very useful if you have to match a regexp in a loop for example. You only construct it once :)
Both of those things above are directly related for me. There are better design patterns out there that are simpler, easier to implement, easier to understand, and significantly more performant. Yes, all of these, all at the same time.
I get why these tools work for others... but the whole point was "unpopular opinions", which mine is. ;) And it is based purely on 20+ years experience as a software engineer developing software at pretty much any scale (microcontrollers to fully distributed server clusters across multiple datacenters)
As time permits, I've been documenting all of my notes on this, but it is a very lengthy process. But it essentially comes down to attempting to create a zero-boilerplate-framework. Pretty much just create a new file, have the text "hello world" in it, nothing else, and it works. Need more? Simple enough to add more. URL Routers and MVC frameworks add additional and often unnecessary extra boilerplate to get the same job done.
I truly believe our ultimate jobs as software engineers should be to simplify tasks as much as possible, not add more barriers to entry with frameworks which get in the way of simple tasks.
Hmm, that's very interesting. How would you go about making a framework that simple, but flexible at the same time?
If you're working a project like this, I'd love to see it.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.