Jeff Kaufman  ::  Blog Posts  ::  RSS Feed  ::  Contact

Thoughts on AMP

(I work on ads at Google, which involves working closely with some AMP folks. These are all my views and not theirs or my employer's)

AMP is a way of writing web pages using a subset of HTML and CSS, plus some open source Javascript libraries. It has two main properties that allow it to be perform very well under some circumstances:

  • It doesn't allow many inefficient things that regular pages can do. You can't include an image tag without specifying its size, you can't write horribly performing javascript that blocks the UI thread and locks the page, you can only use CSS transitions that can be GPU-accellerated, etc.

  • It's designed for pre-rendering. The AMP JS knows when it's being speculatively rendered and prioritizes the most important and cheapest things. Additionally, this pre-rendering can happen in a privacy-preserving way

This is a really good fit for the case AMP was designed for: very fast loading when you click through from search results. This is a major use case in general and especially for Google. In order to provide this, however, AMP is fundamentally dependent on its javascript library, or 'runtime'. The runtime schedules the loading of everything on the page, tries to prioritize content that will be viewed soon, understands whether it's in prendering mode, etc.

As you might guess from this site and others I've made I really don't like the AMP approach. I hand-code my sites with simple HTML and minimal inlined CSS. Javascript is for progressive enhancement and implementing features. Having Javascript in the critical path of rendering or loading, as AMP has to do, is strongly at odds with the goal of fast and responsive sites.

In the non-preloaded case, taking a random post here, I see a median speed index of 1.611s on non-AMP but 2.051s on AMP. In both cases the HTML loads in ~400ms, but the HTML version can paint the HTML right away while the AMP version is still waiting on JS. Then the AMP version spends 600ms downloading and executing the AMP runtime and extension scripts. Once AMP has loaded it's smarter than the HTML version about what to load, deprioritizing below the fold resources, but it's already too far behind to catch up. The HTML page is fully loaded in about the time it takes the AMP page to finish rendering above the fold.

On the other hand, that's not most sites on the web. I see all sorts of Javascript frameworks and libraries, huge external stylesheets, giant images that the browser can't tell are well below the fold, complex asynchronous loading, etc. Most sites really are a lot faster and more responsive as AMP, and this improves my experience of using the web.

One way to look at this is that I want the web to be declarative: sites should describe how they should look and act. This is how HTML and CSS work, while in Javascript you tell the browser what to do. The AMP spec dramatically expands the range of what a site can do declaratively, but only if you think of the AMP runtime as part of the platform. Ideally I'd like to see the key things AMP provides made available actually as part of the platform, without the dependence on JS libraries. This could look totally different from AMP, but AMP is still very useful in that the project lets you see what features site-owners would need from something like this for it to be useful.

full post...

What is Phrasing in Contra Dance?

If you come to contra dance from a different tradition, or you're a DJ putting together sets for a techno contra, people will tell you to choose "square" tunes with "clear phrasing". What does this mean?

In contra dance you take one step for every beat of music, and it's all built around powers of two:

  • 2 beats: roll away, pass through, pull by.
  • 4 beats: balance (which is two 2s), petronella and rory-o-moore spins, turn as a couple.
  • 8 beats: long lines, chain, right and left through (all of which are two 4s)
  • 16 beats: balance and swing, full hey

The music is also generally built around powers of two:

  • 64 beats: once through the tune
  • 32 beats: the A part vs B part
  • 16 beats: a section of the tune (A1, A2, B1, B2)
This looks like:
      tune
    /      \
   A        B
  / \      / \
A1   A2  B1   B2
Each section (A1, A2, B1, B2) then also divides into powers of two, with two clear 8-beat phrases, each of which generally has a clear 4-count and 2-count.

These power-of-two figures generally need to align with the powers of two in the music. So while you could have a dance that did:

  • (4) balance
  • (2) roll away
  • (2) roll away
  • (8) long lines

a dance that did:

  • (4) balance
  • (8) long lines
  • (2) roll away
  • (2) roll away
would be very strange. Whhen you look at the structure of a the tune you can see why the that doesn't work:
          64
         /  \
        32   ...
      /   \
     16    ...
   /    \
  8      8
 / \    / \
4   4  4   4
The former is fine:
           16
          /  \
         8    long lines
        / \
 balance   4
          / \
      roll   roll
but the latter doesn't fit well:
              16
          /        \
        8            8
       / \          / \
balance  lines  lines   4
         go in  go out / \
                      /   \
                  roll     roll

Of course, a dance could be an even worse fit. Consider:

  • (2) roll away
  • (4) balance
  • (8) long lines
  • (2) roll away
Or:
  • (1) stamp
  • (2) roll away
  • (4) balance
  • (8) long lines
  • (1) stamp
These fit the tree so poorly I'm not even going to try to sketch what they could look like.

Now, some figures don't exactly fit a tree. The main exception is the swing which always runs until the end of the current sixteen count:

  • (2) pass through
  • (14) swing
or:
  • (4) balance
  • (12) swing
or:
  • (6) circle 3/4
  • (10) swing
or:
  • (8) larks allemande left 1.5
  • (8) swing

These can look a little strange:

          16 
         /  \
        8    more swing
       / \
balance  swing
but the key thing is that the swing has to finish the 16 count. So you can have:
  • (8) half hey
  • (8) swing
but you can't generally have:
  • (8) swing
  • (8) half hey

This means the dancers need to be able to hear the 4 count, 8 count, and 16 count to figure out when to start and end figures.

What about the 32 and 64 counts? They keep the dancers from getting lost. Consider the dance, The Baby Rose:

  • A1
    • (16) Neighbor Balance and Swing
  • A2
    • (8) Circle Left
    • (8) Dosido Partner
  • B1
    • (16) Partner Balance and Swing
  • B2
    • (8) Ravens Chain
    • (8) Star Left
Notice how both the A1 and B1 are a balance and swing, but then people need to do different things in the A2 (circle) vs B2 (chain)? When you play a tune that has two clear sections of 32 beats (and "A part" and a "B part") and that clearly signals the 64-count ("top of the tune coming up!") the dancers are much less likely to accidentally circle when they should be chaining.

A "square" tune is one that breaks down into our nice even tree:

          64
         /  \
       32    ...
      /  \
     16   ...
   /    \
  8      8
 / \    / \
4   4  4   4
It supports the dancing, and makes it easy to hear where the figures go. When you're playing, or picking tunes, you want to make sure that each of these different levels of the tree will be apparent to the dancers.

Now, different dances need different things. For example, here's the B2 (last 16 counts) of Chuck the Budgie:

  • (4) Balance short wavy lines
  • (4) Neighbor allemande left 3/4
  • (4) Balance long wavy lines
  • (4) Next neighbor allemande right 3/4

This dance would go great with a tune that really gave a clear four count ("chunky") while a B2 of:

  • (16) right shoulder round, and swing
is going to go a lot better with a tune that doesn't emphasize fours or even eights, and just lets the dance flow.

While you're unlikely to find a tune that has exactly the right rhythmic structure to support a particular dance, you also have a lot of freedom in how you play the tune. For parts that are flowy with long figures and mushy transitions (hey into right shoulder round) then don't accent the 4 or 8 and let the structure of the tune indicate the 16/32/64. Similarly, if the transitions are precise (balances, lines) then make a clearer break.

If you're playing for a dance and choosing standard 32-bar jigs and reels most of this will come very naturally. On the other hand, if you want to take pop songs and DJ them, you're going to run into the problem that they don't tend to have this "square" structure. They often have an 8-count, but they probably don't have all the levels of the tree up to the 64-count. You can pick songs that do, modify ones that don't, or just go ahead with things that don't have clear phrasing (that's what people usually seem to do). One thing I'd love to see someone play with is adding a tiny bit of extra embelishment on top of songs to signal the 16-count, 32-count, and 64-count.

full post...

Right Shoulder Round

One of the figures in contra dance has traditionally been called "gypsy", a figure where two people walk around each other, typically while maintaining eye contact. It was borrowed from English Country Dance in the 1970s, which got it from Morris dancing, and history before Cecil Sharp wrote it down in ~1909 is not known.

Being the name of a historically oppressed group of people, over the past few years there's been a push to switch away from the term. People suggested alternatives and debated their merits, callers tested them out at dances and figured out what worked, and at this point it looks to me like we're landing on "right shoulder round". Examples:

more...
Value of Working in Ads?

I recently gave a talk about my experience earning to give, and someone asked whether I saw the direct impact of my work as positive or negative. This is a good question, and a common objection to earning to give: you wouldn't want to take a job that was majorly negative for the world in order to earn a bit more money to donate. So how is the world different with me doing this job as opposed to something else?

I work in display advertising at Google, which means AdSense and Ad Manager (formerly DoubleClick for Publishers). These help people who have websites to put ads on them.

So one question, then, is whether the display ads business is overall positive or negative for the world. I think it's generally positive, despite some downsides: the majority of websites are funded through ads, and this has allowed an enormous diversity of information to flourish. I can afford to write for fun and run this site without ads on it [1], but many people with interesting things to say can't. The New York Times can convince some people to pay, but a subscription-only web would be much worse. Overall, ads are a very progressive and democratic way of funding things: everyone can read and everyone can write, not just people who can pay.

On the other hand, it's not ideal. Ads are often annoying, and can get in the way of what you're trying to read. They can be slow to download or execute and delay the rest of the page. Similarly, they can download large images or videos using up your metered data plan. While sometimes ads fill a beneficial function of informing you about something you'll honestly be better off from having purchased, other times they're trying to convince you to spend your money foolishly.

more...
Trycontra Implementation

A while ago I wrote a very simple site that let you put in your zip code and find nearby dances:

Since there are only ~300 contra dances and ~40k zip codes I decided to do everything client side. The browser downloads a file of dances (json) that looks like this:

...
["http://www.nbcds.org/",
 "Santa Rosa CA",
 "Fridays and Saturdays", 15,
 38.44, -122.71, ""],

["http://www.nbcds.org/",
 "San Rafael CA",
 "Saturdays", 12,
 37.97, -122.53, ""],

["http://www.nbcds.org/",
 "Sebastopol CA",
 "Saturdays", 12,
 38.4, -122.82,
 "Larks / Ravens"],
...

And a file of zip codes (json) that looks like this:

more...
Beantown Stomp Retrospective

In April of last year I started thinking about maybe organizing some sort of contra dance weekend in Boston. I've been to a lot of weekends playing with the Free Raisins and I thought it would be fun to bring this format to Boston. In early May I talked to Amy and Audrey, wrote up a description of what I was thinking, and started pitching it to JP and BIDA.

Dates were still up in the air, but looking for times when the Masonic Hall, Amy, and Audrey were all available, and avoiding conflicts with other events, the weekend of March 22nd looked best. I signed a contract with the hall and confirmed with Amy and Audrey in early June, and then sent out a progress report. This started a long process of getting feedback from people on specifics of the weekend, trying to make sure I was thinking about all the things people like and don't like in a weekend.

more...
More Posts


Jeff Kaufman  ::  Blog Posts  ::  RSS Feed  ::  Contact