Site Archive (Complete)
Light Weight Languages
DECENT PROGRAMMING

Rails, Ajax, Python, Zope and more.

by Jeffrey Hicks

August 2006


August 25, 2006

Ruby and python list comprehension


If you've never heard about lambda ... move on, this article isn't for you.

On the other hand, if syntax comparison with examples of list comprehension in ruby and python sounds de.licio.us ... well you might want to check out Scattered Thoughts About Ruby vs. Python, Mostly Inconclusive.

Posted by Jeffrey Hicks at 12:23 AM  Permalink |


August 22, 2006

Beyond old school AJAX


In day-to-day AJAX programming I rarely see AJAX in its original "old school" incarnation. Strictly speaking, AJAX stands for Asynchronous Java and XML - but in today's practice the XML part is definitely getting more rare. In this article I describe a few AJAX patterns I've come across: Original AJAX, AJAX with JSON, AJAX with HTML, and AJAX with dynamic javascript.

Original AJAX

In the beginning, your web page would request additional data from the server and the server would respond with data encoded as XML. Your web page's javascript would then parse the xml and update the pages through the Document Object Model (DOM). Needless to say, this process was error prone and not light-weight. Parsing XML in your javascript isn't any fun, and explicitly manipulating the DOM keeps you in front of your javascript debugger longer than needed.

AJAX with JSON

In this method, the server returns JSON instead of XML. JSON is a much simpler data format than XML. Its easier to write and easier to read, but like Original AJAX you still have to update the DOM yourself. Individual programmer's solutions tend to be ad-hoc and consistency declines.

AJAX with HTML

In this method the server returns HTML instead of a data format such as XML or JSON. This method is easy enough for the novice programmer and is a worthy simplification. No more encoding and decoding data and performing ad-hoc operations on the DOM. With this method, the server generates the HTML with the data and the returned HTML replaces a portion of your page.

Server side generated HTML means that the dynamic action happens server side and your javascript remains blissfully simple - client side javascript only has to load in the HTML. But with simplification comes less power and flexibility. Your updates are limited to simple and one-at-a-time HTML substitutions. For example you wouldn't be able to update a shopping cart's price total in the upper-left corner and also add a line item in the main part of the page.

AJAX with dynamic javascript

This method is my personal favorite and makes more sense when you consider a hard-to-uncover limitation of "AJAX with HTML". Imagine you've been dynamically updating your page with "AJAX with HTML", and you decide to inject some HTML that also happens to contain some javascript. You're likely to get quite frustrated when you realize that your HTML was injected into the DOM, but the javascript inside your injected HTML was NOT executed by the browser. You've learned how much easier it is to generate the HTML server side, and now you want the javascript thats generated server side to also work.

Welcome to the "AJAX with dynamic javascript" solution. In this method you don't generate XML, JSON, or HTML server side. In this method you generate Javascript code. Again, no more encoding and decoding data - you simply use your server side scripting language to create dynamic javascript. This makes it easy to modify multiple elements on your page in one AJAX response. You have virtually the same freedom of Original AJAX but without its data encoding burden.

Learn some more

To learn more about the first three methods you can check out this: The AJAX response: XML, HTML, or JSON?. To learn more about the 4th method, you might consider diving deeper into Rails RJS templates - Rails RJS Templates

Posted by Jeffrey Hicks at 07:17 PM  Permalink |


August 02, 2006

Screencast worth watching


If you're involved with a Rails project, you owe it to yourself to watch this screencast. Relevance LLC understands dynamic scaffolding and they've got an open source framework built on Rails to prove it.

Posted by Jeffrey Hicks at 10:57 PM  Permalink |



What is web 2.0?


500 random people define Web 2.0

37 Signals has surveys where they ask their basecamp users to help guide product development, but recently they had a little fun to ask: What does web 2.0 mean to you?

They've posted 500 random answers.

Here are of the responses that kinda resemble my understanding of Web 2.0:

#164. An overhyped term that means some component of AJAX or social software

#89. easy sharing of data between web applications I think?

#421. Web apps that behave almost like desktop apps

One of the more controversial Web 2.0 definitions:

#121: It means rounded corners, gradients, DHH, 37s, beta, and no clear revenue plan


Posted by Jeffrey Hicks at 04:24 PM  Permalink |



October 2006
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        


 
INFO-LINK


Related Sites: DotNetJunkies, SD Expo, SqlJunkies