Comment I find this useful, ignore the FUD! (Score 1) 488
As a cocoa programmer tasked with implementing yet another embedded htmlfucking5 project thanks to Adobe Edge, I wish Javascript would die.
After looking at the myriad of patterns for my current project - a Javascript client REST API - I came to the swift conclusion that most of them are silly, namespace polluting, self initializing mindfucks. I gave up looking at patterns, found a preloader (lab.js - although require.js is looking good) and wrote my own module pattern objects to satisfy the clarity, structure and ease of maintenance requirements of a good API. Being verbose is not a sin in enterprise Javascript.
I have a lot of little helpers like this:
MyCompany.fetchSomething(function (things) {
});
Plus some event handlers
MyCompany.addEventHandler('scope', function (data) {
});
But by far the largest section of my code is the model fetching stuff - you know the really boring bits where copy by value doesn't cut it, I need functions and and objects.
My last trail by fire was a paginated e-book reader with support for embedded video and audio. That wasn't a lot of fun, but at least the CSS3 spec was helpful and the DOM readable. The Javascript in that project was limited to around 200 lines.
I recently discovered that REST libraries are pretty long winded - after 200 or so lines, Javascript becomes a horrible implementation specific mess of spaghettied anonymous function chains. I opted for the Module pattern and ran into lots of fun:
- I have to write all my getters and setters, as properties/getters/setters
- Variable lifting/elevating results in seriously ugly var blocks at the top of my functions and causes copy by value in some rather obvious block scopes
- Fast enumeration (for x in a) doesn't work
- Itterating through ordered keys is painful with associated hashes - you have to create a key enumerator (with pushes! ) each time you want order. jQuery doesn't particularly help.
- Everything runs on the same thread.
- Post increments don't work in for loops, for (i = 0; i
- Prototypical inheritance is pointless key bashing - it pollutes your vision with the use of 'self' everywhere god forbid you miss a one.
- Inheritance is a dirty word unless you've already written things in a special way (prototype extension is just a dirty hack!)
- Given a lack of compile stage, writing code is error prone and debugging a tiresome line by line experience
- Chained async callbacks are inflexible, hard to read and painful to edit. Expanding ajax piped promises to a colleague made him cry and take a week off sick.
- Everything has to be a fucking DOM element before jQuery/the DOM will play nice
- Preloading code, initializing it and handing off to that code is painful/ugly with self initializing modules.
So with MS actually targeting 5 or more of the annoying problems I face, I find this library really useful. But naturally I'll get modded down because, a) I develop Apple software and b) I don't pick sides, I program (I like Windows 7 as my desktop, XCode as my IDE, and Slackware on my shell - go fish!).
Oh well, I can only dream of this being adopted!