Skip to main content


Showing posts from 2012

New Dart Web UI Codelab

Originally posted on Dart News & Updates : If you've been waiting for the right time to learn how to use Web Components in Dart, now's your chance! Continuing where we left off with the Google IO 2012 Dart Codelab , I've created a Dart Web UI Codelab which focuses on Web Components and the new Web UI library. In this codelab, I cover: How to set up pub How to use Web Components How to use dynamic templates and two-way data binding (inspired by Model-driven Views) How to build an application with multiple Web Components Where to get more information about Web Components and the Dart Web UI package What to do if you get stuck while trying to build an app using the Dart Web UI package We've already created videos , blog posts , and articles about how to use Web Components in Dart, but this codelab is pretty exciting in that it walks you through building a complete, albeit small, application using Web Components and the Dart Web UI library. So give

An Approach to Illiterate Programming: doc-code-merge

Reposted from Dart News & Updates : It's very common to embed code examples in technical documentation. However, doing so is kind of painful. First of all, the environment you use to edit the documentation may not be the same as the environment you use to write code. For instance, I generally use Dart Editor to write Dart code, but I use Sublime Text 2 to edit documentation written in HTML or Markdown. Secondly, it's difficult to run unit tests or use dart_analyzer if the code is trapped in documentation. This is a big problem for us on the Dart project because we move pretty quickly, and we want to make sure our documentation is always 100% correct. I've created a tool called doc-code-merge to solve this problem. doc-code-merge is the opposite of what Donald Knuth labelled Literate Programming . doc-code-merge lets you write your documentation and your code examples completely separately. When you run doc_code_merge.dart, it makes a copy of your documentation wit

Dartisans Ep. 16: Dart and Web Components Reloaded

In this episode of Dartisans, Dimitri Glazkov (one of the godfathers of Web Components) gives a presentation on Web Components. Also, John Messerly and Siggi Cherem (who helped build the dart-lang/dart-web-components library) give a presentation on using Web Components in Dart. A lot of things have changed since our last episode focused on Web Components, and this was a must-see episode if you're interested in Web Components and/or Dart!

The Untouchables

There are some technologies that have such strong "street cred", they are effectively untouchable. Anyone who dares imply that they are deficient in any way is instantly labelled an uneducated moron. It is impossible to have a realistic conversation about these technologies, and it's not very common for enthusiasts of these technologies to admit their failings. Let me give some examples: Linux is the best operating system. Common Lisp is the best programming language ever invented. Haskell code is shorter, more elegant, and more correct than code written in any other language. Emacs is the best editor for real programmers. Apple creates the most user friendly user-interfaces. Tiling window managers lead to the highest degree of user productivity. Ruby on Rails is the best web framework written in any language. The only way to write good software that meets its users needs and is delivered on time is to embrace agile software development and use test-driven deve

Humor: Metamocking

There are a lot of very powerful concepts in the world of software engineering that have "meta" in their name. Just consider metaprogramming and metaclasses. I've spent some time thinking about what "metamocking" might look like. What would it mean to mock a mock? First, some background. Let's say I have the following function (written in Dart): void helloWorld() { print("Hello, World!"); } How do I know if it works correctly? Since it doesn't return anything, but rather changes the state of the outside world (specifically, the stuff printed to my terminal), it's not so easy to test. Mocking to the rescue! I need to add a bit of dependency injection so that the test can pass in its own code for printing and so that I can mock things properly: library hello_world; const defaultPrinter = const Printer(); class Printer { const Printer(); printValue(String s) => print(s); } void helloWorld({Printer printer: defaultPrinte

Dart: Lazily Evaluating Static Variables Leads to Wackiness

It is now possible in Dart to initialize top-level (i.e. static) variables using any expression. The expression gets evaluated lazily. When I first heard about this, my instant reaction was fear because laziness and imperative programming don't really get along. At the time, I hadn't seen the blog post where Gilad admitted that plainly. Hence, I spent a couple hours that night trying to come up with ways this could lead to wackiness. I asked Gilad about it, and he said, "Laziness and statefulness can cause scary problems, I know. You can get into these Hesienbugs, where things only show up when you look, so as you debug the problem disappears." Just to prove the point, I came up with the following Dart program: import "dart:io"; import "dart:math"; var varA = changeVarB(); var varB = 1; int changeVarB() { varB += 1; return 0; } main() { print("$varB"); var seed = new; var nextBool = n

Dart: My Recent Dart Talks

I recently gave two talks on Dart, one at reflections projections|2012 at the University of Illinois at Urbana-Champaign and one at DevOps Live in Plano, Texas. Both of them were recorded. The DevOps Live talk is slightly newer since I updated it for the M1 release of Dart. If you've never seen one of my introduction to Dart talks, now's your chance! reflections|projections 2012 talk DevOps Live talk

Trip to "reflections projections|2012"

I gave a talk and a codelab on Dart at reflections projections|2012 at the University of Illinois at Urbana-Champaign. I can't possibly explain how well organized the conference was, how friendly the students and alumni were, or how much I enjoyed hanging out with everyone there! A big shout out to Kurtis, RJ, Metro, Zed, Danielle, Caitlyn, Ciara, etc.! Since I did manage to attend a few talks, let me blog about those. If you want, you can watch the videos. Garry Tan from YCombinator This was a talk on creating startups. He worked at Microsoft. He co-founded Posterous. "Do everything. Don't box yourself in[to a particular skillset]." The more you know, the better you'll be able to guage the qualities of cofounders. Studying entreprenuership != doing it. Work is for learning. If you plan on doing a startup, don't run out and buy a really nice, brand-new car. Money is capital. Microsoft made $650,000 per year per employee while he was there.

Personal: Life Beyond Startups

I've gone to a lot of talks recently focused on startups. Personally, I've spent more than a decade at more than 10 different startups, and I certainly think startups are a heck of a lot of fun. However, I'm beginning to think they're a bit overrated. Some of the talks I've gone to lately almost suggest that doing your own startup is the only path to happiness and personal fulfillment. Let me dispel that myth. First of all, not everything can be accomplished by two guys and a spare garage. Apple started out in a garage, as did the Wright brothers. However, the sleek MacBook Pro that I'm currently typing on bares little resemblance to the Apple I. There have been thousands of people needed to make Apple what it is today. The same is true of Google as well. Google is way more than just a search engine these days! The Wright brothers may have been the first ones to successfully put a man in an airplane, but a Boeing 747 isn't something that can be accompli

Video Games: TV Latency

I was having a lot of problems with latency on my TV, and my wife and I finally figured out how to fix it. I bought a used TV on Craigslist because my old CRT started smoking. The new one was originally purchased at Best Buy. It's an Insignia model number NS-32L550A11. When I plugged in the Wii, the latency was so bad it was driving my entire family crazy. Here are the steps that my wife and I took to finally fix the problem: First of all, I decided to buy a component adapter / cable to connect the Wii directly to the TV using a component connection. This made the picture look a lot better. We resynced all of the Wii remotes and checked their batteries. Then we went to the Wii settings menu and switched the screen to wide screen mode, and we set the resolution to 480p. Then we made sure that the TV was in game mode. Other versions of this TV called this DCM mode. We tried moving the sensor bar and checking the sensitivity. The most important thing we did was reset t

Software Engineering: Corporate Wormholes

Imagine you have two teams that are located in different offices. It's sad when you lose the ability to just walk up and talk with someone, especially when you notice that they're just walking by. I think spur-of-the-moment meetings are underrated these days. They can really help speed up your team velocity! Although I can't take credit for the idea, I think the solution is what I like to call "corporate wormholes". Setup a computer at each office with an always-on video connection with the other offices. Hence, you can always see when there are people in the other office. You can chitchat when they walk by, etc. If you have 10 small offices, then you can reach out to all the offices quickly if it's important enough to interrupt them (which should be rare, of course). Naturally, you don't need a wormhole to every part of your organization. You only need them for teams that are working on the same thing, but at different localities. In general, corpora

Linux on the Desktop

I'm a Linux guy at heart, but I use a Mac. For a long time, I've had a weird love hate relationship with Apple laptops. I was feeling a bit nostalgic today, and I stumbled across these articles: What Killed the Linux Desktop by Miguel de Icaza, one of the founders of GNOME How Apple Killed the Linux Desktop and Why That Doesn’t Matter which comments on Miguel de Icaza's post Linus Torvalds Ditches GNOME For Xfce Another post by Linux Torvalds on GNOME3 The Linux Haters Blog Evolution of an Ubuntu User It reminds me of The UNIX-Haters Handbook , which as a fantastic read :) Warning, do not read any of the above if you're easily offended! Who would have thought that Linux would be more successful in the mobile world than on the desktop? Who could have guessed that one of the most successful Linux on the desktop projects would actually embrace trusted platform modules and restrict access to the shell by default (unless you put it in developer mode)

Dart: An Algorithm to Unindent Code

Have you ever had to write an algorithm to unindent a block of code consistently? Figuring out the maximum amount of whitespace among all the lines and then removing that amount of whitespace is non-trivial. Remembering to ignore lines that only have whitespace makes the problem even harder. Here's some Dart code that I wrote to do it. I do believe the performance is O(num_lines * max_line_length), which I think is optimal. It should be easy to port this to other languages if you need it: /** * Remove the indentation from the given lines. * * Only remove as much indentation as the line with the least amount of * indentation. */ List<String> unindentFilter(List<String> lines) { // Make a copy so that we can modify it in place. lines = new List<String>.from(lines); // Make sure there is at least one line. if (!lines.isEmpty()) { // Figure out how much indentation the first line has. var indentation = new List<String>(); for

3 Articles Every Hardcore Dart Developer Should Read

I answer a lot of questions about Dart. Some of my friends are even working on their own programming languages, and they tend to ask really hard questions. In the past, I've struggled with some of those questions. However, I finally got around to reading three articles that answered a lot of those tough questions: Why Dart Types are Optional and Unsound Why Not a Bytecode VM? Optional Types in Dart Reading these three articles really helped me appreciate Dart at a much deeper level. If you're a language geek like I am, I highly recommend them!

Java: Helloooooooo, World!

I was talking to my buddy, Peter von der Ahé, today about optimizing startup time. He asked me to guess how many classes the JVM had to load for a simple hello world application written in Java. He also asked me how long such a program would take to run. I didn't know the answers, so he quickly typed it out on my friend's MacBook Pro. Here's how to see how many classes are loaded: java -verbose:class Hello That results in 594 classes: [Opened /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar] [Loaded java.lang.Object from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar] [Loaded from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar] [Loaded java.lang.Comparable from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar] ... [Loaded java.util.Collections$UnmodifiableMap from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Con

Books: Memoirs Found in a Bathtub

I just finished listening to Memoirs Found in a Bathtub by Stanislaw Lem. It was recommended to me by someone long ago, but I can't remember who. All I can say is WTF!?! Fortunately, Wikipedia has a better summary: Set in the distant future, Memoirs Found in a Bathtub is the horrifying first-hand account of a bureaucratic agent trapped deep within the subterranean bowels of a vast underground military complex. In a Kafkaesque maelstrom of terrifying confusion and utter insanity, this man must attempt to follow his mission directives of conducting an "on-the-spot investigation. Verify. Search. Destroy. Incite. Inform. Over and out. On the nth day nth hour sector n subsector n rendezvous with N." The narrator inhabits a paranoid dystopia where nothing is as it seems, chaos seems to rule all events, and everyone is deeply suspicious of everyone else. In danger of losing his mind, the protagonist starts keeping a diary, and it is this diary which details only a fe

Python: Party Playlist Picker

At long last, Jeffrey Posnick and I finally got around to open sourcing a project that we started as my starter project at Google. Here is the blog post we posted on the YouTube API Blog : When Google+ first came out, we were really excited about the idea of writing some open source code to showcase how you could integrate YouTube with Google+. After some brainstorming, we came up with the idea of letting people collaboratively edit a playlist in realtime, and we started hacking! We started working on Party Playlist Picker in early 2011. We’ve always wanted to release our experiment as an open source project, and you can now download the code to see one example of integrating Google+ functionality to enrich a YouTube application. Party Playlist Picker is a Google App Engine application written in Python . It uses a Google+ share button so that partygoers can invite their friends to come edit a playlist in realtime. That feature is based on the Google App Engine channel API .

Dart: My Quest to Program Dart on a Chromebook

They gave me a cool new Chromebook at work. Now, the sensible thing to do is to use it as a convenient web browser and nothing more. However, I'm not a very sensible person, and for some reason, I dislike having more than one computer at a time. Since I'm a member of the Dart team, I figured I should be prepared to use Dart Editor at any time of the day or night. Hence, I embarked on a multi-day journey, driven by my own obsessive compulsive disorder, to somehow figure out a way to run Dart Editor on a Chromebook. By far, the easiest approach is probably to install Ubuntu on it. I didn't want to take that approach since I really wanted to use ChromeOS as well, and I hate dual booting. The next approach is to put the machine in developer mode and install various things within the existing Linux distro. There are some pretty good instructions on that here . They involve setting up a build server, etc., which I balked at--I want fewer computers, not more computers! M

Ruby: Quizzimoto

I finally open sourced Quizzimoto . Quizzimoto is an application that lets you build video-based quizzes. My goal was to do something interesting in the educational space using Ruby on Rails and YouTube APIs. I used Quizzimoto as a sample application in my tutorial, Google I/O 101: Using Ruby on Rails and YouTube for Education . If you're interested, here's the source .

PHP: Phycocauth

Phycocauth is a sample project that combines the following: PHP, YouTube, OAuth2, CodeIgniter, the CodeIgniter Youtube API Library, and the Google APIs Client Library for PHP. I'm releasing this proof of concept to show that it's possible to integrate the CodeIgniter Youtube API Library with the Google APIs Client Library for PHP. Once version 3 of the YouTube API is ready, the CodeIgniter Youtube API Library will no longer be necessary. All you'll need is the Google APIs Client Library for PHP which will be able to handle OAuth2 as well as the YouTube API. See application/controllers/example.php for the most interesting piece code.

Books: Content Rules

I just finished listening to Content Rules: How to Create Killer Blogs, Podcasts, Videos, Ebooks, Webinars (and More) That Engage Customers and Ignite Your Business . In short, it was good. If it's part of your job to talk to the world using social media, it's worth reading.

Books: What Technology Wants

I just finished listening to What Technology Wants by Kevin Kelly, the guy who started "Wired" magazine. What an incredible book! Here's Amazon's description: In this provocative book, one of today's most respected thinkers turns the conversation about technology on its head by viewing technology as a natural system, an extension of biological evolution. By mapping the behavior of life, we paradoxically get a glimpse at where technology is headed-or "what it wants." Kevin Kelly offers a dozen trajectories in the coming decades for this near-living system. And as we align ourselves with technology's agenda, we can capture its colossal potential. This visionary and optimistic book explores how technology gives our lives greater meaning and is a must-read for anyone curious about the future. In short, it's a fascinating, holistic, comprehensive philosophy of technology. Kelly covers things such as: The history of technology since pre-human

Books: Peopleware: Productive Projects and Teams

When I worked at Xmarks, I had a boss named Penny. Before coming to Xmarks, she worked as a manager in operations at Amazon. Apparently, she went several years with no employee turnover. Obviously, she was a very good manager. I asked her what her secret was. She told me that I should read a book called Peopleware: Productive Projects and Teams : Demarco and Lister demonstrate that the major issues of software development are human, not technical. Their answers aren't easy--just incredibly successful... Fast forward 5 years, I finally took her advice. What a fantastic book! It was first released in 1987, and an updated version was released in 1999. However, it's just as relevant today. I really think this book ranks up there with The Mythical Man-Month . I've spent so much time over the course of my career reading technical books and learning new programming languages in order to perfect my craft and increase my productivity. However, I was oblivious to the fact that s

Books: What Would Google Do?

I just finished listening to What Would Google Do? It was okay. I think the book was really about what Jeff Jarvis would do. For instance, he argued very strongly for some things that he admitted Google doesn't do. In general, I think he gets a lot of stuff right, but he also overstates some things, and he even gets some things wrong. If you really want to understand Google's ethos, I think In the Plex: How Google Thinks, Works, and Shapes Our Lives is more on target.

Using Ruby on Rails and YouTube for Education

The other tutorial that I created for Google I/O this year just went live. In "Using Ruby on Rails and YouTube for Education", I explain that Ruby on Rails, YouTube, education, and TDD are like a peanut butter, honey, and banana sandwich! I'm particularly proud of the section that teaches you how to do test-driven development with RESTful web services, including a "live" (for some definition of live) coding session. Enjoy!

YouTube for Your Business

I did two tutorials for Google I/O this year. The first one, "YouTube for Your Business", just went live. It's amazing that it took weeks of effort and 8.5 hours of filming to produce these two videos, but they're less than 45 minutes long combined! Anyway, if you're interested in learning about all the different ways you can use YouTube for your business, including both technical and non-technical examples, check it out!

Books: In the Plex: How Google Thinks, Works, and Shapes Our Lives

I just finished listening to In the Plex: How Google Thinks, Works, and Shapes Our Lives . I liked it. While it may not be as good as Steve Jobs' biography or Steven Levy's other book, Hackers , I still really enjoyed it. It really helped me put my experiences at Google into context. It's amazing how little Google has changed, how much it continues to work on, and how much Steven Levy was allowed to get an inside look at Google.

Books: Steve Jobs

I listened to Steve Jobs' biography while commuting to and from work. It was incredibly interesting, and extremely well written. I highly recommend it.

Async: To Be or Not To Be

Just because I have to use a callback-oriented style on the client doesn't mean I want to use a callback-oriented style on the server. Now, before anyone gets all upset and tells me that I don't know the difference between async and a kitchen sink, let me explain :) The client is necessarily an event-oriented place. If I don't know which button the user is going to press, it makes a lot of sense to use a different callback for each button. The server is different. If I'm waiting for the result of a database query before I can continue processing a request, it sure is convenient to just block and wait. My key point is that it's important to separate what style you want to code with and what performance and scalability characteristics you want. You shouldn't necessarily pick a callback-oriented style just because you want the performance and scalability characteristics of asynchronous networking APIs. My favorite two examples are gevent and Erlang, b

HTML5 Dev Conf

I went to HTML5 Dev Conf yesterday. The following is a loose collection of my notes. First of all, the place was packed! Even the second-tier talks didn't have any standing room left over. The Backbone.js talk was especially packed. Not only could I not get into the room, I couldn't even get anywhere near the door. In general, Backbone.js was an extremely hot topic. However, most people admitted that they hadn't used it. Douglas Crockford's Keynote JSON has no version number. "Everything with a 1.0 gets a 1.1 and a 2.0, and it's all crap until you get to 3.0, so JSON has no version number." He talked about the first browser, Mosaic. Some company patented an <embed> tag to embed content in a rectangle in the browser. He said that the company was a patent troll, and they went after everyone trying to make money. They figured their patent covered JavaScript, image tags, etc. Apple settled. M$ fought them for years. Yahoo finally l

Code Reuse has Finally Arrived...Obviously!

I got into a discussion about code reuse with my co-worker, Jarek. I remember reading books on object oriented programming from a few decades ago in which OOP promised to increase code reuse. A lot of people doubted that serious code reuse would ever happen. OOP suggested that code reuse would be possible by reusing and subclassing existing classes. I even remember hearing C++ programmers talk about purchasing libraries of useful classes. To some degree, this did actually happen. For instance, QT is a wonderful library for C++, and it certainly makes coding in C++ a lot easier. It was even proprietary up until a few years ago. Library reuse also happened via language-specific package sites such as CPAN (for Perl), PyPI (for Python), and a range of sites for Ruby. Furthermore, most languages come with a lot more stuff built in these days. For instance, compare Python's standard library ("batteries included") with that of C. However, compared to decades ago, t

Documentation Sucks, Video Games Rule!

One thing that's great about a lot of video games is that you don't have to read any documentation in order to start playing them. I tend to play games on the Wii with my wife, and those games tend to teach you what you need as you go along. I think the same thing applies to user interfaces. Having to read documentation kind of sucks. Being able to learn as you go along is much nicer. A user interface that is easy to get started with is great, and one that teaches you on the fly how to become a power user is even better. For instance, I think that menus are a great way to enable users to discover new features. Menus that also show you the relevant shortcut keys are great because you become a power user by gradually memorizing frequently used commands. A user interface that does useful things automatically (assist and suggest) is the best of all (for instance, code assist). Another thing I feel strongly about is that a piece of software doesn't have to be hard to

Dart in Glasgow, Scotland

I gave a talk on Dart in Glasgow, Scotland. A big round of thanks go to my friends at and 29studios for not only setting up the talk, but also recording and editing it.

Unit Tests Don't Find Bugs: the Death of QA

Unit tests don't find bugs. They find regressions. This is a painful lesson I learned when I first started doing TDD (test-driven development), and it's well known among most TDD circles. TDD's goal is to prevent programmers from introducing new bugs into working code. However, when you're writing code from scratch, your tests won't help you find all the bugs in your code. That's because you can't possibly write tests for all the ways your software will be used (or abused). When I first started doing TDD, I had really good tests, but I was too tired to do much exploratory QA. However, my boss wasn't, and I was very embarrassed to find that my software had lots of bugs. Simply put, he used my software in ways that I hadn't intended. I've seen a lot of companies that don't bother writing any tests or doing any QA. They just let their users find all the bugs. Needless to say, I've never had respect for those companies. Howeve

Books: Agile Web Development with Rails

I finished reading most of Agile Web Development with Rails , fourth edition. This is the third edition that I've bought and read. I still love this book. This edition is much shorter than the previous editions. I tend to read books cover-to-cover, so I appreciate when they aren't full of reference information that I can find online. I think this book struck the right balance of breadth, depth, and length. My buddy Shailen Tuli thought it was too short. Your mileage may vary. I think the only thing bad about this book is that it focuses on Rails 3.0. Because Rails 3.1 has something called the "asset pipeline", it's not so easy to make the jump. I decided to stick with Rails 3.0 for the time being because I really like having a book to refer to.

Personal: My Laptop is Worried About Me

My laptop and I have a close relationship. After all, we do spend all day with each other! Hence, it's unsurprising that we show little bits of affection for each other. For instance, my shell prompt is "Yes, dear?", and the last command I type before reinstalling my OS is always, "thank you". It always replies "command not found" which is its way of saying, "Oh, it was nothing. Think nothing of it!" Naturally, we're not always so sentimental. We like to joke with each other too. For instance, whenever I start a new terminal, it always gives me my fortune , which is usually something funny. Today, my fortune read, "You look tired." Maybe my laptop is right. I've been giving so many talks lately, maybe it's time to take a break ;-)

PyCon: Parsing Sentences with the OTHER Natural Language Tool: Link Grammar

See the website . When it comes to NLTK (the Natural Language Toolkit), some assembly is definitely required. If you're not a linguist, it's not so easy. Link Grammar is a theory of parsing sentences. It is also a specific implementation written in C. It's from CMU. It started in 1991. The latest release was in 2004. Link Grammar does not use "explicit constituents" (e.g. noun phrases). It puts an emphasis on lexicality. Sometimes, specific words have a large and important meaning in the language. For instance, consider the word "on" in "I went to work on Friday." pylinkgrammar is a Python wrapper for Link Grammar. (Make sure you use the version of pylinkgrammar on BitBucket.) Often, there are multiple valid linkages for a specific sentence. It can produce a sentence tree. It can even generate Postscript containing the syntax tree. (The demo was impressive.) A link grammar is a set of rules defining how words can be linked tog

PyCon: Parsing Horrible Things with Python

See the website . He's trying to parse MediaWiki text. MediaWiki is based on lots of regex replacements. It doesn't have a proper parser. He's doing this for the Mozilla wiki. He tried Pyparsing. (Looking at it, I think I like PLY better, syntactically at least.) He had problems with debugging. Pyparsing is a recursive decent parser. He tried PLY. He really likes it. It is LALR or LR(1). PLY has stood the test of time, and it has great debugging output. However, it turns out that MediaWiki's syntax is a bit too sloppy for PLY. LALR or LR(1) just doesn't work for MediaWiki. Next, he tried Pijnu. It supports PEG, partial expression grammars. He got it to parse MediaWiki. However, it has no tests, it's not written Pythonicly, it's way too slow, and it eats up a ton of RAM! He wrote his own parser called Parsimonious. His goals were to make it fast, short, frugal on RAM usage, minimalistic, understandable, idiomatic, well tested, and readable