Friday, October 26, 2012

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() {
  var seed = new;
  var nextBool = new Random(seed).nextBool();
  if (nextBool) {
    varA;  // This looks like a no-op, right?

Can you guess what this prints? Half the time, it prints 1, 1, 2. The other half the time, it prints 1, 2, 2. The first time I print varB, it's value is 1. However, the first time varA is evaluated, changeVarB() gets called (i.e. evaluated lazily). From then on, varB's value will be 2.

Of course, being able to initialize top-level variables to things that aren't constant is really useful, so I'm not sure I'd advocate changing this. Nonetheless, it's something I think you should be careful with.

Thursday, October 25, 2012

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

Wednesday, October 24, 2012

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.

Work is a transaction. You create the value. They give you a fraction of the value in exchange for stability...and a place to learn.

Be contrarian: Don't rely on third-hand accounts of what happened 6 months ago. (He criticized the media.)

All great ideas seem stupid initially.

He showed a Venn diagram where there's a sweet spot where something looks like a bad idea, but it's actually a good idea.

A great pitch is a self-fulfilling prophecy.

Everything sucks. Seek a problem, not technology for its own sake.

Ship a quantum of product: a discrete, indivisible manifestation of a product that solves a problem that people have.

When you're small, act small: Do unscalable things. Don't act bigger than you are.

When you're small, you can be human. Answer every email. Be personal. People notice.

reddit and came out of the first YCombinator batch.

They're spawning companies that are worth billions.

They only focus on building software and getting users.

Dinner is the only thing that's required of YCombinator participants.

Every angel and VC in the valley comes out to watch Demo Day. People generally raise $300k to over a million.

To get PR, go to a publication, and email them, "We want to give you an exclusive. Do you want it? Yes or no?" Go after the most junior writer there.

He joined YCombinator because he got a little burnt out.

When you're starting, it takes all your working hours. However, you can only sustain that for 3-6 months. At some point, you have to take it easier. Flow makes the time go by really fast.

Getting other co-founders involved is important. If you can't get another extremely talented person to go into it with you, then maybe what you're doing is really is crazy.

At this point, YCombinator isn't about the money they give you. It's about the connections.

Mark Twain said, "If at first you don't succeed, try, try again. But then quit. There's no use being a damn fool about it."

The most frequent question he hears is "How do I hire?" He said to go after your friends. Vote on who you think is the smartest, and then go sit on their doorstep. Posting a job posting and expecting to get an amazing hacker--that rarely happens. Don't start doing that until you've been around for quite a while.

The other question he hears the most frequently is "How do I fire my co-founder?" He said to talk to a lawyer. Make sure your stock options have a vesting schedule.

He thinks KickStarter is a good idea.

In general, focus on getting to market. Generally, don't focus on patents. They're really expensive.

I don't think a 10-page business plan is important. No one does that anymore. However, a 3-4 sentence pitch is key.

The Art and Algorithms of Pixar's Brave

This talk was given by Danielle Feinberg, Directory of Photography for Lighting.

The only way I can explain what they do is "wow"!!! Unfortunately, we weren't allowed to take pictures of anything. This has really given me a new appreciation for what they do.

Debian: 19 Years of Free Software, Do-ocracy, and Democracy

This talk was given by Stefano Zacchiroli, the Debian project leader.

They now have support for running kFreeBSD. This was added about 2 years ago. It's important for running ZFS. I remember wishing back in 2001 that Debian would make it possible to swap in new kernels, especially FreeBSD.

Ubuntu is 15-30 times more popular than Debian.

Dropbox Notification Servers

Dropbox can handle 1.7 million clients connected per machine. Those servers are written in C++. They use epoll (in edge-triggered mode). They use libevent. Each process has 170k connections. Limiting the amount of memory used per connection is critical. Avoiding SSL where possible is also critical.

They get about 70% CPU utilization. IO bandwidth is their biggest bottleneck.

They make clever use of shared memory and swapping open file descriptors. That way, they can restart a server process without losing all the open connections.

They originally wrote things in Twisted, but they couldn't get past 5000 connected clients. Twisted and Python are both kind of slow.

They then wrote it in C++, then went back to C, and then went back to C++.

They have about 60 engineers.

They server about 100 million users.

They want to be the "filesystem of the Internet".

They say that the fact that they're platform agnostic is one of their biggest competitive advantages.

They don't do client-side encryption. They use one key to encrypt everyone's data.

They've had a couple security incidents. There are tradeoffs for how secure you need to be.

Their main data is stored in S3.

All their web stuff is in Python. They use Pylons, but they have evolved very far away from Pylons. They also have their own templating system.

MySQL really doesn't like supporting more than 100 open connections.

When they receive a DMCA takedown, they don't try to delete it from the user's account entirely. They just ban the item from being publicly shared.

A lot of people at Dropbox came from Google.

My talk: Structured Web Programming: An Introduction to Dart

Here's a link to my talk.

There were two other talks going on at the same time as mine. One of them was by Zed Shaw. I got about 65 people. This proves conclusively there are still 65 people in the world who don't know that Zed Shaw is a more entertaining speaker than I am :)

I also did a codelab. Things were going very well, but about half way through the codelab, most of the people suddenly left. Apparently, there were a panel starting, and some of the guys who built "Portal" were on it :)

Nonetheless, I'm really, really glad I made the trip down to UIUC!

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 accomplished by two guys and a garage. Similarly, it took a lot more than two guys and a garage to put a guy on the moon. The freeway that I drove on to get to work today may have been envisioned by some guy in Germany in the 1930's, but actually building the freeway took a lot more effort than is possible by one man. I definitely admire Linus Torvalds for creating Linux, but it has taken thousands of skilled hackers to build and package all the software present in a modern Linux distro.

A lot of these talks also seem to suggest that people at startups are happier and co-workers are smarter. Sometimes that's true, but it's definitely not always true. I've been very unhappy at a lot of startups, especially when I was burnt out from being overworked, and I wasn't sure there was going to be enough money left to pay my rent! I may be a bit biased considering I work at Google, but I think that my current co-workers are some of the smartest, friendliest, and happiest people I've ever worked with. I know I'm definitely enjoying myself!

Everything has to start somewhere, and it's a lot of fun to start new things. However, there are many very worthwhile things that take a massive amount of manpower to accomplish. So let's not forget all those people who aren't famous who nonetheless made it possible to fully accomplish many of the most monumental and influential things all around us!

Sunday, October 21, 2012

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 the component settings in the TV menu to factory settings. I had seen other tips online that resetting the TV to factory settings would fix the problem. Resetting just the component settings was enough to get rid of the latency issues.

Now my wife can play her Wii Fit without wanting to kill the TV :)

Tuesday, October 09, 2012

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, corporate wormholes are a great way to build close-knit teams that are forced to work very far from each other.

Tuesday, October 02, 2012

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:

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)? What a strange world we live in!