
Why You Might Want To Consider Java And/Or Clojure For Your Next Project - fogus
http://www.gamasutra.com/view/news/35700/Opinion_Why_You_Might_Want_To_Consider_Java_AndOr_Clojure_For_Your_Next_Project.php?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+GamasutraNews+%28Gamasutra+News%29
======
bad_user

         C# actually is quite good in many ways as well, but 
         unfortunately its open source counterpart (Mono) leaves
         it trailing a little bit behind on operating systems 
         other than Windows.
    

This is just an uninformed opinion. Mono is just better for desktop
applications and games, in all ways that count.

Performance wise, Mono is much more predictable. The VM starts faster and
doesn't need special warmup. If you don't like the VM, you can always compile
ahead-of-time. It has stack-allocated values, unsigned integers and if you're
inclined you can always come up with your own special 256-bit integers that
are still stack allocated.

I wrote lots of data processing scripts this last year and Mono had better
performance characteristics than Java. And that's before I tried plugging in
Mono.SIMD which totally blew me away.

Writing bindings to C/C++ libraries using P/Invoke is a piece of cake. That's
because Mono has richer primitives; in "unsafe" blocks of code you can even
have pointers and pointer arithmetic.

For desktop apps you can create native interfaces with GTK+ on Gnome, Windows
Forms / WPF on Windows and Cocoa on OS X. I mean, the bindings for GTK and
Cocoa are state of the art as far as bindings go and on Windows .NET is just
native.

And some people scoff at the idea of building a specific interface for each
platform, but I never seen a Java desktop application that I haven't found
nauseating. Qt Jambi is the only hope you have for something decent, but kind
of sucks on OS X.

------
programminggeek
So, having written some Java games back in 2002 or so, I can say that Java can
be an pretty decent place for writing simple 2d games. That being said, there
are lots of more interesting alternatives now that I'm not sure if Java is the
way to go.

It isn't a BAD choice, but if I were an indie dev, I would look at something
like Torque2D or Torque3D, especially since those give you a nice set of tools
as well as a way to move to iPhone and consoles.

Also, if you want to get something off the ground fast, check out Corona from
Ansca Mobile or even something like the LOVE 2D engine, between the two you
can write your game in Lua, which is an awesome little language to write games
in.

There is also the option of HTML5 and JS if one were so inclined. Given that
everything seems to support HTML5 and JS now, once hardware catches up in the
next 2-3 years, that might be an interesting option for game dev across all
platforms.

Oh, and if you are going to do a 3D game, start with a good 3D engine and
toolset, otherwise you'll spend all your time building an engine instead of
building a game.

~~~
eropple
FWIW, Torque is pretty constraining. I find it awkward to use because of the
reliance on its own scripting system.

I miss the Kanji game engine. It was bought by Gogii and then never re-
released for developer licensing.

------
quanticle
>I once heard something that has stuck in my mind ever since: "servers are
cheap, programmers are expensive." In other words, you have to carefully
choose your battles: at what point is optimization worth a programmer's
sanity? Java might not be the fastest language, but it will keep you slightly
more sane than C/C++, and is usually worth the slight performance penalty.

But then, why Java? Why not a language that's even more high-level (like
Python, Lua, or Haskell)?

~~~
peteretep
This isn't the first time I've seen someone with experience only of a lower
level language get all aflutter when they first make a real attempt at using a
higher level languages.

At a contracting gig I had, one of the Java guys gave us a talk about Scala.
And OH MY GOD SCALA HAS MAPS and OH MY GOD SCALA ALLOWS FUNCTIONAL ITERATION
OVER LISTS. It was like his entire relationship to programming had changed,
and he had to tell the world.

I felt for the guy - he was clearly pretty excited about this - and it must
have been like a breath of fresh air for him. The talk didn't go down that
well though, as it was to the Perl team...

~~~
gavanwoolery
Heheh...I have used a number of different languages, from high level, like
Python, to very low level, like assembly, and everything in between -- and
pretty much messed with every paradigm at one point or another. I will readily
concede to not being an expert in any of them. Most of my game programming
experience has been performance-focused though (in HLSL/DirectX/C++), but I
have worked with high-level languages in other areas. I tend to see a lot of
hobbyists fall into this performance trap, and I am only trying to point out
the virtues of sacrificing a bit of performance. :) Java and Clojure may not
be the best choices, but having tried many languages I am passing them out as
a suggestion for consideration.

------
gavanwoolery
Wow...I did not expect to be picked up on Hacker News, I am honored! I agree
that established engines like Unity/UDK are probably your best bet for making
commercial games, but I am targeting hobbyists/hackers for the most part, who
typically like to build engines the hard (or stupid :p) way, from the ground
up.

------
astine
"First, let's be clear: I am speaking to anyone but console/mobile/AAA
developers here."

Well, if you're targeting mobile, and by 'mobile' you include Android, you
already have to use Java. You could use Clojure in this case as well, but
Clojure in my experience is too inconvenient on Android to be worth it (yet.)

~~~
itsnotvalid
Scala seems to be a little better to work with in this case.

I think he is just referring to iOS. However I have to disagree the author
that it's suitable for desktop GUI applications. I hate running Java programs
on desktops (may be except Eclipse), as they always take much more resources
than they actually needs, while still maintaining ugly interfaces all over
different platforms, or would require much more work for the developers to
solve issues with incompatibilities over different configurations of Java
installs. For GUIs, Java is _still_ (for since Swing was available) not the
choice.

~~~
astine
If you are writing video games, then you're not likely to be using the built
in GUI tools. I agree to an extent about the resources, but games almost
always use a lot of resources in my experience.

------
MichaelEGR
I commented on the linked articles in more depth regarding performance game
dev w/ Java. I see someone mentioned libgdx in a comment here which is
awesome. Also awesome to see mention of Slick. I'll just mention that I have
been working for many years developing a mature component oriented platform
for real time app & game dev in Java that spans J2SE & Android utilizing all
the language features of Java without sacrificing performance. I am barreling
towards initial release. It's called TyphonRT and a little more info is
available here: <http://www.typhonrt.org/> I'm aiming for an end of summer
release and I hope you might want to consider Java (w/ Scala) & TyphonRT for
you next project.. :)

------
dminor
If you're considering Java for an OpenGL-based game, I'd recommend looking at
LibGDX - you can target the desktop and Android all at the same time. Even if
you're only targeting Android, LibGDX speeds up the dev cycle quite a bit,
since you don't need to load to the phone as often.

------
extension
I gave up on Java for games because I couldn't find a way to do vector math
that was both clean and efficient. Basically, the options are:

Immutable vectors - loads of temporary heap objects

Mutable vectors - spaghetti data flow

Implicitly grouped primitives - horrible verbosity and repetition

And of course, there's no operator overloading.

There are potential solutions to this that could be implemented at the
language level e.g. stack objects or macros that expand to primitives at
compile time, but none of the other mature JVM languages seem to do any better
at it.

Say what you will about C++, but it lets you write code like this:

    
    
      vec4 lerp(vec4 a, vec4 b, float s) {
        return a + s*(b - a)
      }
    

that compiles to something efficient. With all the vector math that ends up in
my game code, I just couldn't live without this.

------
itsnotvalid
why don't you submit the original than this reprint? (besides the comments on
the new one)

[http://altdevblogaday.com/2011/07/06/why-you-might-want-
to-c...](http://altdevblogaday.com/2011/07/06/why-you-might-want-to-consider-
java-andor-clojure-for-your-next-project/)

------
Tanner
In case anyone is considering this and wants an additional level of simplicity
added to LWJGL, Slick is a great library for easy 2D graphics.
<http://slick.cokeandcode.com/>

~~~
resatori
Yes it is a great engine.

I am using Clojure & Slick2d for the Action RPG I am developing so I can say
Clojure is a great choice for games!

I even open sourced my game: (with video) <https://code.google.com/p/clojure-
rpg/>

You can play it here (older version , not so fun but works!)
<http://resatori.com/cyber-dungeon-quest-alpha-1>

------
pwaring
It's perhaps a bit old now (2005), but O'Reilly published a good book on Java
game programming if anyone is interested in the subject:

<http://oreilly.com/catalog/9780596007300/>

------
leeoniya
why is TL;DR at the bottom? /facepalm

~~~
z92
Even though this comment is getting down voted, it told me that there is a
TL;DR at the bottom. Therefore now I shall click the link and read the
original article.

