Wednesday, January 16, 2008

Scala Pong 4K

Well, I've decided to enter the Java 4K Game contest again, but I didn't use Java. Launch my simple 2-player pong game from here:
Scala Pong 4K
Player 1 uses W and S. Player 2 uses Up and Down. Not too exciting. It doesn't even keep score. But it's under 4K.

I've watched Scala off and on for years. Most recently, I've been toying with making a Scala-look-alike of my own, but far closer to Java. My two biggest problems with Scala have been these:
  1. Scala is very different from Java, even though you can code in Java style. I'm sometimes willing to learn new, but I've been afraid others wouldn't, and I wanted something with popular support. Also, it would be nice to be able to write Java libraries in "JavaNG".
  2. It has a 2.5 (plus or minus) MB runtime library. Some people couldn't care less, but I love small. To me, 2.5 MB isn't anywhere close to small. Oh, and then the compiler is 4 MB or so, if you want that.
Well, Scala can be made usable from Java (just as people sometimes write C libraries in C++ or other languages), people are picking it up despite my fears, and I made a 4K game in it. So, maybe it's time to start learning it better.

Side notes, don't say "object Game extends JPanel" since the singleton objects create classes that make a static method for every method in the class or super class. Or at least all visible methods.

Also, even private vars create accessor methods. Closure vars don't, but they bring in the class IntRef (for ints). And simple closures like "(a) => a + 1" create a class with a half dozen methods defined in them. Maybe pack200 and gzip would take care of that, but pack200/gzip doesn't count for the Java 4K Game contest. In real life, it could be useful, though.

Oh, and I definitely used ProGuard.


  1. Aren't you a little worried about leaving dead blogs all over the place, Tom? After all, you and Kristine have something like 5 or 6...

    A Grand Unified Blog might be a better idea. IMO.

  2. I'm trying to consolidate to Blogger, at least. And the plan is for this blog to be public, unlike my family/friend-oriented blog.

  3. I'm a long-time Java/C# developer who's curious about Scala and F#. It'd be really cool if you post the source for this.