Why don’t extra builders “use the platform”?


For years, advocates for net requirements, efficiency, and accessibility have implored net builders to “use the platform”. I’ve usually been a type of advocates.

The argument is straightforward: why construct one thing your self, in JavaScript, when the browser can do it for you? Whatever you construct, it’s more likely to have poorer efficiency and worse usability than one thing the browser might simply offer you out-of-the-box.

I believe it’s value taking the opposite aspect, although, if for no different cause than to grasp the place the “platform-skeptic” builders are coming from. If “use the platform” is so apparent, then why accomplish that many individuals appear to want convincing?

The most evident cause is historic: for the longest time, browsers had been taking part in catch-up with the ecosystem on prime of them. Libraries like jQuery crammed essential gaps whereas browsers applied equal APIs – and even then, you may need to attend for laggards like IE6 to age out earlier than you can really use them. Today, most browsers are evergreen (Safari is debatable, though ~7 times per year ain’t unhealthy), however up till the 2020s or so, net builders needed to cope with a decidedly lumpy web. In that surroundings, rolling your personal is a good selection.

Another cause is familiarity: whenever you’re used to searching for React elements on npm, that’s what you have a tendency to achieve for, whatever the downside at hand. If you seek for “sticky positioning” on npm, there’s no package deal that claims “simply use CSS place: sticky, you dolt.”

And usually, even with a sturdy customary, libraries on npm would fill a helpful hole between framework ergonomics and the platform beneath it. I all the time discovered it intriguing that many React builders most popular to stay to JSX and React idioms – uncooked DOM APIs felt “icky” – however had been completely completely satisfied to make use of lower-level libraries the place uncooked DOM manipulations are widespread. For instance, a digital record library would possibly fortunately use uncooked DOM APIs for pure efficiency, whereas exposing higher-level primitives {that a} novice React developer might higher grasp. In a way, the ecosystem of React elements led to a pure division of labor the place these with extra experience packaged up unfamiliar platform APIs in a extra acquainted kind issue.

Some of this impact was additionally pushed by documentation. Many npm packages have lovingly detailed READMEs or web sites with examples, tutorials, and screenshots. Whereas till MDN grew to become cemented because the go-to place for net documentation (with web.dev as Google’s extra future-facing arm), documentation for the online platform was scattered throughout blogs, StackOverflow, and websites like CSS Tricks. And many of those websites would simply inform you to make use of a well known library like jQuery or InexperiencedSock!

The Dragula site versus the Drag and Drop MDN page. Arguably the previous remains to be extra compelling.

If it had been nearly third-party libraries versus platform APIs, although, then I don’t assume it might absolutely clarify the antipathy towards “use the platform.” Developers who’re lazy (or do I repeat myself?), and who simply need a ready-made answer for no matter downside they’re going through, are unlikely to care whether or not that answer comes from npm, the browser, or copied off of somebody’s random GitHub Gist. They need to clear up their downside and transfer on. But there’s a special supply of anti-“use the platform” that I need to discover.

For a sure sort of developer, constructing issues your self is simply extra enjoyable. And usually the ensuing code is simpler to cause about, particularly if you happen to don’t have an encyclopedic data of the online platform. And when you’ve constructed one thing, there is usually a type of IKEA effect the place you need to keep and tinker with your personal selfmade code.

As an instance, let’s think about you’re attempting to construct a modal dialog. You would possibly visually perceive how these are imagined to work: content material seems on the display, however the background remains to be seen though partially occluded, and possibly clicking outdoors the dialog dismisses it. So you would possibly seize for place:absolute and z-index to place the dialog accurately – aha, however the background nonetheless scrolls, so you need to disable overflow on the physique… And then if you happen to perceive one thing about accessibility, you understand you should deal with Esc to dismiss, and construct a focus trap, and return focus to the ingredient that launched the dialog, and…

For many builders, what I simply described appears like a nightmare (and a great way to construct one thing that solely half-works). But for a lot of builders, this appears like enjoyable! Think of how a lot you be taught as you begin constructing this factor. And take into consideration how you can begin placing your personal spin on it by including animations, themes, an non-obligatory “shut” button… Before you already know it, you’ve constructed a library that’s able to go on npm. That’s manner extra enjoyable than simply grabbing

and calling it a day – what a downer!

And for many people, earlier than APIs like

existed, this was how we discovered the online platform! Many of the individuals who now advocate for “use the platform” had been as soon as themselves authors of polyfills, shims, and libraries. I do know as a result of I’m one myself! I spent years engaged on tooling for IndexedDB, WebSQL, and different browser storage APIs as a part of my work on PouchDB, which ultimately led to me feeling assured sufficient to take a seat in W3C requirements conferences and even open points and pull requests on the IndexedDB spec itself. Without the forcing perform of a niche within the platform that wanted to be crammed, I don’t know if I might have discovered the curiosity or motivation to get to that stage of experience.

Of course, doing it your self will not be all the time an unalloyed good. Sometimes it simply comes from pure ignorance. On the online platform particularly, I believe one of many causes there was such a proliferation of JavaScript options to issues that may very well be higher solved by CSS, for instance, is that many builders simply didn’t take the time to deeply perceive how CSS works.

And to be honest, CSS has traditionally been exhausting to grasp! There’s a cause the location is known as “CSS Tricks.” Things just like the clear fix, floats, and the min-width: 0 trick are hardly intuitive. Rather than attempting to grasp CSS’s inside algorithm, it’s usually a lot simpler to simply think about the crucial logic you need after which specific it in JavaScript. Plus, for years CSS didn’t have an easy technique to specific widespread patterns like line clamping, textarea resizing, scrollbar hiding, and many others. So after all builders constructed it themselves utilizing the instruments they already understood.

I don’t even assume this phenomenon of “avoiding the platform” is restricted to the online. It can apply to any developer engaged on prime of a platform they don’t absolutely perceive. For instance, at my work, we use ClickHouse for storing varied sorts of analytics knowledge. At one level, my coworker and I disagreed about how one can retailer massive JSON knowledge in a column: he constructed a system for compressing it earlier than storage, whereas I put the information in a separate key-value retailer and solely inserted the important thing into ClickHouse. It turned out we had been each unsuitable! ClickHouse automatically compresses data, and as a columnar data store you really get higher compression throughout rows if you happen to simply let ClickHouse deal with it. And the separate key-value retailer was only a poor man’s model of what a columnar SELECT already does.

I solely realized these items after really taking the time to totally learn the ClickHouse docs after which write a benchmark to show my speculation. In the tip I used to be shocked that we had constructed one thing that was slower and clunkier than what the platform itself might give us out-of-the-box. The parallels with JavaScript and the online platform had been exhausting to disregard.

I’m certain that if you happen to’re a developer on iOS or Android, or somebody constructing on prime of a sport engine, or actually any type of developer constructing on prime of any platform layer, you in all probability have comparable tales. There’s a cause that the stereotype of the grizzled senior engineer is somebody who can take a junior’s baroque tangled mess of code and change it with a single line. The extra you be taught, the extra you’re capable of wield your data of how all the system works end-to-end to create the smallest doable contribution to it (and thus scale back your upkeep burden in the long term).

I’ve been attempting actually exhausting to not discuss AI this complete submit (as a result of I’ve completed it to demise over the previous 12 months), however after all I can’t assist however surprise how AI coding will influence this phenomenon. I even have each an optimistic and a pessimistic take:

  • Optimistic: as a result of LLMs have an encyclopedic data of no matter platform you’re working with, they will select precisely the correct platform API to ship the expertise the prompter asks for in imprecise English. And since this answer is probably going sooner and extra right than userland code, the agent will desire it after rigorous testing and benchmarking. Furthermore, the “IKEA impact” goes away when builders should not really writing the code themselves.
  • Pessimistic: as a result of LLMs appear to like duplicating code – for instance, ignoring helper capabilities that exist already in favor of writing their very own for the umpteenth time – the quantity of customized, non-platform-idiomatic code will skyrocket. Developers received’t instruct their brokers to check sufficient or to strive sufficient options, and can simply commit the agent’s first draft. And as a result of it’s all the time doable so as to add extra epicycles, the brokers will proceed to iterate on over-engineered options that by no means ought to have existed within the first place.

In my very own use of AI coding, I’ve seen each phenomena occur. I’d wish to assume that as fashions and coding harnesses get higher we’ll begin to veer extra in the direction of the optimistic final result, however I can’t say for certain.

In any case, these are my longwinded and considerably conflicting ideas on “use the platform.” As a mantra I find it irresistible, as a result of it succinctly captures a sense I’ve once I’m taking a look at some overwrought pile of spaghetti code and considering how significantly better and extra elegant it might be if the writer simply understood the layers beneath them a bit higher. At the identical time, I’ve been that writer, and I’ve felt the enjoyment of constructing such lovely, messy code (lovely to me, anyway), so I believe it’s value understanding the place such builders are coming from. For that cause, I’m certain we’ll be listening to “use the platform” for so long as there are platforms.

You can touch upon the fediverse or Lobsters.



Source link