Hi, everyone!
I just got working a preliminary version of a JBox2D 2.0.1 port to Scala. I still have lots of work to do before releasing anything though, and I'm not really sure yet if I want to turn this into a project that needs maintenance -- I primarily did it for my own game. And my port is with a twist:
* it's primarily focused on cleaner API's and code readability instead of speed and similarity to the C++/Java versions
(Actually without those goals I wouldn't have started it, because you can easily use JBox2D from Scala anyway)
* speed is still important, and I'm even thinking of writing a Scala compiler plugin that could optimize vector/matrix math behind the scenes, but that may be too crazy an idea. But currently I even "de-optimized" some of the math where it made code simpler.
* as much as possible is immutable. For example vectors, matrices, transforms are immutable
* operators are back (and more) compared to Java (well, in Scala operator and method are the same thing) -- for example cross products can be written like w2 × ccp.r2, since Scala allows special unicode characters in method names
* I know very little about physics, for me this is more of an exercise in API design and porting Java code to Scala
Due to many differences to the original code, I'm not sure how easy it is to keep this code current as Box2D is developed. But there is some hope because there is less code in the Scala version -- I haven't measured yet (as some code is yet to be ported), but I'm estimating that there is at least 2 times less lines of code than the Java version. Could be even less than that.
If anyone is interested to see the code, let me know. It still needs some more work and cleanup, though, so I won't be able to show it to you immediately.
I just got working a preliminary version of a JBox2D 2.0.1 port to Scala. I still have lots of work to do before releasing anything though, and I'm not really sure yet if I want to turn this into a project that needs maintenance -- I primarily did it for my own game. And my port is with a twist:
* it's primarily focused on cleaner API's and code readability instead of speed and similarity to the C++/Java versions
(Actually without those goals I wouldn't have started it, because you can easily use JBox2D from Scala anyway)
* speed is still important, and I'm even thinking of writing a Scala compiler plugin that could optimize vector/matrix math behind the scenes, but that may be too crazy an idea. But currently I even "de-optimized" some of the math where it made code simpler.
* as much as possible is immutable. For example vectors, matrices, transforms are immutable
* operators are back (and more) compared to Java (well, in Scala operator and method are the same thing) -- for example cross products can be written like w2 × ccp.r2, since Scala allows special unicode characters in method names
* I know very little about physics, for me this is more of an exercise in API design and porting Java code to Scala
Due to many differences to the original code, I'm not sure how easy it is to keep this code current as Box2D is developed. But there is some hope because there is less code in the Scala version -- I haven't measured yet (as some code is yet to be ported), but I'm estimating that there is at least 2 times less lines of code than the Java version. Could be even less than that.
If anyone is interested to see the code, let me know. It still needs some more work and cleanup, though, so I won't be able to show it to you immediately.