Saturday, January 29, 2011

Reconsidering GUI platform

So I just found out that JavaFX will be ported as a Java API and thus will become a java library.  JavaFX seems to be a more technologically advanced GUI framework than Swing.  What caught my eye on the JavaFX roadmap was that it would be hardware graphics accelerated.  Unlike Swing, which is rooted in AWT, JavaFX will be able to take advantage of OpenGL or DirectX.

In fact, when I originally started on my clojure project, I had considered using lwjgl and nifty-gui (and possibly even the jmonkeyengine).  I had ultimately planned on wanting a 3d view, as I thought this would be a cool feature for the game.  A long time ago, even before I had started programming, I had looked at the OpenRPG engine (written in python).  While I thought OpenRPG was pretty cool, I wished it had a 3d map/world feature.

So I will go ahead and complete the java launcher project in Swing, but I will then start looking into lwjgl and nifty-gui from here on out.  Although jmonkeyengine looks great, and I know (almost) nothing about 3d programming, I doubt jmonkeyengine will be very amenable to using clojure.  Besides, this will be an opportunity for me to learn OpenGL from the ground up.


 UPDATE:


I did a little more research, including taking a look at TWL, and a little more into lwjgl, and I think switching to  3d aware GUI platform is the way to go.  

I looked a bit at TWL, but none of their java web start demos worked for me, the wiki leads you to a non-existent page, and the documentation like-wise is missing.  Basically, not a good way to get me to want to use it.  It did however have a scala port and it used mercurial as its VCS system.  Yes, I do tend to see how up-to-date people are with a project.  If they are still using CVS, I get scared (I'm looking at you Eclipse), and if they are still using subversion, I see them as falling behind (or maybe they are just scared of using repository porting tools to convert from subversion to something like git or mercurial).

So while looking at one of the nifty-gui tutorials, it goes into some detail about how to create your own widget.  In other toolkits, this is quite a pain to do, and I thought it was pretty cool to be able to do that.  I did notice that all the java 3d gui toolkits used XML as a declarative language.  I was thinking that it might not be bad to make a clojure port.  

I remember about 10 years ago, on the gamedev.net forum, there was a debate about lisp vs. xml.  Essentially anything you can do in xml, you can do in lisp.  Now that I have a better handle on clojure, I can see why.  In fact, Amit Rathore's book, Clojure in Action tries to dispell the myth that lisp syntax is hard by stripping away parts of xml until it looks like lisp syntax.

Now that I am getting better at clojure, it amazes me that people think Scala is the future for the JVM.  Not to pick on Scala, but its hybrid approach means that while programmers will be more comfortable in learning it from a paradigm perspective, it also means that code will be a mish-mosh of functional and impure code.  I think Scala is the bad way to go, even though it is clearly better than Java itself.  The syntax of clojure was actually pretty easy to get used to, it was just wrapping my brain around functional programming that was hard.  I also still haven't quite understood how or when to use macros, and that's one of the next things I want to tackle, and I think I will need to use macros if I wanted to make a clojure API around nifty-gui.

No comments:

Post a Comment