Currently coding the site

I am a workaholic web technologist working in the Silicon Valley and living in San Francisco doing what I like to do best by creating new ways to access, visualize and organize information.
More...

Notes

Understand them as Lorem Ipsum

Rendering Polygons with Canvas

Jun 22, 2008

This time I wanted to test the performance of the canvas rendering versus other technologies. Since Google Maps uses VML, SVG and image retrieval depending on which browser you are using, I compared the rendering times of the maps polygons to see the results.

In the end it wasn't the best environment to do the tests since it was impossible for me to split the actual rendering time of the polygons and the rest of the processes of the map code. In any case, I leave the experiment for you to see.

Canvas

May 31, 2008

I am releasing an experiment I made last October when I started playing with the canvas element.

One of the main reasons I started to play with this technology was that while I was trying to port a previous SVG experiment, I noticed it had quite a few cross browser issues. The final result with canvas was quite satisfactory and it gave me the chance to learn features beyond the basics such as drag and drop, event handlers and performance optimization.

Since that experiment in October my interests and prototypes in Canvas have been more and more challenging: Skewing techniques, VR emulation, polygon rendering, etc. There's a bunch of code to release though I am not allowed to release all of it right now. But I will do my best.

Update: Due to the interest and enhancement requests from friends and colleagues, I have created a project page where you can contribute and add items to the to do list.

Update 2: Check the Flickr and Picasa integration from Michael Johnston and Pamela Fox respectively.

JS Interpreter and Execution

Apr 29, 2008

Here is a quick (and tricky) mini challenge for those who usually work with javascript. Take a couple of minutes to think about the results of the alerts in each snippet.


// Snippet 1
x = 4;
function init() {
 alert(x);
 var x = x;
 alert(x);
}
init();
	

// Snippet 2
x = 4;
function init() {
 alert(x);
 // var x = x;
 alert(x);
}
init();
	
See the answer
Answer below
.
.
.

The explanation of the behavior of the snippet 1 (undefined, undefined) is that the line var x = x; is doing a declaration var x; and an initialization x = x; at the same time. But each of these processes happen separately, one after the other, when the javascript code is interpreted and then executed.

First, when the code is interpreted, before any code is executed, the var x; declaration makes the variable x available within the scope of the entire function, no matter what line it is written on. It would have the same effect whether var x; was written at the very end of the function or at the very beginning. However, the variable won't be initialized, i.e., assigned to any value, until the code is executed. Until then, its default value will be undefined.

Second, when the code is executed, any x inside that function will refer to the declared local x instead of the global x as one may think at first sight. Therefore, the x = x; initialization won't throw any run time error because the variable x exists but it has never been assigned to any value other than the default undefined.

Walking the DOM

Mar 11, 2008

As an experiment I had the idea of implementing the iterative version of the walk the DOM recursive function (which uses firstChild and nextSibling DOM methods to walk the DOM tree as a binary tree). One of the conditions was I didn't want to use a stack in the iterative implementation. At some point, I had the hope that it could be faster than the recursive one due to the absence of the function-call overhead but that didn't happen.

With that said I will leave the code here for anyone who wants to spend more time playing with it or provide some feedback.

Source code

World Map Projections

Jan 21, 2008

As a big fan of world maps and also because I have been for a while programing some things on it, I am going to show my favorite world map projections:

1 - Goode homolosine

This projection belongs to the equal-area projection category, which means it tries to represent countries in their correct proportional size. I think the first well known app using it was 43places.com.

For a long time, this map made in flash was the main map of the 43places application so the users were able to select countries and see which ones were visited, 'want to visit', etc. From my point of view this map was the best choice. However, they later switched to google maps maybe because of the specificity of the markers. Although you still can access the flash version from its users' profile.

2 - Robinson

This one belongs (among other categories) to the compromised projection ones. Its goal is to find a balance between different kinds of distortions.

That representation can be seen everywhere in the Wikipedia.

3 - Peters

Probably the most popular of the Cyllindrical Equal-Area. However, similar projections like Behrmann or Hobo-Dyer make the countries look less strange. They all differ in the ratio of the vertical to horizontal axis, especially close to the pole areas

I haven't found any web app using them though.

4 - Mercator

Also called 'evil mercator' since it's the worst one in terms of distortion of the countries. Greenland is 554% bigger than its real size, Canada 258%, USA 68%, etc.

It's still commonly used in a lot of places. For instance, google maps uses it. Although my guess is that 95% of the use of google maps is not at the world view zoom level.

Acknowledgments

Dec 23, 2007

I have never been in the acknowledgments of a book before.

Ross Harmes from Yahoo! and Dustin Diaz from Google decided about a year ago to write a book about Javascript Design Patterns. As I have the honor of being on the team of the former, I was pleased to offer my feedback on his excellent lessons. Although one wonders who needs technical feedback when the beast Simon Willison is already doing that.

Javascript, being the first mainstream lambda language, has its very own features. It well deserves a good training not only to write better code but to use all the potential of the language. This book will really help you in both aspects and it will make your path easier to the mastery of the language.

If I feel happy to be mentioned in the book, I can't imagine how proud Ross and Dustin must feel to be the authors after months of work. In fact, it's a feeling that is worth a try.

Congratulations guys!


View all notes...

Articles

It doesn't hurt

Image Transformations in Canvas with Slicing (by Ross Harmes and Ernest Delgado)

Jun 23, 2008

Published on the Yahoo! User Interface Blog

User registration patterns (URP)

Nov 24, 2007

In this article we will try to prove that some practices in current web apps have important privacy and security issues both for the user and for the application.

Read more...