Thursday, July 26, 2012

More Google I/O take away

Some years ago, a well-known CEO stood on a stage and screamed that his company and the future was all about "Developers! Developers! Developers!" Since then, the sheer diversity of platforms has exploded, the web continues to advance in content and functionality, and the world supply of developers has grown with mixed result.

As a developer who takes pride in building advanced web applications, I have seen on more than one occasion the negative side of the focus on and proliferation of so-called "developers": trash code that is more often than not brittle, insecure, and clunky. To the average end user, this means that, despite all of the advances in processor, RAM, HDD/SSD, and network technologies, they continue to wait on the applications that they use on a daily basis.

Enter Google I/O. This year, perhaps more than ever, the recurring and overarching theme of the conference was performance. From Project Butter in Android 4.1 to a heavy emphasis on debugging and performance analysis in the WebKit Developer Tools, speed was the talk of the conference. And rightfully so.

Some of the tricks that I picked up at I/O for improving performance in my web apps are briefly described below. I would love to hear what you use to trick the most speed from your apps and/or your experience with one or more of these tools.

Closure

The compiler. Not necessarily the library. Closure, when advanced optimizations are enabled, is a powerful tool for automagically reducing the size of your JavaScript and optimizing those sections of your code that could run faster. I've been using Closure Compiler for more than a year now, and it's simply awesome.

WebKit Developer Tools

With outstanding debugging and in-browser CSS, Javascript, and HTML editing, WebKit's Developer Tools were already pretty awesome. But Google and the WebKit team have continued to push in this area over the last year to make it even more impressive. When it comes to performance, the Timeline feature alone is worth its weight in gold. (Okay, so it doesn't "weigh" that much, technically. But it is still awesome!) Essentially, this feature helps you find exactly what, when, and where, your application is running into a bottleneck. And it helps you make sure that your users will never see the "jank" that so often characterizes web applications.

Accessibility

Okay, so this doesn't really have to do with performance. But if someone can't use your application because they are visually or otherwise impaired, performance is a moot point anyway. Fortunately, the Chrome team has been working on a number of tools for helping developers improve the accessibility of their websites and applications. Tools such as High Contrast, ChromeVOX, and Accessibility Developer Tools go a long way toward making accessibility accessible for developers.

Server-side performance optimization

Too often, particularly with web applications, the real bottleneck is not on the browser. It's not even in the network. It's where the application relies on the server to do something. Make sure that your server-side stuff is optimized. Simple things such as setting expires headers, enabling gzip compression, etc., go a long, long way.

CSS optimization

Some CSS rules bring the browser to a crawl while others can achieve virtually the same effect and still scream. Particularly with CSS3 transform3d and more, you can offload a pile of stuff to the GPU and radically improve performance.

Smart JS

The V8 JavaScript engine is pretty smart. And the other JS engines out there (e.g., Safari, Mozilla) are not far behind. But understanding just how smart they are - and how that smart works - is essential. One very quick example is in the case of prototyped objects. If objects use the same prototype, they will be given the same hidden class in the JS engine. This means that they will share a bunch of optimized code behind the scenes, thus speeding up everything they do. But the instant that you add one custom property to one of those objects, you break it out of that shared, optimized code. Surely, you could hear the screeching sound of your application grinding to an abrupt halt. Do everything in your power to avoid giving objects which are otherwise identical to a thousand others on the page some custom property.

Jelly Bean

Android 4.1 (aka, Jelly Bean) includes a plethora of tweaks to the ICS UI and UX which basically make life faster, smoother, and better. And while this probably isn't a developer tip, I am going to throw it out there. You want Jelly Bean. Not tomorrow. Or next week. But now. And sadly - or maddeningly, I think, from Google's perspective - OEMs and carriers are going to drag their feet in deploying it, and when they finally do push it out the door, they'll figure out how to bog it down with some hack-job custom UI and a pile of bloatware. Demand a vanilla Jelly Bean device from your carrier sooner, rather than later. Tell them that you would even pay extra for the thing so they didn't cripple it with bloatware and custom (read that, junk) UIs.

So there you have it. Just a few of the more technical takeaways that I brought home from Google I/O. Of course, this is a very quick hit list. And in order to actually utilize these tips, you'll have to do more research on your own. I would suggest that you start by going to YouTube and searching for related sessions from I/O 2012.

Monday, July 9, 2012

To I/O and beyond...

In the movie Toy Story, Buzz Lightyear has a particular tagline: "To infinity and beyond!" It embodies the space ranger's sense of adventure and courage, and challenges the hearer's imagination to suspend reality and, for at least a moment, embrace the limitless possibilities of life and the future. In more ways than one, Google's annual developers conference, I/O 2012, was an exercise in exactly the same.

June 27-30, I was privileged to be one of the approximately 6,000 people to attend Google I/O 2012. This was my fourth I/O - I've been to all of them but the inaugural event in 2008 - but in many ways, this one was dramatically different than all the rest.

For starters, it was bigger. Of course, there were more people. And the conference was a day longer. But what I really mean is that Google pulled out all the stops to make this I/O a phenomenon. During the Day 1 Keynote, for example, they demonstrated Project Glass in spectacular fashion with a live parachute drop, stunt bikes, and rappelling. Then, at its conclusion, the Android team announced the single largest giveaway in I/O history (which is, for the record, saying something). Add to this a second giveaway during the Day 2 Keynote and more sessions than ever before (they did add a day, after all!), and you have the makings of something huge!

But I/O was also about a message. Going into the conference, I was hearing a lot of rumblings about how people were confused about Google's direction of late. We all knew that the company is committed to Android and the open web, but with rumors swirling of Facebook and numerous others poaching Googlers, the plethora of disparate projects that Google has been supporting for years, their rather questionable progress in the social arena (read that, Google+), the firestorm still raging about their commitment (or lack thereof) to privacy, and more, there were serious questions in the air. Throughout the conference, I truly believe that one of Google's primary purposes was to communicate that the company, its products, and (perhaps most importantly) its culture are alive and well.

So, what did I take away from I/O 2012? I think there were three things.

First, I learned a lot, particularly about performance. There was a pile of sessions dealing with Javascript performance, developer tools, and basic (and not-so-basic) tips for tricking the most speed possible from a website in general or a particular web application.

Second, Google is frustrated with the state of Android. Namely, they are frustrated that they continue to pour time, energy, and resources into developing an excellent mobile platform while OEMs and carriers squander it all with second-rate hardware, sad skins and bloatware, and an utter lack of commitment to upgrades. I can come up with no other explanation as to why they would hand out a Galaxy Nexus phone - the only phone to run a vanilla Android build and get OTA updates directly from Google - and enter the tablet market themselves with the Nexus 7. In particular, I think the Nexus 7 is a shot across the bow of Amazon (because the Kindle Fire, best-selling Android tablet by far, is still running Android 2.3) and Samsung (whose flagship Galaxy Tab 10.1 - i.e., the tablet Google handed out last year - is plagued with quality issues and still running Honeycomb rather than Ice Cream Sandwich). I think Google is recognizing that the fragmentation of the Android ecosystem will eventually - probably sooner than later - make the entire platform untenable, or at least undesirable. And they're hoping that, by spurring developers and the world with a taste of Jelly Bean goodness on good hardware will prompt their partners to get their heads in the game and their acts together.

And the third thing I took from I/O is that Google isn't quite sure about how to find the balance between pleasing shareholders and maintaining the creativity and culture that has made it Google since day one. So on the one hand, we have Google doubling-down on Google+ (which investors rightly believe is key to the search giant remaining viable and growing in the advertising space) and monetizing APIs and services such as the Custom Search and Translate APIs (which investors are understandably loathe to simply give away to anyone and everyone). And on the other hand, we have a company which produces products as blatantly whimsical as the Nexus Q and as boldly next-generation as Project Glass (which, to be honest, I think should be called VISOR in honor of the device worn by Geordi LaForge of Star Trek: The Next Generation). They continue such endeavors as GoogleTV while simultaneously introducing the Nexus Q, which essentially reproduces a significant chunk of GoogleTV's features. To be honest, it seems as though they're on a seesaw, using a scattergun, blindfolded, trying to hit a moving target.

Given these take-aways, what am I looking for down the road?

Well, on the web side of things, I anticipate that Google will continue to use Chrome to push the state-of-the-browser and advance the open web. The company is fully invested in HTML5 and actively working to push it even farther. I also see that performance is going to become even more critical because it affects not only user experience but also the bottom line. I see that mobile is going to continue to grow, and with it, there will be an ever-widening range of form factors (read that, display sizes) to consider when building a website or app. And I see that Google will continue to push so that, even given the wide range of form factors, there will be an unprecedented continuity of capability and user experience across all of these devices.

On the Android side of things, while the pair of Nexus devices in the giveaway on Day 1 was not exactly the opening salvo in a war on OEMs and carriers, it was certainly another warning shot. Google is growing impatient - and it's about time! - with the hardware manufacturers and carriers who are perpetually gimping what has become a mature and powerful smartphone platform. These partners need to look at the iOS ecosystem and realize that fragmentation is a bad thing (iPhone 3 can still run the latest iOS software with only a few caveats!) and their crumby customizations are hurting everyone in the realm. Build hardware that's not crippled. Don't shoot the OS in the foot on the way out the door. If you're going to build Android products, build Android products!

And on the corporate side of things, I hope we'll see Google figure out who they are and where they're going, and then be that company and go that way. Get over trying to impress the shareholders. If they're not impressed with your results to date, then they're probably insatiable. You're making money. Lots of money. Now, get back to making the world - particularly, the internet - a better place.