I've been a coder since 1986 and used many languages on this journey. Starting off with Locomotive Basic on Amstrad/Schneider CPC 464, learning Prolog, Assembler and Pascal. With Borland Turbo Pascal I jumped to IBM PC XT, along I learned stuff like AT commands for Hayes & USRobotics modems, still used today. Got stuck with it on PC-MOS/386 up to 1995 when I made a full transition to Windows 95 and Delphi. Along came ASP and ActiveScript, I even learned some C to develop drivers for what is today called IoT. Ajax wasn't a thing yet in 2005 when I was running a kind of Protobuf service with highly compact and typed structure to fetch data from Foxboro DCS into Web Pages. Yes, they were not called Apps back then :).
PHP was evolving at the time and MySQL came along. I jumped on it at version 3.23, never left. With PHP, I made dozens of great apps, loved by the users. I do have a slight tendency to push myself into the misery and to the limits by producing one-off apps which nobody else wants to tackle. No resales, paid by the project.
So, fast forward to Corona times in 2020/21. As for those previous century apps ... yes, I still support them. I've got clients with 20 years history in local Paradox database. A licensed Delphi installation on a virtualized Win 7 boots up in seconds.
I've been using the LEMP stack for quite a while now. Laravel, MySQL and Vue were my weapons of choice. Did a few projects in Go, loved it. Explored Rust, loved it just the same. Python ... well, running smoothly but there is nothing major to write home about. Added Redis, use it everywhere. Their Timeseries was a revelation, MQTT is my daily life as I still do a lot of PLC related work.
This will not be a quick read, grab some beer. Or java. Whatever makes you happy, just stay with me. I'll dive into stuff, spread it all around and close it down on my way back. Kinda graph-y, OK?
I took on an ecommerce project. I knew I wanted a PWA and could easily serve it from a Laravel back. But, I was tired of setting up the virtualized environments for it. Docker on Windows is no where near mature for serious projects, so I am staying with Virtualbox. WSL and the second reincarnation is about the same joke. As an alternative, I do have Macs around the office but I just work so much faster on Windows with all the available tooling. I just can't get used to Macbook not having dedicated navigation keys. I was born and raised with a keyboard, so this is huge for me. I tried running a Mac with a PC keyboard and that somehow worked. Also, there actually was time when I was using Ubuntu as my primary desktop, but landed back at Windows for the same reason: vast selection of tiny software tools I use every day.
Back to the project: I explored some options on how to serve my PWA with data and not run a VM in Windows. I could write an API server in Go natively on Windows and cross-compile, done it before and it runs smoothly. For example, I volunteer at First Lego League Tournaments and we run a scoring software there written in Go. All realtime, speedy as can be, clean code, reads like Pascal. I am using the Echo framework and it does the job. It would be a valid choice, but I am just not fluent enough with it and would still need to invest time into exploring the specifics of the language.
Microsoft offers a solution with their stack but I went away from it at ASP.NET and would also need to invest time into languages. No go, at least for now.
Installing PHP natively and staying with Laravel was another option. I am already running a native MySQL instance on my notebook to be readily available for all the hacks and developing I do, so this should not be a big deal. PHP is always welcome, especially if you have dozens of projects with it under you belt already, right? But, installing PHP on Windows (or Linux) with extensions and PECL and compiling and versioning .... no, thank you.
Btw, another thing I like to follow is Dev/Prod parity, like the 10th commandment of 12-factor Apps. You might say how does this even compare, running development on Windows and production on Ubuntu? Bear with me, it turns out the runtime environment within the OS must be close enough, not the OS itself.
That is how I started exploring the NodeJS environment. I mean, I used Node before, but never wrote an app that actually served production data. My first search was for an API/Admin producing app like Strapi. Initially a great experience, but once you start exploring internationalization, localization or database views to name a few, it all falls apart. Just not ready, yet.
So, if I need to adapt a piece of software which was supposed to help me with scaffolding, I might as well stretch some more and do it myself from scratch. I did some more researching but 99% of projects fail on such a simple requirement as a second language or local date formatting.
Let me ramble some more on localization, the one and most important aspect of any app besides its functionality. You go to the bakery in the morning and purchase a loaf of bread in your local language. Your takeaway coffee is ordered in local language and domestic quantities. Ever tried to order 3dcl of Pils in London? Good luck with that. So, we agree your app must be localized to be usable for the wide public. It may be even more important for the specialized type of apps I am writing in enterprise environment where you tackle a specific use case on some local stuff which exists nowhere else. Just compare Postal Codes around the world and try to fit a British address into valid form for address in Slovenia. If users don't understand the application or it stands in their way of completing tasks because it expects nonsense input, it can be designed by Jony Ive and still be unusable. Translations are just a small portion of the whole experience, there is formatting, positioning, plurals ...
Laravel shines here. But I am still looking for more.
This was a point where I turned to lower level libraries, like SQL adapters. What I needed was a fair ORM as you sooner or later do write one yourself. Oh, this brings back memories ... remember Torque for Java? I was trying that out and even wrote some tutorials on it:
Java never stick for my apps. Anyway, I found for example Sequelize, quickly ran thru documentation and got my API REST endpoints running on JWT within days. I am polishing this stuff as I go along but it is powering the web shop just nicely. Included restana instead of express, installed pm2 behind nginx and I am a happy camper.
So, how is it different from my previous projects? First, it is a simple folder on my laptop. How do I get it running on a new computer? Install nvm, choose latest node and you've got a running environment. Add MySQL and ORM and you've got REST endpoints. No heavyweight Vagrant deployments. No Dockerfiles, upload persistence and routing nightmares. No switching the Windows Hyper-V on and off as I still need older projects to work with Virtualbox.
I test all my apps on a variety of devices. I keep iPhone 4, SE, Motorola G2 and late Android phones around, notebooks from Atom 13,3" HD to latest HP Elitebook with tons of power and best display. 5:4 ratio monitors, 4K TVs and some tablets round up the lineup. And all of those need to access my developing app. Usually the development environments prefer running this stuff on localhost but with my setup, every npm run dev produces a sharable url to test, with ngrok also from the web. I usually keep my projects on a laptop and share the code folder so it can be accessed from an ergonomically correct desktop. I do most of my coding on three monitors and this is just the simplest possible solution. Even with desktop under UPS, I still trust notebook's battery more in case of emergency. All my projects are under git, but also backed up on real back up services. And, once I need to get on the road, I simply pack my notebook and have all the tools at my disposal for running a demo on a subway if needed. Offline.
Could all this be done differently? Sure, I've been doing it for years. This same notebook still runs Virtualbox for my PHP apps with queues and similar services, but now I am spinning up an API server and my PWA within seconds, not minutes. I do not need complicated routing setups to access it and it keeps quiet all the time.
The beauty of it is that it depends on a single installation line, the nvm. As long as you keep the same node version on production and development, it really does not matter if you're on Windows, Mac or Linux for dev. Pretty much the same with any other service, MySQL, Redis, queues, ... keeping the parity of Dev/Prod environment.
Once I got around with the ecommerce site, I couldn't stop. I have done a rewrite of a very specialized piece of code for another ecommerce within fortnight and again loved how lightweight everything feels. I am using Svelte on the front and it is a perfect fit for me.
The latest project under this architecture is an IoT data collector. Took mqtt broker library for the server, added some persistence to Redis Timeseries and voila, I am routing around two million records a day and it all gets delivered to dashboards at the enterprise level in real-time. The code is 100k zipped!
The best part of it is well known to the community: shared code for front and back, the right balance of vanilla language and libraries, small memory footprint, scalable as heck, deployable in seconds. Yes, I do prefer Netlify or similar over big cloud providers as it streamlines my process even more and is more predictable on cost. If needed, just spin up a VPS or two for the demanding API. To put this in conext, I never wrote an app for millions of concurrent users but I don't think many developers do. You would be surprised how much processing power and bandwidth gets wasted by premature optimization and over engineering. If any of my endpoints becomes a bottleneck, I have ways of replacing it with a rewrite in another technology or scale it behind load balancer. Those are the decisions I made as a Software Architect way before I chose the language or db for the app.
Speaking of databases, here is one of the Windows tools I use daily for some 15 years now:
It used to be called MySQLFront and it is by far the most complete manager for MySQL (and some others). I never write a DB migration by hand, always produce the model in GUI, connect all the tables with foreign keys, enter some dummy data and only after doing some updates and deletes on it, produce the migration. Automatically, of course. Everything else was a waste of time.
And this is what it comes down to: time. I realized I produce the same quality of product in shorter period of time. With less stress, it translates to better monetary compensation or off-time. For now, my off-time is still debatable, if you ask my family, but I just love coding.
So, this is me jumping to NodeJS. Some might argue about being late to it with Deno around or throwing existing knowledge thru the window. In my mind, I am ready for the move now as it brings exactly what I need for the current set of projects. I've seen lots and lots of projects struggle with adoption like Meteor or RethinkDB, both brilliant in my mind. But you need an ecosystem to support your operations and that is what keeps proven technologies alive. They just produce results. So is Node.
It's ready for me.
This post first appeared at https://collectednotes.com/reepolee/switching-again in June 2020.