Comments on: Monkeying With JavaScript http://girtby.net/archives/2009/01/07/monkeying-with-javascript/ this blog is girtby.net Wed, 30 Sep 2009 01:44:34 -0400 http://wordpress.org/?v=2.9-rare hourly 1 By: Andrew http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2332 Andrew Fri, 30 Jan 2009 01:36:14 +0000 http://girtby.net/?p=3674#comment-2332 <blockquote> <blockquote> <p>I completely understand the first row without being very knowledgeable in JavaScript.</p> </blockquote> <p>Because obviously the most important criterion for how to write a piece of code is whether it can be read by people who don’t know the library or the language. Or programming.</p> </blockquote> <p>That depends on whether you are maintaining a site as a full time professional job, or (for example) running your own small blog and tweaking it every few months. Readability can in any case be <a href="http://en.wikipedia.org/wiki/Literate_programming" rel="nofollow">considered an extremely important aspect</a> of a language.</p> <p>... and only a programmer would expect that "jQuery(document).ready(function() { ... });" was readable by a non-programmer.</p>

I completely understand the first row without being very knowledgeable in JavaScript.

Because obviously the most important criterion for how to write a piece of code is whether it can be read by people who don’t know the library or the language. Or programming.

That depends on whether you are maintaining a site as a full time professional job, or (for example) running your own small blog and tweaking it every few months. Readability can in any case be considered an extremely important aspect of a language.

… and only a programmer would expect that “jQuery(document).ready(function() { … });” was readable by a non-programmer.

]]>
By: Aristotle Pagaltzis http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2328 Aristotle Pagaltzis Thu, 29 Jan 2009 12:19:45 +0000 http://girtby.net/?p=3674#comment-2328 <blockquote> <p>I completely understand the first row without being very knowledgeable in JavaScript.</p> </blockquote> <p>Because obviously the most important criterion for how to write a piece of code is whether it can be read by people who don’t know the library or the language. Or programming.</p>

I completely understand the first row without being very knowledgeable in JavaScript.

Because obviously the most important criterion for how to write a piece of code is whether it can be read by people who don’t know the library or the language. Or programming.

]]>
By: Adam http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2327 Adam Thu, 29 Jan 2009 07:49:44 +0000 http://girtby.net/?p=3674#comment-2327 <p>First, I think</p> <p><code>jQuery(document).ready(function() { ... });</code></p> <p>is much more readable than</p> <p><code>$(function() { ... });</code></p> <p>I completely understand the first row without being very knowledgeable in JavaScript. <em>"When the document is ready, run the following function."</em> But the second row, I have no idea. Even knowing that <code>$</code> accesses an element in the page doesn't help much.</p> <p>Second, I think the comment dates are confusing. It is much easier to parse them relative to now. That is, I know that the post is for example 3 weeks old and Brendan's comment is 1 week old. It is not hard to figure out when he posted it relative to the original post. Now I need to take the time of the original post + the time of the comment to figure out when it was posted. It's just not the time conversions you're used to make.</p> First, I think

jQuery(document).ready(function() { ... });

is much more readable than

$(function() { ... });

I completely understand the first row without being very knowledgeable in JavaScript. “When the document is ready, run the following function.” But the second row, I have no idea. Even knowing that $ accesses an element in the page doesn’t help much.

Second, I think the comment dates are confusing. It is much easier to parse them relative to now. That is, I know that the post is for example 3 weeks old and Brendan’s comment is 1 week old. It is not hard to figure out when he posted it relative to the original post. Now I need to take the time of the original post + the time of the comment to figure out when it was posted. It’s just not the time conversions you’re used to make.

]]>
By: Brendan http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2269 Brendan Wed, 21 Jan 2009 02:12:58 +0000 http://girtby.net/?p=3674#comment-2269 <p>Maybe it's just me, but I don't like the relative dating schemes that you call "more human-friendly." I find it easier to see the absolute date and time and do any desired conversions to relative ("Ah, he posted this yesterday") than I do going the other way. And then there's the annoyance of searching for and not finding a string that I expect to be there; e.g., 20 January 2009.</p> <p>Which is not to say anything against this post, your interest in solving this problem, or your own <strike>poor</strike> taste.</p> Maybe it’s just me, but I don’t like the relative dating schemes that you call “more human-friendly.” I find it easier to see the absolute date and time and do any desired conversions to relative (“Ah, he posted this yesterday”) than I do going the other way. And then there’s the annoyance of searching for and not finding a string that I expect to be there; e.g., 20 January 2009.

Which is not to say anything against this post, your interest in solving this problem, or your own poor taste.

]]>
By: alastair http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2239 alastair Wed, 14 Jan 2009 22:50:27 +0000 http://girtby.net/?p=3674#comment-2239 <p>On a related note, I've just installed the excellent <a href="http://blog.clearskys.net/2008/05/28/google-ajax-libraries-api-plugin/" rel="nofollow">Google Ajax Libraries API plugin</a> for wordpress. The idea is that standard libraries like jQuery are served directly out of Google's servers. Which is great because it reduces the load on your site, but also is a lot more likely to be cached and hence loads more quickly into the browser.</p> <p>Leveraged synergy AND open kimono!</p> On a related note, I’ve just installed the excellent Google Ajax Libraries API plugin for wordpress. The idea is that standard libraries like jQuery are served directly out of Google’s servers. Which is great because it reduces the load on your site, but also is a lot more likely to be cached and hence loads more quickly into the browser.

Leveraged synergy AND open kimono!

]]>
By: Chris Heald http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2182 Chris Heald Thu, 08 Jan 2009 08:00:54 +0000 http://girtby.net/?p=3674#comment-2182 <p>For what it's worth, jQuery is specifically written to play nicely with other libraries; there is doc on the jQuery site about how to make it do so. It's very clean, since jQuery is entirely written in closures, and doesn't clutter up your global namespace.</p> For what it’s worth, jQuery is specifically written to play nicely with other libraries; there is doc on the jQuery site about how to make it do so. It’s very clean, since jQuery is entirely written in closures, and doesn’t clutter up your global namespace.

]]>
By: alastair http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2175 alastair Thu, 08 Jan 2009 00:04:42 +0000 http://girtby.net/?p=3674#comment-2175 <p>@Rob: I deliberately wanted to avoid all the craziness with the <code>$</code> symbol. Like I said though I don't know much about JavaScript...</p> <p>@marxy: Sorry I should have explained. Yes the reason for using JavaScript is to avoid re-rendering the page on the server side every time it is loaded. This also means that (in theory anyway) it can be cached. Mephisto used to do this nicely, but unfortunately Wordpress does not do this by default (but there is a plugin).</p> <p>And not that I'll be doing this, but JavaScript enables the possibility of dynamically update the page if you leave it open for hours/days at a time (again without re-rendering on the server).</p> @Rob: I deliberately wanted to avoid all the craziness with the $ symbol. Like I said though I don’t know much about JavaScript…

@marxy: Sorry I should have explained. Yes the reason for using JavaScript is to avoid re-rendering the page on the server side every time it is loaded. This also means that (in theory anyway) it can be cached. Mephisto used to do this nicely, but unfortunately Wordpress does not do this by default (but there is a plugin).

And not that I’ll be doing this, but JavaScript enables the possibility of dynamically update the page if you leave it open for hours/days at a time (again without re-rendering on the server).

]]>
By: marxy http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2172 marxy Wed, 07 Jan 2009 19:27:29 +0000 http://girtby.net/?p=3674#comment-2172 <p>Woops, I completely missed the point I was trying to make. Why do you want to humanise dates in Javascript? Is it for localisation or something? </p> Woops, I completely missed the point I was trying to make. Why do you want to humanise dates in Javascript? Is it for localisation or something?

]]>
By: marxy http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2170 marxy Wed, 07 Jan 2009 19:07:12 +0000 http://girtby.net/?p=3674#comment-2170 <p>Django has some lovely filters for doing this in the <a href="http://docs.djangoproject.com/en/dev/ref/contrib/humanize/" rel="nofollow">humanize</a> template filters.</p> Django has some lovely filters for doing this in the humanize template filters.

]]>
By: Rob Britton http://girtby.net/archives/2009/01/07/monkeying-with-javascript/comment-page-1/#comment-2168 Rob Britton Wed, 07 Jan 2009 13:43:08 +0000 http://girtby.net/?p=3674#comment-2168 <p>Three cheers for jQuery ;)</p> <p>You can go:</p> <p><code>$(function() { ... });</code></p> <p>instead of:</p> <p><code>jQuery(document).ready(function() { ... });</code></p> <p>Just looks nicer is all.</p> Three cheers for jQuery ;)

You can go:

$(function() { ... });

instead of:

jQuery(document).ready(function() { ... });

Just looks nicer is all.

]]>