I’m currently trying to learn the scala language (http://www.scala-lang.org/)
Scala is the next big thing in language design - it is a mix between object oriented and functional programming.
Scala has the nice features of Ruby without the performance hit. It is also statically typed, which means less run time testing and error warnings directly in eclipse.
What better way to learn a new language than writing a game?
Scala compiles to java bytecode, which means that I can use all java libraries - including JME.
Here is TestSimpleGame written in Scala:
package test
import com.jme.app.SimpleGame
import com.jme.bounding.BoundingSphere
import com.jme.math.Vector3f
import com.jme.scene.shape.Box
object HelloWorld {
def main(args: Array[String]) :Unit = {
object MyGame extends SimpleGame {
override def simpleInitGame() {
this.display.setTitle("A Simple Test - written in Scala!")
def box = new Box("my box", new Vector3f(0, 0, 0), 2, 2, 2)
box.setModelBound(new BoundingSphere())
box.updateModelBound()
this.rootNode.attachChild(box)
}
}
MyGame.setDialogBehaviour(2)
MyGame.start()
}
}
This is of course not very exciting. The main difference to the java version is that MyGame is a singleton object, not a class.
I had problems accessing AbstractGame.ALWAYS_SHOW_PROPS_DIALOG, because it is abstract and protected.
I will let you know when I do something that better demonstrates the awesomeness of scala.
Cheers,
Martin