3 ms·
> I can't imagine trying to build a: * client side router * data transportation/cache layer * view layer * model layer * build pipeline Why can't you? Routers
by BinaryIdiot 11y ago
> I can't imagine trying to build a:
* client side router * data transportation/cache layer * view layer * model layer * build pipeline
Why can't you? Routers are easy; you likely don't need more than a few lines of code to accomplish most of what you need. Caching and data transportation is also easy and simple (there are a million cache libraries if you don't want to write a small one). Views and models have been done since the 90s and are relatively easy as well (in fact I wrote one in just a few minutes the other day to drop some dependencies from a personal project). Though models are not always the best way but I'm digressing.
Build pipelines usually add more complexity than needed in my experience. I almost always, eventually, nix whatever complicated build pipeline I start out with and go with something dead simple.
Most of this stuff has been done for over 15 years on the web. It's at the point where it should be mostly boilerplate / routine if you're not using a framework.
- khattam 11y ago> It's at the point where it should be mostly boilerplate / routine Yes, that is EXACTLY what many of these frameworks are.
- deathanatos 11y ago> Routers are easy; you likely don't need more than a few lines of code to accomplish most of what you need. Router as in delegating a URL to a handler for that URL? I wrote one once … and it is deceptive and not easy; most of the server side ones that I've encountered (e.g., Django, Flask, nginx) do a poor job.¹ The naive implementation of a mapping of regexes to handlers is dead simple to implement, but not very ergonomic to really use. Something that understands that paths are hierarchies works a lot better. Then it's also nice to have something that can stub out a component to a variable (and preferably type check that), e.g., "/customers/:customer_id", and pass you "customer_id" after validating it to be an integer, a UUID, or whatever. Then you need the capability to delegate an entire subtrees to a subrouter, and maybe if we could just get some handling of delegation based on the method in here, but HEAD needs to be automatic…, and canonicalization of URLs would be nice too. ¹I feel like this is one of those things that until you've seen something better, you're still wanting the faster horse.