Sunday, October 26, 2014

I so wish I could play Sim City 2000 on any of my devices.

Wednesday, October 22, 2014

Andy Wingo, maybe the smartest person I know and probably the only person on the planet with major contributions to...

Andy Wingo, maybe the smartest person I know and probably the only person on the planet with major contributions to all open source JS VMs, tries to set up SSL TLS. Hilarity Sadness ensues.
http://wingolog.org/archives/2014/10/17/ffs-ssl

Tuesday, October 21, 2014

Tuesday, October 14, 2014

Of all talks I've ever seen, this one from Mathias Bynens had the highest rate of "Oh shit, I've written code with...

Of all talks I've ever seen, this one from Mathias Bynens had the highest rate of "Oh shit, I've written code with that bug in it. … Multiple times. Oh, and also that bug. That was like last week."
Mathias Bynens: JavaScript ♥ Unicode
https://www.youtube.com/watch?v=zi0w7J7MCrk

Monday, October 13, 2014

Inspired by a tweet by Kelly Ellis I made this image.


Inspired by a tweet by Kelly Ellis I made this image.

Wednesday, October 8, 2014

Sunday, October 5, 2014

OK, this is awesome. I want Internet Explorer 5.5 on my smart watch!

OK, this is awesome. I want Internet Explorer 5.5 on my smart watch!
http://youtu.be/GZx-LJH5J_I

Thursday, October 2, 2014

Scaling usage requestAnimationFrame and a solution for avoiding style recalculation more than once per frame.

Scaling usage requestAnimationFrame and a solution for avoiding style recalculation more than once per frame.

Recently some code that I wrote for Google internally was open sourced as part of the Closure library: "goog.dom.animationFrame"
https://github.com/google/closure-library/blob/master/closure/goog/dom/animationframe/animationframe.js

The library is quite interesting as it solves a big issue when working with browser animations in larger teams:

2 or more tasks want to do work in the same animation frame.

Say task 1 is animating your navigation while task 2 is animating some parts of the content.

In the worst case now the DOM operations look like this:

Animation frame:
Task 1 measures position of object A.
 - Triggers style recalculation
Task 2 changes position of object A.
 - Invalidates previous style calculation.
Task 1 measure position of object B.
 - Triggers another style recalculation
Task 2 changes position of object B.

The new library solves this with the following API:

var animationTask = goog.dom.animationFrame.createTask({
  measure: function(state) {
    state.width = goog.style.getSize(elem).width;
  },
  mutate: function(state) {
    goog.style.setWidth(elem, Math.floor(state.width / 2));
    animationTask();
  }
});

When code wants to schedule an animation frame, they have to supply two functions: One to measure the DOM and one to mutate it.

Because of this separation the library can serialize all the measure and mutate operations to happen in 2 phases: First all the measurements and then all the mutations.

Thus the operations against the DOM per animation frame now look like this:

Animation frame:
Task 1 measures position of object A.
 - Triggers style recalculation
Task 1 measure position of object B.
Task 2 changes position of object A.
Task 2 changes position of object B.

Note, how one style recalculation disappeared – and as more tasks are added this scales further without introducing any additional recalculations.

Besides this major feature, the library also solves the following problems:
- designed to minimize per frame memory allocation.
- designed to avoid accidental scheduling of the same work more then once per animation frame.

If this sounds useful, go ahead wrap the code in some module system of your choice and make your app a little silkier.
https://github.com/google/closure-library/blob/master/closure/goog/dom/animationframe/animationframe.js

Wednesday, October 1, 2014

Today marks 4 years of working at Google, which is 20% of another anniversary: 20 years of somebody being nice...


Today marks 4 years of working at Google, which is 20% of another anniversary: 20 years of somebody being nice enough to give me money for programming.
It all started in 1994 at a company called Integrated CASE and Concepts that hired me as an after-school-job to copy their manuals and floppy disks and then needed a website – with all their highly skilled Smalltalk engineers having no idea how this crazy new HTML thing worked. 

CASE, or Computer Aided Software Engineering, for you kids out there, was the dream of the 90s that if you would just punch at the problem long enough, some diagram drawing thing would bring the same productivity gains to software engineering that CAD brought to drawing complicated 3D models by hand. And here I am still typing this into a text editor.

It was great to learn Smalltalk (the programming language, the social skills came later or never) from some of the original OO people. I then proceeded to forget everything they taught me at least 3 times (after sufficient exposure to Perl, University and JavaScript) but enlightenment always slowly came back to me. Definitely being reminded of the VisualWorks debugger is the #1 trigger that brings out the grumpy-old-man in me.

Here is to another 20 years and the hope that we'll have time traveling debuggers[1] in 2024.

[1] Doesn't require major advances in physics although those would also help.