Author Topic: JVM vs something else  (Read 16443 times)

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
JVM vs something else
« on: February 17, 2012, 12:02:39 AM »
As of right now, portability is a big issue for me.  I'm working with OS X, but as far as I know, to create a Windows executable, I need to compile on a Windows compiler.  This is a bit difficult, as far as money and buying a emulator/operating system/etc.  I have thought of the Java Virtual Machine, but I was worried about overhead.  Is it going to slow the program considerably if I use a Java-based language?
{O.o}
 |)__)
   ” ”   o RLY?

george

  • Rogueliker
  • ***
  • Posts: 201
  • Karma: +1/-1
    • View Profile
    • Email
Re: JVM vs something else
« Reply #1 on: February 17, 2012, 01:21:49 AM »
Well overhead and slow are somewhat different. Java would probably use more memory than C++ for example but I don't think relative speed will be an issue, and the amount of memory it does use is probably not an issue either for most users.

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Re: JVM vs something else
« Reply #2 on: February 17, 2012, 04:19:05 AM »
Well overhead and slow are somewhat different. Java would probably use more memory than C++ for example but I don't think relative speed will be an issue, and the amount of memory it does use is probably not an issue either for most users.

Thanks, I was mostly thinking would the overhead (and extra memory) cause it to slow the computer down.  I just remember playing Minecraft and it running slower than Team Fortress 2.
{O.o}
 |)__)
   ” ”   o RLY?

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Re: JVM vs something else
« Reply #3 on: February 17, 2012, 06:04:22 AM »
Basically, unless you're crunching 3D graphics or some pretty intense 2D graphics, slowdown isn't really a thing.

TheCreator

  • Rogueliker
  • ***
  • Posts: 370
  • Karma: +0/-0
    • View Profile
    • Fame
    • Email
Re: JVM vs something else
« Reply #4 on: February 17, 2012, 08:29:03 AM »
I have never seen a single Java program that was running really smooth, no matter whether it was 3D or 2D. And it's not only the amount of memory used (C++ programs use a lot of memory as well), Java is just slow. However, if you don't have much C++ experience and you care about portability, Java is still a good choice.
Fame (Untitled) - my game. Everything is a roguelike.

XLambda

  • Rogueliker
  • ***
  • Posts: 208
  • Karma: +0/-0
    • MSN Messenger - tau_iota@live.de
    • View Profile
    • The Weird Rogue
Re: JVM vs something else
« Reply #5 on: February 17, 2012, 10:35:14 AM »
I have never seen a single Java program that was running really smooth, no matter whether it was 3D or 2D. And it's not only the amount of memory used (C++ programs use a lot of memory as well), Java is just slow. However, if you don't have much C++ experience and you care about portability, Java is still a good choice.

Bjarne Stroustrup once said: "There are only two kinds of programming languages: those people always bitch about and those nobody uses." I agree.

I don't know what kind of java programs you've run, but I've never had any problems. Sure, it's usually not as fast as native c++, but in my experience the difference is negligible, and rarely noticeable for most applications. And yes, Java applications eat more memory than c++ ones. That is a technical necessity, due to garbage collection and portability. However, you DO have garbage collection and portability to every system capable of running a JVM, plus easy and effective multithreading and networking. There ARE things I wouldn't use java for. Dedicated high-performance software, for example, or low-level stuff. Writing a game is not one of them.

Look, there is a reason why Thomas Biskup writes ADOM II in Java. The guy knows exactly what he's doing.  :)

TheCreator

  • Rogueliker
  • ***
  • Posts: 370
  • Karma: +0/-0
    • View Profile
    • Fame
    • Email
Re: JVM vs something else
« Reply #6 on: February 17, 2012, 11:43:42 AM »
I don't know what kind of java programs you've run, but I've never had any problems.

You probably own newest hardware available on market. I don't, so I'm really sensitive to performance issues and I can really tell whether they are negligible or not ;).

Quote
Look, there is a reason why Thomas Biskup writes ADOM II in Java. The guy knows exactly what he's doing.  :)

Even gods make mistakes ;).
Fame (Untitled) - my game. Everything is a roguelike.

XLambda

  • Rogueliker
  • ***
  • Posts: 208
  • Karma: +0/-0
    • MSN Messenger - tau_iota@live.de
    • View Profile
    • The Weird Rogue
Re: JVM vs something else
« Reply #7 on: February 17, 2012, 11:55:34 AM »
I don't know what kind of java programs you've run, but I've never had any problems.

You probably own newest hardware available on market. I don't, so I'm really sensitive to performance issues and I can really tell whether they are negligible or not ;).

Fact: I own an eight-year old rust bucket. ;D

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Re: JVM vs something else
« Reply #8 on: February 17, 2012, 07:27:10 PM »
Look, there is a reason why Thomas Biskup writes ADOM II in Java. The guy knows exactly what he's doing.  :)

On that note, are there any open-source roguelikes written in Java (or a Java-based language) that I can look at for reference?  It would be nice if they were well commented.
{O.o}
 |)__)
   ” ”   o RLY?

XLambda

  • Rogueliker
  • ***
  • Posts: 208
  • Karma: +0/-0
    • MSN Messenger - tau_iota@live.de
    • View Profile
    • The Weird Rogue
Re: JVM vs something else
« Reply #9 on: February 17, 2012, 08:54:20 PM »
Look, there is a reason why Thomas Biskup writes ADOM II in Java. The guy knows exactly what he's doing.  :)

On that note, are there any open-source roguelikes written in Java (or a Java-based language) that I can look at for reference?  It would be nice if they were well commented.

Well, slash has written a few using his libjcsi library (which is basically a swing-based curses with a native alternative included), I think you can grab the source for these from svn. There have also been quite a few 7DRLs written in java. There are no larger java-based RLs, as far as I know.  :-[

george

  • Rogueliker
  • ***
  • Posts: 201
  • Karma: +1/-1
    • View Profile
    • Email
Re: JVM vs something else
« Reply #10 on: February 17, 2012, 11:31:45 PM »
There are a decent number of engines and libraries too, I started another thread about that a little while ago. Unfortunately I haven't found anything that looked really nice yet, but I'm spoiled by libtcod.  :(

XLambda

  • Rogueliker
  • ***
  • Posts: 208
  • Karma: +0/-0
    • MSN Messenger - tau_iota@live.de
    • View Profile
    • The Weird Rogue
Re: JVM vs something else
« Reply #11 on: February 18, 2012, 01:03:48 AM »
There are a decent number of engines and libraries too, I started another thread about that a little while ago. Unfortunately I haven't found anything that looked really nice yet, but I'm spoiled by libtcod.  :(

I'm still waiting for someone to port libtcod to java. Yes, you'd lose portability, since you'd need to swap libraries depending on system, but it would be so awesome. JNI is pretty lame though, but JNA would be an alternative.

george

  • Rogueliker
  • ***
  • Posts: 201
  • Karma: +1/-1
    • View Profile
    • Email
Re: JVM vs something else
« Reply #12 on: February 18, 2012, 01:29:34 AM »
Whoa, JNA looks quite doable. It seems like you could even auto-generate the mapping.

When you say swapping libraries, do you mean for a version that used something like JNA? Wouldn't a straight port just work across all platforms with the JVM? Sorry, I'm pretty new to Java so I'm still getting to grips with it.

XLambda

  • Rogueliker
  • ***
  • Posts: 208
  • Karma: +0/-0
    • MSN Messenger - tau_iota@live.de
    • View Profile
    • The Weird Rogue
Re: JVM vs something else
« Reply #13 on: February 18, 2012, 02:24:51 AM »
Whoa, JNA looks quite doable. It seems like you could even auto-generate the mapping.

When you say swapping libraries, do you mean for a version that used something like JNA? Wouldn't a straight port just work across all platforms with the JVM? Sorry, I'm pretty new to Java so I'm still getting to grips with it.

JNA merely loads a native library (probably written in c++) , which is machine code for the platform it's compiled for. The actual computation using that library is AFAIK done outside of the JVM, since the VM can only execute java bytecode. To make it work on every JVM you would have to rewrite libtcod in java so it can be compiled to java bytecode.
So, if you wanted to port a java program using an imported libtcod to, say, linux, you would have to replace your libtcod-whatever.dll with the one compiled for your target system. It's a rather small change, and the rest of the code should still be 100% portable.

AgingMinotaur

  • Rogueliker
  • ***
  • Posts: 805
  • Karma: +2/-0
  • Original Discriminating Buffalo Man
    • View Profile
    • Land of Strangers
Re: JVM vs something else
« Reply #14 on: February 19, 2012, 09:50:38 PM »
On that note, are there any open-source roguelikes written in Java (or a Java-based language) that I can look at for reference?  It would be nice if they were well commented.

Legerdemain is written in Java. Don't know about documentation.

As always,
Minotauros
This matir, as laborintus, Dedalus hous, hath many halkes and hurnes ... wyndynges and wrynkelynges.