1) MVC is a terrible design pattern. The separation of concerns is absolutely backwards. It separate directly related items that would most likely be worked on together, simply because one is visual and the other is logical. Instead, we should go back to the time when code was organized by access and usage. The logical code and visual template for a given URL should exist in the same folder, not separate them.
2) these modern "URL routers" are very slow, bulky, unnecessary, don't scale well in hardware, or scale to larger teams! It causes a "too many cooks in the kitchen" problem
All design patterns are terrible.... for problems they weren't meant to solve. I think a more general issue here is people; we learn a new thing and want to apply it everywhere.
MVC isn't a horrible design pattern. It's because they're trying to implement it into things like PHP (which can't be actually done). But in my experience while everything isn't perfect, MVC can increase your development speed, and keep things separated and clear in your head. At least it has for me.
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.