The Rules

One of the downsides of doing client-side code golf is that it’s really easy to cheat. It’s so easy that most people would find it really boring. But if you’re not deterred by boredom, golf.js has a simple safeguard in place: all scores are submitted with code, and any code found to break the rules will be deleted.

Which raises the question: what exactly are the rules?  Here they are:

  1. jQuery is legal. I’m loading jQuery for the functionality of the site itself, but you’re welcome to use it in your submitted code.
  2. Using any other external JavaScript (e.g. via AJAX, script tag insertion, bookmarklets, etc.) is not legal.
  3. ObscureVariableName is not legal. I’m using this suffix in the testing framework itself to avoid conflicts with your own variable names. So don’t intentionally introduce such conflicts to game the game.

That’s it so far. If necessary, I’ll add more rules as I see people doing things that could reasonably be labeled “cheating.” And some holes may include exceptions to these rules.

The Scoring

The scoring is pretty simple:

  1. Incomplete holes get a default score of 10,000.
  2. Complete holes get a score equal to the number of characters in the solution code.

If you have questions about rules or scoring, speak up.

Welcome

If you’re new to golf.js (and right now everyone is new), you’re probably wondering what’s going on here. If you’re not familiar with the concept of code golf, you should check out codegolf.com. After writing PHP code there, and JavaScript code for my day job, I started to think about combining the two. And that’s pretty much where golf.js came from.

In retrospect, JavaScript seems like the ideal code golf language. All of the limitations of running server-side code are gone with JavaScript. Because you’re running it on your own computer, it won’t make a difference to me if you test your code 1 time or 100 times. And because the code isn’t running on the command line, the input and output formats can be any kind of variable.

So hopefully this will be fun. If you have any suggestions to make it more fun, please leave them in the comments, or send an email.