Thursday, December 18, 2008

A plunge into UI programming with Scala

Over the last couple of month, I have been working part-time on a new project: Kogics. The basic idea behind Kogics is to provide educational games and tools for kids. Even in this early stage of its life, Kogics has started to be pretty useful. I am using it to help my seven year old daughter practice her arithmetic skills. I have also been using it in evening computer-fun sessions with kids in my neighborhood in Dehradun, India. And Kogics is being used at a couple of schools in India as part of the Samvedna project.

The games on the Kogics website are written in Scala, and are deployed as applets. Yes - you heard that right: they're deployed as applets! I last wrote an applet sometime in 1996, in the early days of Java. And I have never really done anything much with Swing. But I must say that Swing programming has turned out to be surprisingly pain-free, especially with Scala adding a nice fun (and power) factor to the mix. The Java runtime, as of JRE1.6u10 onwards, has (so far) turned out to be a pretty good way to deploy rich content on the web, despite the bad rap that it has in this area. Proguard is the magic sauce that makes all of this work in an efficient fashion, with applet sizes in the 20-30k range.

To see what I have been upto, check out the following:
The Addition Game
The Subtraction Game

Feedback is welcome (especially if you have kids).

And did I mention - I'm hosting parts of Kogics on the Google App Engine (the rest of Kogics runs on Wikidot). This has made me go off and start learning Python - which is currently the only language supported by the App Engine. It's been good fun so far. More on this in future posts...

I am planning to put in a lot more interactive stuff on the Kogics website in the coming weeks and months. As my proficiency with 2D graphics, UI development, and game-programming (goes up from zero and) increases, I'm hoping to create some pretty interesting and useful games and tools. Stay tuned!

6 comments:

Doug Holton said...

Is there a scala wrapper for swing out there?

I mean I know you can use swing just fine with scala, but was wondering if there was a wrapper that simplified it somewhat.

Lalit Pant said...

Doug,
Scala has a swing wrapper (under the scala.swing package), and something called ScalaFX is in the works.
But for now I'm just using plain-old swing directly in my Scala code.

Doug Holton said...

Thanks, I also just ran across squib, which looks interesting (it might be that scalafx, as it mimics javafx somewhat):

http://compulsiontocode.blogspot.com/2008/02/squib-kicks-part-1.html
http://code.google.com/p/scala-squib/
http://groups.google.com/group/scala-squib

Lalit Pant said...

Thanks for the links, Doug. I'll check out squib.

The ScalaFX I was talking about is located here:
http://lampsvn.epfl.ch/svn-repos/scala/scala-experimental/trunk/scalafx/

Cilia Johnson said...

Thank for this post -
I have been thinking of exploring more on Scala; and it is blog posts like yours that keeps one's interest in programming language alive.


I just saw this review and thought it looked very good. http://www.jroller.com/bookreview/entry/programming_in_scala

I will get a copy of the book.
Thanks again

Free Java said...

Nice piece on getting one's feet wet with Scala. I still think Swing is easier to use than ScalaFX though.