12 November 2009 9:05a Pacific

Google Closure based on naive server-side notions?

by Matt Sherman

I rely on libraries (mostly jQuery) instead of writing a lot of serious JavaScript these days. I mean, of course I am writing JavaScript but the libraries allow me to stay in “script space” – small procedure bits that are scripts as opposed to applications.

But I do like to keep an eye on best practices, and this article offers some great tips from an experienced JS library developer.

He offers them in the context of ripping Google’s new Closure library – he says it’s evident that it was done by Java people without much real-world JavaScript experience. In other words, Closure appears to be based on the naive assumptions of a server developer.

This is understandable if it’s true that these are Java developers behind Closure. Java is a compiled and garbage-collected language. Poor coding patterns may be optimized away at compile-time. The behavior of Java’s garbage collector is known science, so if you manage scope well, you should have no trouble.

And, in Java or any other compiled (static) language, others can’t swoop in and change your code at runtime.

JavaScript, however, can’t rely on any of these assumptions. Your users will be on a variety of browsers, with widely varying JS performance. Sloppy code may or may not get optimized. Who knows how good the memory management is. And other libraries can change your code, intentionally or otherwise.

It’s the difference between knowns and unknowns. On the server (Java), you have 100% control of the environment. On the client (JavaScript), you have almost none. These are very different ways of thinking.

Comments are closed

Tell others

TwitterTweet this page
Digg!Digg this page
TwitterAdd to Google Reader

Experimental! Let me know how it works for you.

Shorten this page's URL

Learn more about the TinyASP URL shortener

ASP.Net jQuery Controls

Implement jQuery effects using familiar ASP.Net server controls. Learn more...

Recent posts

Avoiding “magic strings” in jQuery, C# and ASP.net MVC

Alikewise learnings #1: DIY PR

Sherman’s law of prior knowledge, or, predicting the past

The busiest people at Apple right now…

When “infographics” jump the shark

HTTPS is the least of your problems

Stacking up

Beware the truth-tellers

more...  

About us

ClipperHouse.com is brought to you by Matt Sherman and Fernando Chilvarguer, among others. Contact us here.