title: Put the knife down and take a green herb, dude. |
descrip: One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com Using 89% of the same design the blog had in 2001. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white. As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
x
MarkUpDown is the best Markdown editor for professionals on Windows 10. It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support. Features you won't find anywhere else include...
You've wasted more than $15 of your time looking for a great Markdown editor. Stop looking. MarkUpDown is the app you're looking for. Learn more or head over to the 'Store now! |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Friday, May 20, 2022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Step 1: How I chose ReactI'm working for a company that has a lot of legacy code, where "legacy" means "nothing on the client newer than AngularJS". Recently, I essentially volunteered to figure out how to stop building more technical debt by proposing a "modern" JavaScript templating engine (and associated tools) to use going forward for new feature work. But since there's very little pure greenfield work for us in the near future -- and plenty of new features on the backlog -- my solution needed to be able to operate in a lot of different environments without causing ramp-up headaches for each new team of developers. Finding a solution to that is the real challenge I'm going to describe here. I should note that, even in a working museum of obsolete code, the idea isn't and shouldn't be to toss the legacy code and start over, no matter how tempting that might feel. As Spolsky said years ago...
In brief, you want to keep as much as your legacy code running as is realistically possible, refactoring it as your resources and priorities allow. I've split my response into two posts.
What follows is part 1... Researching a solutionThere seem to be three clear candidates for a modern browser-based templating solution/stack:
I mean, there are other super-cool options (where "cool" means "better" given the right developers on your team), like Svelte, but I'm trying to stay super-conservative here to match our culture and existing devs. Remember, this is a system that's largely AngularJS (that's Angular 1.x for those not in the know) but it may include even more lines of code in ASP.NET than AngularJS! That is, at start, my newest existing code is AngularJS. The rest is all So that pushed me to measure templating systems on these three registers:
Why not use React?Admittedly, I was pretty sure I had 1 & 2 (Popularity and Ease of dev onboarding) answered going in. In my experience, React seems to be both the most popular framework (both in what's known and what devs want to know) and the technology developers get up to speed on quickest. Our recent job applicants' skills also seem to bear out this preference for React. Out of hundreds of resumes (where React was most common), we had 15-20ish interviews that, aside from one 100% Vue expert, gave us exactly zero applicants who were lacking React completely. Further, I've used both Angular.io (6+) on a $30 mil/yr revenue project with four dev teams and React on a healthcare practice management project that was a little smaller, for about 18 months in each. Developers do better, in my experience, ramping up and developing quality code with React than Angular 2+. Those two together made me think that rather than looking for the best fit from the available templating systems, my job could be more to the point: Are there any reasons React shouldn't be our new templating system? (TL;DR: The quick answer is no.) Jerry, SHOW ME THE NUMBERS!!!1!But, like the scouts they kicked out of Oakland in Moneyball, managers don't want to make decisions based on wizened, experienced devs' feels; they want numbers so they can't get fired if things go sideways. For React, at least, we've got 'em. From statista.com:
From stackoverflow.com (these are amazingly close to Statista's without being exact matches):
Also from stackoverflow.com (and notice that Svelte pokes its head out again):
Vue and the Problem of the Progressive FrameworkThis brings me to #3: A framework that matches our current use case. I've liked Vue for years because it's a "progressive" framework -- which should not be confused with the "progressive" in "Progressive Web App" (PWA).
And Vue does deliver. I've created transpilation-free Vue projects in the past, and I wanted to preserve that option for us here. You can sprinkle Vue almost anywhere in your existing app if you need to. This would allow us to start using a modern framework anywhere in the app without the barrier to entry of normal build requirements. I wanted us to be able to insert our new client stack into any new UI work, even if it was an addition to legacy code in AngularJS or knockout. I didn't want to preclude using conventional builds [for new projects], but I didn't want builds to be a technical blocker during a design phase so that we ended up with more new code in twenty year-old stacks. Instead, I wanted new code to be able to be "eaten" by a modern project with minimal porting. That is, if we have five new features and only one is greenfield, I don't want to have to set up four slightly different builds before I can get modern stacks into those four. Nor do I want to maintain those two-staged builds as legacy and modern requirements fight going forward. This was the number one reason I originally wanted to use Vue over React. Vue has some other debatable advantages; I'd say Vue is "as good as" React in most ways. But it was this conscious decision to be progressive that stood out as a clear Vue advantage. Opposed to Vue, doing React "by hand" was a pain in the rear. I mean, you can code React by hand, making no changes before releasing to browsers...
Source of full code for that example over here. ... but this is not a sustainable way to write apps, and quickly loses React's component framework advantages. Though, spoiler, you're right. The real hang up isn't React (though it is sizeable at 133 kB), it's JSX. More on that in just a second. PreactWhen we were looking at using FullCalendar to add calendars to our app for a feature slated to be done before we adopted a modern stack, I read about Preact. From the Fullcalendar.io blog:
What's more, Preact, when paired with a special template literal processor type called htm, allows for what Preact bills as its no build tools route:
Transpilation-free Preact via HTM sounds exactly like the missing piece that makes React (well, the "React family") a progressive framwework in the same sense that Vue uses the term. We can literally embed this version of Preact anywhere without requiring a build to transpile to JavaScript a browser can easily digest. What's next?This was enough for me to think pitching "the React family" via Preact was the best plan. Before doing so, though, I wanted to play around with injected Preact components inside of an AngularJS project. That code is what we'll look at in Part 2 [which has not yet been published]. posted by ruffin at 5/20/2022 03:20:00 PM |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
All posts can be accessed here: Just the last year o' posts: |
||||||||||||||||||||||
|