Hacker News new | ask | show | jobs
by kbenson 2653 days ago
Most my work is generally in Mojolicious (with or without an Nginx instance proxying and providing SSL support, but I've found with Nginx easier), jQuery and Bootstrap. A while back I bit he bullet and learned a bit of Vue... and I have to say, it's pretty nice, even if I just use it as a way to build the page.

The main thing it provides is a sane toolset for what I was already slowly moving towards, which was templates in script tags (grabbed through jQuery), and my own home rolled templating in JS (it's just a few lines for something minimal). I get some JS from the server (or serve it on the page), and use a JS class to build the representation for display, but this allowed me to easily build the initial page and also get updated without a complete page reload and reliably update the page.

Vue is basically the same thing, but taken a few generations farther. You have a data structure, you define how to build the HTML from the data structure, and Vue tracks the data so if you change one five levels deep in the data structure, the page just updates accordingly (and it only updates the things that change, so half entered forms/text boxes don't lose all their state.

It's nice to just have to serve JSON, or a minimal HTML page with some JSON data in a script tag. No mixing Perl templating, and HTML, and JS anymore. At least for a select few new things I've deployed. It's not like I can just replace everything. I also forego the whole NPM and deployment stuff, and just include Vue with a script tag, and write my components either on the page, or in a JS file (or set of files) I can load, depending on whether the components have any use outside the page I'm writing them for. Dead simple.

If you haven't tried it Vue (and you very wel may well know everything I just mentioned about it already), I suggest you do one of the quick online tutorials to get an idea. It's actually a pretty cool idea (and since it's hard to get away from using JS anyway, you at least get to cleanly separate the front-end from the back-end).