8 ms·
I would like to point out a middle ground, where I currently reside. Back-end in whatever you want (Perl + Mojolicious for me), and a front end using one of th
by kbenson 8y ago
I would like to point out a middle ground, where I currently reside.
Back-end in whatever you want (Perl + Mojolicious for me), and a front end using one of the major frameworks (Vue for me), but without even the need to managing it all with node and NPM (you can still just use script tags, it's not that hard if you don't go crazy with inclusions). Serve pages as simple templates, with maybe some embedded JSON to cut out the initial AJAX request, and now you're playing to the strengths of each part of the stack.
You have a back-end that you're comfortable with and possibly have your own library of utilities for, you have a front-end that leverages all the power the browser brings to the table, and you aren't mixing front-end jQuery style actions with back-end templating and the pain that eventually results in.
- giancarlostoro 8y ago> with maybe some embedded JSON to cut out the initial AJAX request That's the only hackish portion out of there, otherwise I'd agree. I rather get back what I expect from an endpoint not some mixture of things.
- kbenson 8y agoWell, if you're asking the endpoint for an HTML representation of something, and it responds with template portions and rules for combining them based on data (React,Vue), doesn't it make sense to respond with all the date needed to actually build it right then and there? If someone requests /users.json I return JSON. If someone requests /users.html I return a document with rules in JS for how to build the HTML based on the data (Vue) and the JSON to build it with. In both cases the JSON is the important part, the Vue stuff included in the HTML version is just a transform on that data to be applied by the client. In that respect, I think not including the desired JSON would by hacky, requiring a separate request for the actual data you requested initially.
- azangru 8y ago> a front end using one of the major frameworks (Vue for me), but without even the need to managing it all with node and NPM This sounds like such an arbitrarily painful limitation I couldn't resist asking: why? As far as I heard, package managers have been regarded by every language as a blessing. Ruby has its Bundler; Python has its pip; PHP has its Composer (and I heard PHP programmers joke that they feel like grown-ups now, when they have modern tools). Why would you deliberately exclude Node, NPM, and the whole ecosystem that it brings to the table?
- kbenson 8y agoBecause I'm literally using Vue, Axios, a polyfill, and Bootstrap-Vue. Two CSS link tags, and four script tags. Currently for external resources, but trivially brought locally. It's an internal web-app, so it's not like minification is even required, much less bundling. No Javascript is used on the back-end currently. To use NPM/yarn/etc, I would have to first install Node, and then configure it to build my stack. At some point if I pull in a bunch of requirements, maybe that's worthwhile, but right now, it's actually a fair amount of work for dubious return given my current needs.
- azangru 8y ago> I would have to first install Node You mean, locally, on your machine? But it's not a big deal. Not even a small deal. It's, like, not a deal at all. But I get your point. I thought you were advocating a general approach, but instead you were describing your specific setup.
- kbenson 8y ago> You mean, locally, on your machine? Well, in this case development is done through Vim on the remote server, first in a dev environment branch, and then pulled from production. It would require installing the tool chain on the server, which is an artifact of my development process, but nevertheless should require consideration in my case. But yeah, I'm just describing my setup, and the ease of which it allows getting started and productive. I'm wasn't really advocating for or against using a build process for the front end in general, just noting my current process. I imagine if I was using a lot of modules in my front-end, I would see the benefit of putting more tooling in place to maintain and manage it fairly quickly.
- fencepost 8y agoBut it's not a big deal. Not even a small deal. It's, like, not a deal at all. I can't help but feel that the road to maintenance hell is scaled with tiny tiny things.
- ashton314 8y ago> Perl, Mojolicious, Vue That's a lovely stack you got there. I'm a Perl guy (sometimes) myself, and I hated all the bloat of the JavaScript tooling. I recently found Vue and I fell in love with how light-weight it is.