Skip to content

»Lightweight« The Anti-Pattern

I have a problem with the word lightweight. It used to mean something along the lines of »efficiency« (in terms of performance, memory footprint, code used). Nowadays it seems the word lightweight has become redefined to »ommitting the important stuff, doing things wrong - as an excuse for having a "small" code base«. Caution: this is just an opinion

Being primed for the acronym URL (have guess why), I have a closer look at anything new popping up claiming to parse or manipulate URLs. So happened when @smashingmag and @JavaScriptDaily promoted url(). Looking at the code, I instantly felt the urge to just close that browser window. I resisted, read the code and found a couple of issues before giving up on deciphering the code any further. My concerns were shut down, given the reason the thing was »meant to be lightweight and simple«. There it is, that lightweight thing. But apparently, there also is a thing called heavyweight (doing things properly, or what?) - which was the reason given to another issue being shut down.

Today pickadate.js scrolled by and I suddenly had that weird sensation running down my spine. Could've Rebecca's tweet been hinting at this? Yep, as tragic as this sounds, it did. I usually don't bother reading HackerNews (or HatingNerds™, as I like to call it) - flipping through the comments brought tears to my eyes. People actually congratulated for »a great UI«. Only a hand full mentioned keyboard and accessibility. There is no keyboard access and accessibility-wise it's a fraking nightmare. But hey, it's a great lightweight date picker - job well done!

What infuriates me is not that people are trying to publish their poor code. They don't know better, look at their code / ideas if you still need evidence. No, what annoys me most is that trusted resources (HackerNews, JavascriptDaily, SmashingMag, …) are giving these immature libraries too much attention.

It pains me that there are over 1100 People starring a github repo, that sacrifices quality of implementation for something as ridiculous as file size. It pains me that over 1000 github users like an URL parser, that completely disregards the standards and uses lightweight as an excuse to do so.

Dear news services: I implore you to do some sort of quality control before recommending random tools. It's ok to not promote everything.

Dear developers: I implore you to have your friends look things over to find serious issues like missing keyboard access, accessibility, or even specification compliance before you go public.

Thank you.

Addendum

Now, you shouldn't stop encouraging people to create stuff. On the contrary. If they build stuff and didn't quite nail it - help them improve. People did exactly that to me. I sucked, they told me, I improved. If they hadn't, I'd probably still be building table-layouts.

This is not a pissing contest. It never was, it never will be. If you think it is, you are in the wrong place.

Addendum #2

Now that a day has passed and I'm killing time at some random airport, it's time to add a few more thoughts to this otherwise useless rant.

By no means do I want to hinder anyone from taking the steps of creating stuff and publishing that work. We, the web, need this to happen. In fact, we need to encourage people creating and sharing tools. This is important.

We need to help each other build great stuff. If you're new to the game, find people to review your stuff. Other people have been playing this game for some time now and do this. The fact this happens behind the scenes is just not communicated well enough. Every article written - reviewed by others. Every tool developed - reviewed by others. We need a second (third and fifth) pair of eyes and opinions. Either to hilite mistakes, or to strengthen our position for a specific decision / solution.

That's that. Back to the lightweight thing.

Take jQuery and Zepto for example. jQuery found and fixed all the gaps. They ended up with a bloated code base. Zepto swept in, took jQuery's good parts, made some sacrifices, et voila, it's a lightweightier solution to the same problem (yes, this is overly simplified, I apologize for that). The point is, the creators of Zepto had very good knowledge of the domain and its problems. They made sacrifices and made an argument for it. This is fine. You may break the rules if you know what you're doing.

The two projects named in the rant above are not like Zepto. The date picker is lacking some (fundamental) features. The author's been called on them. He'll probably investigate and fix them - any serious developer would. If this had happened had he have his code reviewed by others? Up to the reviewers. But at least there'd been a chance to find these issues before hand.

The URL parser thing is another story. A lot of issues have been pointed out - most of them shut down with the excuse of being lightweight. This author made a deliberate decision to provide a broken service without explicitly saying so. This is the scary part. People who've not read RFC 3986 - and I think they are the majority - might just mistake this broken thing for a working solution. This is bad. Very bad. Fact is, most people just trust some random third party utility to get the job done right without investigating.

So from now on: if something is labeled »lightweight« - be extra skeptic. Investigate to find out if you're dealing with deliberate decisions or plain inexperience.

Be a little more critical about things. If you see mistakes - tell the authors. How are we - each and every single fraking one of us - supposed to improve if others don't tell us what we did wrong? Be more critical - it's not a bad thing.

Comments

Display comments as Linear | Threaded

Barney Carroll on :

Barney CarrollRead this ages ago, and I agree — then and now — thoroughly: the JS world is utterly polluted with people contributing their own particular angular version of the wheel and shouting it out from the rooftops. Worse, the number of amateur front-end related rags that create lists of "top 10 X plugins" farm these for the cynical aim of drawing more idiots and increasing their daily ad revenue. The worst thing is that the idiots (and every beginner has a right and duty to be an idiot) get the idea from what they perceive to be their elders and betters that propagating unresearched, unverified, incomplete code is a good idea. In consequence, you get many people who after several years in the job would normally be competent programmers still stuck at amateur level because they've been encouraged to roll their own solution for everything. Critical thought and the learning experience become increasingly more difficult and pose more and more of a threat to their accumulated worth measured in "my version of X", and they get stuck, because when you've supposedly gotten that far, admitting false premises in your self-worth is too much to take. It's a social problem more than anything, and I try to fight against it as much as possible.

One of the ways I do that is by promoting URI.js. I've gotten loads of praise myself from telling people to ditch their particular version and stick to yours, because it's thought of all the problems — and if it hasn't, then fork that and raise a ticket, and contribute to the collective knowledge economy, rather than retreating into your comfortable dark cave and rolling your own.

But the real reason I came back to comment is that despite agreeing with this sentiment and loving URI.js so much, I did actually end up writing an incomplete, untested subset ;)

https://gist.github.com/barneycarroll/5310151

The author does not allow comments to this entry