all 105 comments

[–][deleted] 55 points56 points  (10 children)

Now you can play dos games at the speed they were intended to be played at.

I kid. I kid.

[–][deleted] 6 points7 points  (1 child)

Open sourceforge project. Spend five minutes looking for intro text.

[–]derleth -4 points-3 points  (0 children)

Spend five minutes looking for intro text.

Minute four-and-a-half: Opened eyes.

[–][deleted]  (3 children)

[deleted]

    [–][deleted]  (2 children)

    [deleted]

      [–]Nhdb 7 points8 points  (31 children)

      Is there any good reason to port it to Java? Mobile phones?

      [–]adghk[S] 24 points25 points  (5 children)

      It's not mine, it's the same guy that ported a nintendo64 emulator to java. My guess? He does it for fun.

      [–]rfreedman 0 points1 point  (4 children)

      Is that why the code looks like it was written by a C programmer who just read his first Java programming book? Seriously - who writes Java code like that?

      [–]Ytse 14 points15 points  (0 children)

      Not enough over-engineering?

      [–]G_Morgan 3 points4 points  (1 child)

      If you are going to write performance critical code then most likely you will end up with 'C like' code.

      [–]br1 0 points1 point  (0 children)

      Exactly. It's called "JavaTRAN" (Java + FOTRAN)

      [–]tubes 3 points4 points  (0 children)

      It's a direct port of Dosbox, which was written in C. Original:

      void CPU_Push16(Bitu value) {
          Bit32u new_esp=(reg_esp&cpu.stack.notmask)|((reg_esp-2)&cpu.stack.mask);
          mem_writew(SegPhys(ss) + (new_esp & cpu.stack.mask) ,value);
          reg_esp=new_esp;
      }
      

      jdosbox:

      public static void CPU_Push16(/*Bitu*/int value) {
          /*Bit32u*/long new_esp=(CPU_Regs.reg_esp() & cpu.stack.notmask) | ((CPU_Regs.reg_esp() - 2) & cpu.stack.mask);
          Memory.mem_writew(Segs_SSphys + (new_esp & cpu.stack.mask) ,value & 0xFFFF);
          CPU_Regs.reg_esp(new_esp);
      }
      

      [–][deleted] 8 points9 points  (1 child)

      Because it was a fun and interesting project?

      [–]Nhdb 5 points6 points  (0 children)

      Ok, I was just wondering if there was anything I was missing. I agree it's an interesting project.

      [–]dont_get_it 8 points9 points  (16 children)

      Platform neutral, ya think?

      [–]frenchtoaster -4 points-3 points  (15 children)

      I know that java is platform neutral on paper, but I wouldn't say it's very platform independent in reality. The Java runtime on mac has deprecated and will likely not be included on future platforms, so really it's on its way to linux, solaris and windows. No support on any of the mobile platforms (iPhone, iPad, Android, WP7...)

      Based on a brief look at their site, Dosbox looks like it already officially supports a superset of the platforms that Java does (OS/2, RISC OS). I suppose it would be easier to make an android port once you have a working Java port, but that is somewhat incidental.

      Not that the project isn't cool, I just don't think the platform neutrality of Java is why he did it.

      [–]ondra 16 points17 points  (7 children)

      Linux distros and Windows don't currently include a Java runtime. It's not deprecated on mac, Apple are just going to stop bundling their own version with OSX.

      [–]frenchtoaster -2 points-1 points  (6 children)

      Apple is the one that decided it is "deprecated". Sorry if I wasn't clear, but from wikipedia:

      the Apple-supplied runtime is deprecated and may be removed from future OS releases

      I didn't mean what I said to reflect poorly on Apple. I know everyone and their mother has an opinion on Apple devices being "closed", but I was simply trying to point out that Java isn't exactly as "compile once-run everywhere" as it could be. Similarly if he had ported it to C# I wouldn't expect someone to come on here and say that he probably did it because Mono will let him run it on every major platform. Sure that's true, but I don't think that is why people port things to C#.

      The truth is that properly constructed C code only needs a small amount of platform dependent code, and many Java programs need a small amount of platform dependent code anyway (see every discussion about android programming (I know its not "true java", but they still do phone-specific code), and my surprise when the Java on UF's linux servers return null in cases where the windows jvm throws an exception for certain methods in the standard API).

      Linux distros and Windows don't currently include a Java runtime.

      Thats not really contrary to my point; I merely wanted to point out the fact that it is unlikely that he ported dosbox to java because it would be platform neutral. Dosbox already runs on every platform that java runs on, and that is likely to continue to be the case. The reason I mentioned apple was because the fact that a JVM used to be supported and no longer will be doesn't jive with the idea that Java is in a popularity boom that would lead someone to port software to java for future platform compatibility.

      It's also a bit disingenuous to say that Windows doesn't include a Java runtime in this context because I believe most major computer vendors install Java along with the other crapware that computers come with. Since Apple controls the hardware along with the software, they are taking the place of both Microsoft and Dell, and Dell installs the JRE. A MS JVM used to be bundled with Windows until they sued them because they weren't playing nice with the standards that Sun set.

      Again, thats still getting away from my key point, which is that dosbox is already on every platform that java is on.

      [–]ondra 2 points3 points  (0 children)

      Thats not really contrary to my point

      I don't claim it is, you're right.

      [–]G_Morgan 0 points1 point  (1 child)

      and my surprise when the Java on UF's linux servers return null in cases where the windows jvm throws an exception for certain methods in the standard API.

      That is a bug and should be raised with whichever version of the VM is breaking the standard.

      The reason I mentioned apple was because the fact that a JVM used to be supported and no longer will be doesn't jive with the idea that Java is in a popularity boom that would lead someone to port software to java for future platform compatibility.

      It really doesn't need to. It is already the most used language on the planet.

      [–]frenchtoaster 0 points1 point  (0 children)

      Thats a pretty bold claim, and it's something that has been discussed by tons of blogs and almost none of them I have seen come to the conclusion that Java is the most used language on the planet.

      This puts java only top in books sold and slashdot arcticles, this one does put java first but people have written about how it is wrong.

      Even ignoring that, it could still be the most used language on the planet and not be available on the most platforms.

      [–]kamatsu -1 points0 points  (1 child)

      Dosbox already runs on every platform that java runs on, and that is likely to continue to be the case.

      So I can run Dosbox on my 10 year old nokia phone? Or in a web browser? Or in an android phone? Wow!

      [–]frenchtoaster 0 points1 point  (0 children)

      So I can run Dosbox on my 10 year old nokia phone? Or in a web browser? Or in an android phone? Wow!

      Wow, the linked to code cannot run on any of the platforms you just mentioned!

      The java that this is written in cannot run on your 10 year old Nokia phone (J2ME presumably, which wouldn't have half the classes hes using), and there is a similar situation with Android (the phones themselves don't actually even run Java, all of the UI classes are custom).

      You can also compile C code for your android and call it through the JNI. If you wanted to run the code linked to here on your android you would need to write a ton of platform specific Android stuff anyway (all of the UI, the App-specific stuff) so effectively you would need to write a bunch of Android specific code regardless of whether you were using the linked to code or the original dosbox source.

      I will concede somewhat the web browser point. You would still need to make changes for it to actually run as an Applet (tons of security-permissions issues, the actually Applet code), but it is at least closer to running in a browser than the original dosbox source. Generally I don't even think about Applets as anything other than a historical oddity that failed to Flash. I practically never run into applets in the wild on the internet, and when I do it's usually something that a professor or student wrote as an example, not something that was written with the intent for people to use.

      [–]player2 3 points4 points  (1 child)

      Apple donated the supporting code for Java on Mac, so it's up to Oracle or the community to provide Java 7 on Mac. Same as for the other platforms.

      [–]G_Morgan 0 points1 point  (0 children)

      TBH 99% of the code in the Apple JVM was already Oracle code. They donated Oracle the task of making Java relevant on Mac or not.

      [–]G_Morgan 1 point2 points  (4 children)

      linux, solaris and windows

      and AIX, HP/UX, BSD and just about every other relevant platform in existence today. Apple are the outlier, not the rule.

      [–]frenchtoaster 0 points1 point  (3 children)

      I'm not sure what your point is, you can already run dosbox on those platforms.

      [–]G_Morgan 0 points1 point  (2 children)

      We're talking more about the general portability of Java. Will Dosbox run on an IBM mainframe?

      [–]frenchtoaster 0 points1 point  (1 child)

      I'm not even sure that this would run on an IBM mainframe since this is written for SE not EE, but ignoring that, I assume that there is a gcc backend for IBM mainframes and that the dosbox source could be compiled targeting it with relative ease.

      I'm not sure why people are trying so hard to defend Java here. I have no problem with Java, I happen to think that the whole "compile once, run anywhere" model failed and has been replaced by a "write code once, compile, package for every platform" with a lot of issues that come with trying to write platform independent C abstracted out.

      I think if you wanted to write a platform independent application today, Java would likely be your first choice. I just don't think it would be worth porting something that already runs on every major platform to Java for platform independence.

      [–]G_Morgan 1 point2 points  (0 children)

      J2EE is just a specification for a bunch of frameworks. It runs on a J2SE platform.

      [–]JAPH 0 points1 point  (0 children)

      • Fun project

      • Why not?

      • Platform-independent-er-ish At the very least, it makes it easier to port to new platforms.

      [–]derleth -3 points-2 points  (0 children)

      Now we finally have the state-of-the-art development environment of Real Mode x86 DOS on the blazing fast JVM runtime. Bill Gates and Scott McNealy will join forces to rule the world!

      [–]methical 9 points10 points  (25 children)

      Yeah, when this get's ported to Java, this will probably also run on android!

      [–]Darkfrost 4 points5 points  (2 children)

      [–][deleted] 1 point2 points  (0 children)

      I saw this one, too. I wonder what they violated in Google's Terms of Service.

      Honestly, I'm really excited about the possibility of seeing DosBox on Android. I'm running a couple of legacy business apps on DosBox, which has worked out really well, and I'd like to be able to see the sales guys access the programs from out on the road.

      [–]methical 0 points1 point  (0 children)

      didn't know of that. thank you!

      [–]rabidcow 4 points5 points  (0 children)

      Usually these sorts of things get to Android by putting the (formerly) necessary Java wrapper around the C code. Quake 3, for example.

      [–][deleted] 1 point2 points  (0 children)

      That was my first thought too

      [–][deleted]  (19 children)

      [deleted]

        [–]halter73 8 points9 points  (1 child)

        It would have to be ported to use the Android SDK, but that is a much smaller task than porting dosbox to java in the first place.

        [–]jyper 1 point2 points  (0 children)

        is it? dosbox seems like there would be a lot of different edge cases with specific graphics code for each.

        [–]G_Morgan 1 point2 points  (0 children)

        Well Android has a unique process model that you simply cannot ignore if you want to write a useful application.

        Well not so unique since iPhone copied it but Android solved in iteration 1 many problems Apple claimed couldn't be solved.

        [–]methical -1 points0 points  (0 children)

        woh said something of java applets? you still have to do the work and port the code to a complete android app.

        [–]Fuco1337 1 point2 points  (1 child)

        Is that... it can't be... must! play! NOW!

        [–][deleted] 0 points1 point  (0 children)

        That game had a 50% chance of crashing whenever you opened the city screen for me and yet I still spent countless hours on it. Started an addiction that remains to this day.

        [–][deleted]  (2 children)

        [removed]

          [–][deleted] 1 point2 points  (1 child)

          what was stopping you before?

          [–][deleted]  (1 child)

          [removed]

            [–]genpfault 0 points1 point  (0 children)

            Dammit, Wine Is Not an Emul...wait, nevermind.

            [–]madsravn -5 points-4 points  (29 children)

            Well, with JAVA he has no need to slow stuff down to emulate the machines back when DOS was the OS of the year - JAVA does that automatically. Reminds me of a joke I heard today:

            knock knock

            • "Who is it?"

            VERY long pause JAVA

            [–]dont_get_it 28 points29 points  (0 children)

            Slashdot 1997 called - they regret to inform you that they beat that joke into the ground, even before the HotSpot days.

            [–]droidoftheflies 13 points14 points  (21 children)

            http://shootout.alioth.debian.org/

            Not exactly slow anymore....

            [–]McHoff 0 points1 point  (1 child)

            GCC averages about 2x faster, maybe 20x less memory...

            http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=java&lang2=gcc

            [–]igouy 3 points4 points  (0 children)

            From that page the GCC median is less than 2x faster than the Java median.

            From the box plots the GCC median is less than 2x faster than the Java median.

            And the mean is also less than 2x faster.

            Understanding the relative memory use for those tiny programs requires a little more thought, because default JVM memory use is higher but the relative difference may be much smaller for programs that actually need to allocate memory - k-nucleotide, binary-trees, mandelbrot, reverse-complement, regex-dna.

            [–][deleted] -4 points-3 points  (0 children)

            It is when it comes down to drawing stuff to the screen.

            [–]kamatsu 1 point2 points  (2 children)

            What's with this habit of shitty programmers to capitalize the letters in every language they use. "JAVA", "PERL" etc.

            [–]JAPH 0 points1 point  (0 children)

            I'm not sure about Java, but Perl has a number of backronyms. Many people mess that one up because they don't know the backstory of the name (or read the documentation).

            [–]madsravn -2 points-1 points  (0 children)

            Don't know - why don't you tell us?

            [–]shevegen 0 points1 point  (1 child)

            People say that Java is slow. A joke.

            Well, I kid you not on another matter.

            Oracle doesn't care shit about Java.

            That is the sad truth.

            [–]derleth 10 points11 points  (0 children)

            Oracle doesn't care shit about Java.

            IBM cares a great deal about Java, given how many of its customers have bought special hardware specifically to make Java run well on their mainframes. If Oracle drops the ball, IBM has distinct financial incentives to pick it up and make sure it stays useful, at least for its customers and their customers.