Tuesday, June 8, 2010

Protest Against the Dollar Sign

JSP: intermixing java and HTML is a decade+ old idea that makes perfect sense to me. But the problem is this: it doesn't look like everybody's favorite XML. JSTL wants you to use tags instead and argue it is better. See here here for details.

Besides tags, note the use of dollar sign and braces to evaluate an expressions.

Somebody just have to put tags around as if the world doesn't need more syntax.

Ok, it is better of preference, nobody forcing me to use JSTL yet.

Let's go over to the client side. If you have to pick the most popular javascript library... it's got to be jQuery. Don't let the name fool you. It has nothing to do with database queries.

JQuery makes heavy use of $ and it is not quite the same expression evaluation in JSTL. See here, for instance, for an introduction tutorial. Gee, I have not seen so many $ in javascript... just what is it?

Ah, it is merely a SHORTCUT to the variable jQuery! The dollar sign is the shortest variable that is not alphanumeric, and jQuery decides to use it as the shortcut of spelling out the name of itself. Gee, I wish the dollar sign isn't a legal character to begin a variable.

JQuery loves to do this: play with DOM and attach all events and call anonymous functions. So WYSI_NOT_WYG. See a little dropdown select tag or a simple anchor tag that looks perfectly innocent? Gee, somebody may have modified the onclick method or something.

If you LET somebody do something, they will do it all over the place.

Anonymous function (buzzword lambda) is not my cup of tea. I like explicit functions with names.

I protest against the dollar sign shorthand in jQuery.
I protest against inserting extra events to objects on the fly, especially with anonymous functions.
I protest against JSTL.

No comments: