7/6/08

Javascript, AJAX and beyond.

Recently when I was discussing with a friend about my tag clouds, and he commented something along the lines of: "such a nice AJAX application". That triggered my necessity to post on that.

"Is not AJAX. Is just plain Javascript". He said: "but Prototype is an AJAX library".

This hype around AJAX is cool. Lots of nice web applications, improved usability, better user interfaces, etc. But, as with everything, people sometimes misunderstand the concepts and, for the fatal blow, use them wrong.

AJAX is more than an acronym

Ajax (and not AJAX) is not Asynchronous Javascript XML anymore. Why? Because you can make requests synchronously if you want. Because not only Javascript, but Java, ActionScript, VBscript, whatever that runs on the client side and know how to do it can make requests. And XML, heck, it isn't even human readable. Plain text, javascript, html and JSON, among others, are possible results.

Is hard to define what AJAX is. Our friend Wikipedia defines AJAX as a group of interrelated web development techniques used for creating interactive web applications. Certainly the definition comes short, and one can interpret it as most convenient.

AJAX is not javascript

My tag clouds are not AJAX. Most of javascript effects, widgets and toolkits are not AJAX, at least not depend fully on it. People tend to think drag & drop, modal windows, fading elements or loading bars are AJAX. They alone are not. But most of them use AJAX techniques to communicate in some manner to a server, so the line is blurry.

What has changed since the coming of AJAX as such is the way people use those chunks of javascripts. In my opinion, I think it's mainly because designers are not the only ones to develop web applications anymore. Now, in order to successfully develop a web site (of any kind), a minimum of programming background is required. Or good tools. Or even better: good employees.

AJAX is not forever

Wow, that one is hard. AJAX has many weak points that prevent web applications to achieve their fully potential. Web 2.0 starts sounding too old. RIAs are growing, and there are several applications out there to prove it. I don't think that web application will replace desktop applications, not fully. But I think offline web applications will eat a big piece of the cake. Sooner or later, but being able to have an application inside another one, whose main job is communicating, is something still being worked. AJAX, as other technologies, will rather evolve or die.

I am aware we belong to a rapid-evolving era not only for web application but for technology in general. AJAX is not the exception, and we as developers have to catch up quickly, have a clear understanding of the panorama and use tools accordingly.

6/25/08

Label cloud for blogger

I have nothing against Blogger's label widget, but I think label clouds are a better visualization for that matter. After searching around I came across phydeaux3 tag clouds. Based on that, I built my own widget for this blog. You can try it here. Type some words inside the box and click the 'create' button. You can also specify the colors you want for bigger and smaller words. Type them in hexadecimal format, without the # sign.


Big words color: #

Small words color: #


You can see the code on the source of this page (if you have javascript enabled, you'll see my label cloud on the sidebar. If not, you'll see the standard label widget). Or you can have the code here:

function cloudify(element_id, elements, options) {
  eReplace = $(element_id);
  var min_oc = null;
  var max_oc = null;
  var labels = elements;
  labels.each(function(e) {
    if(!max_oc || e[0] > max_oc){ max_oc = e[0] }
    if(!min_oc || e[0] < min_oc){ min_oc = e[0] }
  });
  if(min_oc == max_oc){ max_oc++ } // To prevent a divide by zero error
  var min_font_size = options['min_font_size'] || 10;
  var max_font_size = options['max_font_size'] || 30;
  var text = "";
  var log_min_oc = Math.log(min_oc);
  var log_max_oc = Math.log(max_oc);
  var log_diff = log_max_oc - log_min_oc;
  var start_color = stringToColorArray(options['start_color']||'B47B10');
  var end_color = stringToColorArray(options['end_color']||'006600');
  var link_start = "";
  var link_end = "";
  var link_href = function(e){return ""};
  if(options['includes_link']){
    link_start = "><a ";
    link_end = "</a>";
    link_href = function(e){return 'href="' + e[2] + '"'};
  }
  labels.each(function(label) {
    var w = (Math.log(label[0]) - log_min_oc) /(log_max_oc - log_min_oc);
    text = text + '<span' + link_start + ' style="font-size:' +
      String(min_font_size + Math.round((max_font_size - min_font_size) * w)) +
      'px; color:#' + 
      colorArrayToString([0, 1, 2].map(function(i){
        return start_color[i] + Math.round((end_color[i] - start_color[i]) * w);
      })) +
      '" ' + link_href(label) + '>' +
      label[1] + link_end + "</span> ";
  });
  eReplace.update(text);
}
Where elements is an array with element of the form [count, label] and a third element: the link of each label if specified in the options.

Anyway, is a very quick-and-dirty version, if you are interested on it and have troubles, drop a comment.

6/23/08

Google Developer's Day Mexico 2008

Today I attended at Google Developer's Day Mexico 08. To my understanding, it is the first time such event is done here in Mexico, and Google people did a nice work.

The first couple of hours John Farrell (Google Mexico's director) and Alfonso Luna (Marketing director for Latin America) besides giving us an overview of the event they clearly stated the intentions not only for the workshop, but for the Google developers in general.

It is well known that times are changing and the Internet is positioning as one of the most ubiquitous, important mass medium, yet the communication, use and business paradigm is totally different to 'traditional' media such as radio or TV. Internet, unlike the others, is a dynamic medium, in which the most important thing is not the hardware or the infrastructure per se, but the content. Concepts like shared market and 'the long tail' are playing an important role in their business paradigm.

John described us Google as an ecosystem, in which sponsors, partners, content providers, developers and users interact in complex manners. Google's mission may be ambitious, but the truth is that its worldwide presence is something we should be aware of. And we, as developers, are part of this game. So Google has been developing a set of Open Source tools and engines to help developers, in such way we can develop quick, good and cheap. Is a win-win deal.

The rest of the day we were offered a set of conferences and workshop specific to the Google technologies, split by interests (it would be impossible to cover all of them in just one day). The complete agenda can be checked here (I couldn't find an English translation, bear me). Google gears, Google Web Toolkit, OpenSocial, Android, Google App Engine and KML were just some of the topics covered on the workshops, I will be posting about them and my experiences on later posts.

It was an overall nice event, I hope Google to put its eyes on Mexico since I am sure there are lots of good developers that can be a force to be reckoned with.

6/21/08

RubyWeekend game contest - Yarr Blaargh!

Pirates vs. Zombies. That's the main theme of my game, and also the theme of the first RubyWeekend game contest.

It was an interesting contest in which there was only a slightly more than 48 hours to make a themed game. The platform and implementation was free, just it had to be written in Ruby. Among the options available (this presentation contains lots of options for making a game in Ruby) I picked Rubygame.

I have used Gosu before, which is a nice platform. But I wanted to give a try to Rubygame. Both libraries are very similar, maybe Gosu wraps in a little higher level events and sprite manipulation, but Rubygame is very flexible and efficient.

The game is called Yarr Blaargh. After all, what else would you expect to hear in a pirates vs. zombies battle? You can check the code here, altough in 48 hours I had not enough time to finish it, so you will see an incomplete project by now. Perhaps in the next weeks I can polish the details of the game.

6/19/08

Two of sugar, please!

They say coffee and Red Bull. Occasionally vodka.

Oh, yes, but sometimes they forget to make their beds! Not that they are using them very often, programming 'till 4:00 a.m. is funny. They forget to eat and to sleep. And they forget to put sugar on their coffees.

Programmers are not (always) a console terminal. Real world is more than lines of code.

They are programmers. We are programmers. Nerds, and dreamers.