Tuesday, December 9th, 2008

You Leaked on my JavaScript!

Category: JavaScript

As soon as I read John’s post on JavaScript Language Abstractions I knew that it would draw a lot of chatter and fuzz. John started with:

Pyjamas, GWT, and Objective-J all hinge around a central concept: Abstracting away the authoring of JavaScript-heavy web applications by allowing the developer to program entirely in their natively language (be it Python, Java, or an Objective-C-like-language accordingly).

This is a large abstraction – much more so than what is provided by most JavaScript libraries – you are programming in another language which is outputting JavaScript code. You are likely to never see a DOM object or any pieces of the native JavaScript language.

I worry about large abstractions like this for a number of reasons.

When you use a pure-JavaScript library (such as jQuery, Prototype, Dojo, Yahoo UI, etc.) you are still programming using the JavaScript language. In the case of jQuery a large number of users, who have either never programmed JavaScript before or never programmed before, acquire a good grasp of how to use JavaScript – accented by the use of the library. A pure JavaScript library makes annoying tasks simple, the largest of which being cross-browser support. It does nothing to dilute the quality of the JavaScript-authoring experience. In fact I would argue that JavaScript libraries do much to give JavaScript a particular style and feel. Code written with Prototype feels very different from code written with jQuery – and this is fine since it’s giving the user the option to develop in the JavaScript language how they best see fit.

Charles Jolley of SproutCore came out with support:

I’ve written about this myself on the SproutCore blog before, but I think it bears repeating: The native programming language of the web browser is JavaScript. To write the best software possible, you need to embrace the native tools of the platform you are working on.

Michealangelo said that to him a sculpture already existed within a piece of marble. His job was to simply remove the parts that didn’t belong.

Like any creative endeavor, writing great software is as much about embracing the material you are working with as it is about building something new.

Everybody is writing “abstractions” around JavaScript

That came from Francisco of 280 North / Objective-J in On Leaky Abstractions and Objective-J.

This is a great, very thoughful post that argues that even Ajax libraries are JS abstractions too. He doesn’t just talk about it, he shows jQuery, Prototype, and Dojo code, as well as his own Objective-J to get his point across. He then goes on to talk about why they took the JavaScript++ approach (adding actual syntax), concluding with:

To me what we’ve done with Objective-J and Cappuccino seems inevitable. Even the most conservative major JavaScript libraries can’t get away without adding features to the language, and we’ve simply taken the next logical step with Objective-J. Similarly, Cappuccino is a tool that allows you to stop thinking about web pages and browser incompatibilities, and instead focus on the complex problems presented by the challenge of creating full-on applications on the web. As we’ve said countless times, Cappuccino isn’t for everything. All of this abstraction isn’t necessary if you’re simply trying to add dynamic elements to a site like bankofamerica or digg. Cappuccino is for building rich applications in the browser, a small minority in the web world today. We believe that this is where things are headed, and we designed Cappuccino specifically to get us there.

JavaScript is a malleable language. One that lends itself to the creation of DSLs. This is why Dojo code can look so different to jQuery code. The lack of a class system and an import system means that a lot of libraries reinvent the wheel, in their own way.

Abstractions are an interesting beast. Go with what feels right to you. I personally like the “create a DSL in the language itself and allow me to sneak out” style versus a new language, but that is just me.

Posted by Dion Almaer at 7:26 am
60 Comments

++++-
4 rating from 27 votes

60 Comments »

Comments feed TrackBack URI

@Thomas,
I think you may get some enlightenment from this presentation. It sums up decently well some reasons why there is a resistance to your line of thinking with a significant group of people:
.
http://docs.google.com/Presentation?id=dfxgjqrf_196fr6ct4f2
.
Not that I use Dojo or anything, but the Thin Server Architecture crowd I do subscribe to. Maybe you can see where a few of us are coming from.

Comment by TNO — December 11, 2008

@TNO: I would have to agree. I develop a suite of business apps (php). A common theme is that our performance bottlenecks are often related to server capacity or client-server network capacity. Latency especially can really obliterate a typical ajax app, due to the excessive roundtripping you get when ui state is spread across the client and server.
.
We’re moving to a thin server architecture out of necessity. We need to grow our app capability-wise, but we can’t get more server hardware to throw at the problem. Also, we need to give reasonable performance over high-latency connections, so an architecture that’s based on lots of rpc calls is out of the question. In practice, the only thing that works for me is to treat the server as evil, only to be contacted when it can no longer be avoided.

Comment by Joeri — December 11, 2008

@TNO
http://ra-ajax.org/killing-the-myths-of-managed-ajax-frameworks.blog
.
Here’s my answer to that presentation, taking one point at the time … ;)

Comment by ThomasHansen — December 12, 2008

@Thomas:
It would be nice if you allowed comments on your blog. Would it be to much trouble to allow it especially for this topic? (plus it would help steer me away from trying to follow the same discussion in 2 places)

Comment by TNO — December 12, 2008

@TNO
Perfect link. Encapsulates for me exactly why I wouldn’t ever use Ra-Ajax. Thanks

Comment by paulhan — December 12, 2008

@paulhan
I’m not really sure if you realize this, but I think I pretty effectively proved every single point in that presentation to be roughly 110% *wrong*…!
(That is in *my* link)
.
[flamebait]
But I guess I can’t get you all, the top 5% smartest among you is enough… ;)
[/flamebait]
.
Seriously, if you prefer PHP (yes, I followed your link) then why don’t you *say* so…
Ra-Ajax is (probably) only, at least *mostly* for people on .Net / Mono from *before*…
I’m to threat to YOU…!

Comment by ThomasHansen — December 12, 2008

@TNO
Yes, I think we will soon…
Lot’s of people have been asking for “commenting support”, in fact enough to make it worthwhile… ;)

Comment by ThomasHansen — December 12, 2008

@Thomas,
OK, so I’m going to bite again.
I notice you studiously avoided the issue I raised on John Resig’s blog and in your own denial of the link provided by TNO. That is, that people will not put up with a half second+ delay every time they click something.
And there’s more:
Where’s the documentation.
How do I integrate widgets that you haven’t provided, like a treetable, or a toolbar for instance
Can I be assured that if the four developers go on holiday, that someone will be there to answer my queries.
Can I be assured that if I ask what seems to be a dumb question to you. that I won’t be compared to Britney Spears,
And that is the real reason I’ve bitten, to register my disgust at your depiction of John Resig. People who do that to anyone are lower than a snake’s belly IMV.
You;ve flown in on a very interesting thread, well reasoned by everyone, made a lot of noise and shit all over the place like a seagull.
I’ve made my points. I will never again give you the oxygen of a reply.
Paul.

Comment by paulhan — December 13, 2008

@Thomas:
Due to the length of my response to your blog post, I’ll wait for you to open your comment system to reply.

Comment by TNO — December 13, 2008

@paulhan
What issues…?
Unless you “read something else then what I wrote”, I think I made it really fucking perfectly clear for you…
Documentation is there, it’s not even very well hidden, though if you’re so interested in PHP as you obviously are – why do you care…?
This is .Net or ASP.NET, which for you (probably) means that learning ASP.NET would be a gazillion times more important then reading the Ra-Ajax docs…?
.
Regarding “holidays”, what guarantees do you have in that John doesn’t figure out he’ll spend the “next year” in China or something studying Buddhism…?
.
About me calling you Britney Spears – unless you say something really stupid like “all Managed Ajax libraries sucks” like John did I think you should be relatively safe … ;)
.
Now whether or not I’m “lower then a snake’s belly” or not, that doesn’t really matter since people like me and the guys behind GWT etc will anyway prove to deliver libraries able to put the “DHTML guys” *out-of-business*…!
.
So in one year from now you’ll either be doing Windows or Apache sys-admin works unless you “bite” on the Managed Ajax parts. And in case you still haven’t understood why – the “Managed Ajax guys” can deliver a *gazillion* times the functionality in a *gazillion’th the time* the time frame…
.
You’re trying to make this about me, but really it’s about YOU…!
Either you “bite” or you’re *fucking-history*, there’s nothing *I* can do about that except trying to show you “the light”.
And if I was an asshole, I wouldn’t really care, right…?
Though my problem is that I *do* care…!
.
“Pearls for swines” is an old biblical saying, I am not really sure if it fits here, but it truly feels like it…
.
But keep to jQuery by all means, it probably is the “middle of the road” for at least a year or so more. Though *when* (1-2 years) you end up becoming the “sysadmin” of people doing *real* web applications development, then don’t blame me…
I tried…!!!

Comment by ThomasHansen — December 13, 2008

Leave a comment

You must be logged in to post a comment.