This is just a short rant I guess. Recently, I've wanted to work on some projects requiring me to write a web front-end and every time I revisit doing this, I'm left feeling very frustrated and defeated.
I actually like front-end
Not something you normally hear from people that spend their time writing deploy pipelines and VPC network infrastructure. I've always liked the creative aspect of web design and working on visual mediums. At one point I thought I'd be doing front end dev, but quickly decided to not pursue it after working on front-end stuff at Carfax for about a year.
At that time, front-end was mostly dominated by jQuery plugins and crazy over-engineered MVC frameworks. Around this time, Bootstrap was released, along with a bunch of other CSS / JS frameworks that were supposed to help make development faster. They kind of did, but also introduced a lot of issues with customizing things to your needs that you were probably better off writing your own library for you own needs.
I left front-end dev because of just how painful it was to do, and it has always felt so needlessly difficult. Like how many of us have had the experience of "how do I center this fuckin div!". Why is that so hard? Back then we only aligned stuff using floats or tables. I guess in short, the web was just too immature and clunky to my liking. Even today, I feel like you have to be something of a masochist to actually want to do front-end.
As a programmer, I thoroughly enjoy the fact that other people write high quality libraries so that I can just reuse their code and not have to think about those problems and just get going with my project. This is true for most things I do with DevOps and backend libraries in Python. Those libraries / tools work great most of the time. I really wish I could say the same for the frontend...
How it feels to do front-end in 2022
You have a new project and your colleague told you that React is good and an industry standard. So you spend the next hour just trying to choose one out of literally thousands of component libraries to use.
npm start dev command!
If by some miracle you get that working in less than a half day, now you get finally use these components! Wait, the docs don't have copy and passable code? It's no problem; you just have to dig through lots of stack overflow posts to find an example that you can tailor to your needs.
I for one am glad that the frontend community adheres to common conventions. After all; what really is the semantic difference between a Modal, Dialog, Popup and Popover.
So after a while of thoroughly reading the docs and StackOverflow, you finally figured out what to do. You start writing your app, and get pretty far. Ah but your compontent library is missing a component that you need.
- Switch to a new component library and rewrite everything from scratch?
- Try to import just the components you need and make a frakenframework of sorts?
- Write your own component?
Wait none of that matters now; a new thing came out this week!
exampleCode(). showing(aThing(), thisLibrary.does()) .justIgnore( () -> theSyntax() );
Thank goodness they added these chained call backs, I don't know how people coded before this! I hope I don't have issues compiling back to ES6. Don't sweat it too much though, wait another few months and they'll be using MelonScript or SuperScript, or some new flavor that will solve all it's problems.
Now your app has been in production for a few months and you need to fix some bugs; requiring you to update your library version. Well now you can't even do that because the package maintainer took the library off the internet and replaced it with bitcoin mining software to protest Climate Change.
I know that WebASM is supposed to be at some point allow us to solve this issue of a single language dominating the front-end, but we really haven't seen much practical things from that effort yet; outside of cool OpenGL ports.
I loved the simplicity of the old web. You can super quickly prototype something on a local web page. You didn't need to worry about package managers, CDN's, or running a web server.
From a DevOps perspective; I will go very very very far out of my way to not have to run a production NodeJs server. I've had numerous horrendous experiences in managing and troubleshooting production NodeJs servers. I'd much rather stick with the devil I know, like NginX. Again I yearn for the simpler times when you just served an HTML page and didn't have so much complexity to deal with. Browser default components don't have any of these issues, why can't we have more of those?
I've been following the evolution of front-end for a long time. I don't think front-end developers realize just how complex they have made their ecosystem. And I'd say, quite needlessly so. For something as huge as Facebook, that level of complexity is probably warranted; but the level of complexity that Facebook uses is the only level. React is React. There is not really a lower level of complexity for smaller teams or hobby projects. One that doesn't require WebPack, NodeJS server, JestJs tests, code generation, tree shaking, CSS precompliation, etc etc. One where you can just get to the heart of what you're actually trying to do, which is make a fucking usable component.
The thing that I think frameworks like React get right is the component encapsulation model and in principal I quite like the React way of doing this, it's just all the ecosystem surrounding it that is really painful and a huge turn off to me and the tools are individually so complex and never work out of the box for me.
When React rose to popularity in ~2015 (which is right around the time when I left Carfax and moved on to DevOps) the W3C had been working to develop and implement a way to do what React does, natively in the browser.
This is usually referred to as Web Components; but is really the combination of 3 features to the web standard:
- Custom Elements
- Shadow DOM
- HTML Templates and Slots
As of 2018, all major browsers support all three of these standards natively which means that native custom components have arrived.
Authoring Web Components
These native API's are a bit clunky to use, or should I say are low level. It makes sense, to a degree, that they would do it that way because it allows for libraries to sit on top that expose different abstractions tailored to certain needs. But I fear this gets us back to the issues from before where these libraries will bring in elaborate build systems and complex bundlers and such.
With that said, I've experimented with a few libraries, as well as
I quite like Stencil, but am a bit annoyed that it forces you to exclusively use Typescript. It is essentially a toolchain for "compiling" Typescript as well as the HTML and CSS into a native web component. The thing I like the most about it is that it includes the primitives for hydration and minifying bundles. I could use this tool right out of the box. Or put another way; you can experience success in 5 minutes with this tool; which is more than can be said about React. However, in general, I'm quite wary of complex build chains, and indeed if there was some kind of underlying problem with Stencil's use of WebPack, I'd be at a complete loss at how to fix it.
I also quite like Lit, though it doesn't come with all the same nice batteries that Stencil does. Normally this would be a trade off of bundle size but infact Stencil and Lit will produce bundles of basically the same size since they will both produce an artifact that is just the native component with a thin abstraction layer over it. Though all I really care about for small projects is just being able to author a component quickly. Lit is basically just a thin abstraction on top of the native API's. I won't really know which of these I prefer until I really dig into a project using them.
Native Component Libraries
I've searched pretty thoroughly across the web for anyone authoring native web components and here's all the ones I've found:
I've dabbled with all of these, and the one I like the most is Shoelace. It seems to be the most batteries included, but also customizable (via "design tokens") of the lot.
To me these are basically the next evolution of Bootstrap. Gives you a lot of stuff out of the box, but this much less boilerplate-y to use, and has the styles encapsulated.
Things do seem to be getting better
With the advent of native web components alongside tons of fantastic new CSS features such as Grid, Flexbox, and variables, it seems like things are heading in a good direction for the web.
Right now I'm just stuck in a bit of a limbo waiting for Web Components and WebASM to really get mainstream adoption and start bearing fruit. React just has so much momentum and adoption that these new standards will take a while to get large scale adoption.
Though one very nice feature of native components is that you can just use them in React, Vue, Angular, Svelte and basically every React-like framework; so there is a non destruction path to adoption at least.
At least with native web components, we can rely on them to work basically forever. One of my biggest gripes is that with all the frameworks and libraries out there; how many times has someone reinvented the "button" component? There may be times that this needs some specific customized button; but generally its just a box with text. My hope is that native web components will see a lot of reduction of this reinventing the wheel. Just a handful of libraries that give us the tools to customize parts of the element as we need and we're off to the races; or hell, give me high quality, accessible but otherwise unstyled components that I can customize to my brand / needs.
My hope is that one day, the web wont be so painful that I might be able to re-enter the world of the front-end as a professional. For now, I'm fine to watch from the sidelines.