We Still Haven’t Figured JavaScript Out

That fact that manipulating the DOM via JavaScript has become very easy, thanks to libraries like jQuery, doesn’t mean we should feel authorized to write crappy unmaintainable JavaScript code.

The problem is, I can’t seem to avoid writing piles of bad JavaScript. It’s just too hard. Or, rather, it’s too easy to write bad code.

You see, most of the time I write JavaScript is to make use of some jQuery magic. The process is typically iterative, and the result is a huge amount of code that is relatively simple, but highly coupled with the underlying DOM. Unfortunately, as I already wrote one year ago, this can’t be helped.

If you consider that the process is the same for most pages – bang out some HTML/CSS, add a bit of JavaScript, repeat – and that over time you learn to do new things, or simply decide that something must be done differently, you realize that most “legacy” pages are a total mess. In this case, “legacy” might mean pages you wrote a week ago.

Discipline surely helps, but I feel defeated as soon as I have to repeat myself and do the same thing over and over again, only with minor differences.

DOM manipulation is very easy today, but it’s still a chore and for some reason we can’t find the way out. Every layer of abstraction we add, every shiny JavaScript UI framework, after the first wow moment, limits our freedom and forces us to go back into the tunnel – perhaps deeper.

Pingdom estimated that JavaScript-related HTTP requests have increased 48% in 12 months. That’s the proof of how big the problem is. Meaning: we developers are producing tons of JavaScript code, most of it being messy, possibly buggy and probably inefficient.

Perhaps we should just get over it, and consider JavaScript the Assembly language of the web – only slower – with jQuery as something between C and C#/Java built on top of it. It’s a clunky way to get the job done, but we have no other choice.

P.S.: If you use JavaScript outside a browser, you’re insane. Seek help immediately.


Posted

in

,

by

Comments

One response to “We Still Haven’t Figured JavaScript Out”

  1. Isa Avatar
    Isa

    And Microsoft wants us to use JavaScript for Windows 8 app development.