Pietime, my entry to JS1k 2015

For the uninitiated, JS1k is a JavaScript code golfing competition. To quote its about page, entrants "submit a self-contained demo in 1024 bytes of pure JS, which in turn may use various web technologies." In other words: see how much you can fit into just one kilobyte of JavaScript code.

There have been some incredible entries. 2013's winner might be my favorite, but there are plenty of other amazing submissions. It's almost spooky to see how much one carefully crafted kilobyte of JavaScript can produce nowadays!

I've been entering since 2013, but I actually placed in the top ten this year! You can check out my submission here. It lets you tell time using a non-traditional method: pie charts.

Many of the lessons of Daniel LeCheminant's four-kilobyte StackOverflow clone were helpful when squeezing my entry into the byte limit. Perhaps the biggest lesson was unintuitive: repeat yourself! The JSCrush JavaScript compressor can better compress repeated code than fewer characters. That's why my code has lots of lines like this:

canvas.c.moveTo(s / 2, s / 2);
canvas.c.arc(s / 2, s / 2, s * 0.45, 0, 2 * Math.PI);

I could've used with, but that turned out to compress worse than repeating myself like that. That was surprising to me!

Give my submission a look if you'd like, but definitely check out the other entries from this year—there are some really cool ones.