Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / What limits does Java have?

Author
Message
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 30th Sep 2010 07:13 Edited at: 30th Sep 2010 07:21
I've always thought of java to be a slow language, but after seeing minecraft, I realize I'm wrong.

The thing that surprised me was that it uses OpenGL to render the world. This makes me think - What are the limits of a java applet? I usually think of anything being run in the browser as slow, and not really with much hardware support, as far as the GPU goes (in my not so knowledgeable coderness).

What about things like OpenCL? I mean, I'm realizing now that theres the potential for some really powerful java applications to be run from the browser. Does anyone have any knowledge on this?

[edit]
also wuzzup with the legalities of the whole oracle vs. google thing?

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 30th Sep 2010 10:45
Java is inherently slow unless there's a JIT compiler. It's just it's nature. I've always had a bit of a problem with languages that run on a VM and have garbage collection. I think they tend to remove more features than they add! The again, it wouldn't be so easy to run it in a browser and on multiple platforms otherwise, haha.

Lets not forget that Minecraft might look like it might be a slow game, but with a tight enough implementation and good algorithms it will be quick enough no matter what.

"everyone forgets a semi-colon sometimes." - Phaelax
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 30th Sep 2010 14:43 Edited at: 30th Sep 2010 14:43
Java is not limited in the slightest, since it supports an interface to native code (JNI)

That's how Minecraft / GL work by the way - Minecraft relies on a JAR of a GL wrapper which links to native DLLs (different DLLs depending on platform but the code in the Java app is identical).

Which is also why using GL in this way provides very close to native speeds (although it depends on how much work the Java app does on top of drawing of course)

09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Aaagreen
17
Years of Service
User Offline
Joined: 4th Sep 2007
Location: City 17
Posted: 30th Sep 2010 19:50
Runescape (eurgh) now supports OpenGL or DirectX rendering.


I'd love to see things from your point of view but I can't get my head that far up my bum.
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 30th Sep 2010 23:40
Quote: "Runescape (eurgh) now supports OpenGL or DirectX rendering."


I don't get it... what does that have to do with this conversation?


Senior Web Developer - Nokia
Melancholic
15
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 30th Sep 2010 23:42
I think RuneScape is programmed in java is it not?


I can count to banana...
Aaagreen
17
Years of Service
User Offline
Joined: 4th Sep 2007
Location: City 17
Posted: 30th Sep 2010 23:45
Yeah, Runescape runs on Java. Therefore relevant, surely?


I'd love to see things from your point of view but I can't get my head that far up my bum.
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 1st Oct 2010 02:53
Quote: "Yeah, Runescape runs on Java. Therefore relevant, surely?"


I dunno, I've never tried Runescape so I didn't see the connection.


Senior Web Developer - Nokia
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Oct 2010 23:58
http://www.lwjgl.org/applet/
It seems like LWJGL is the way to go! I really want to make some online applets that have 3d graphics now

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 2nd Oct 2010 00:16
Well call me weird, but I don't want every single object I make to be on the heap. Some objects should be scoped, and some shouldn't. Allocating on the heap is slow, and garbage collection is slow. I would be very happy to use Java if I could do manual memory management.

"everyone forgets a semi-colon sometimes." - Phaelax
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Oct 2010 01:18
Quote: "Allocating on the heap is slow, and garbage collection is slow."


It may not be as quick as doing it manually, but it's very convenient.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 2nd Oct 2010 01:45
Maybe so, but I think it's worth it being a little more difficult so the end product is better. Manual memory management itself isn't difficult, though admittedly learning it is. Still, it's better to learn it rather than making an entire new system that takes away your responsibility to do so.

"everyone forgets a semi-colon sometimes." - Phaelax
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Oct 2010 01:53
Quote: "Maybe so, but I think it's worth it being a little more difficult so the end product is better."


Better how? Many applications won't benefit from the minor performance you gain, versus the reduced development & maintenance time, as well as increased stability.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 2nd Oct 2010 01:59
Faster :p

Fair enough, not all applications you write are time-critical, but if you want a flexible language, it should be able to do well with all applications. As far as I know, the amount of extra time spent in doing manual memory management is negligible, and maintenance? You only need maintenance if you're code is buggy, which is an error with the object between the keyboard and the chair, not the programming language. Again, same with stability.

Now, if Java gave you a choice, where you could either use garbage collection or do manual memory management for time-critical applications, that would be good. I believe the D programming language allows you to do this.

"everyone forgets a semi-colon sometimes." - Phaelax
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Oct 2010 02:11 Edited at: 2nd Oct 2010 02:12
Quote: "As far as I know, the amount of extra time spent in doing manual memory management is negligible, and maintenance? You only need maintenance if you're code is buggy, which is an error with the object between the keyboard and the chair, not the programming language. Again, same with stability."


If you're writing something complex (especially using multithreading) and you have a lot of resource sharing going, sometimes with mutual references, you're going to be spending a certain amount of time making sure you are correctly freeing resources when you are supposed to, as well as writing specific code for exceptional references (mutual references, for example). Yes, if you're a good programmer the chances of such mistakes might be lessened but even a genius can make mistakes sometimes.

As far as maintenance goes, if you have anyone working with you you have to make sure they understand the resource handling just as well as you do. Not only that, but if you come back to the project after several months you'll have to remember exactly what is going on, too.

As I said, the benefit (ie. slightly increased speed depending on the application) isn't really so great for things such as word processors, web browsers, calculators, and other regular applications. At least, not so great that I'd bother to do manual memory management if I could choose to use auto.

Oh, and if you're writing modular code every module has to be aware of how the resource handling works if it needs to share any such resources.
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Oct 2010 03:28
The biggest thing that bugs me about java is no operator overloading... That makes math stuff a HUGE PAIN IN THE BUTT! Bah. I need to write a script that will unwrap something like:
d=(-b+(b^2-4*a*c)^(1/2))/(2*a)
to
d=((b.negate()).add((b.multiply(b)).subtract(a.multiply(c).multiply(4))).pow(1/2)).divide(a.multiply(2))
lines like that make me cry inside :\
That might not even be correct... I think it is :S
If all those were... I dunno, vectors or quaternions or matrices or god knows what, you'd have to write a line like that... and I like creating and using data types like that! >.>

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 2nd Oct 2010 15:16 Edited at: 2nd Oct 2010 15:20
Quote: "You only need maintenance if you're code is buggy, "


Face palm on two accounts:

- Unless you write perfect code (which you don't, nor does anyone) 'if your code is buggy' is going to be all the time

- This is just flat out wrong. Maintenance is often not bug fixing, it can be performance fixes, usability changes or even just maintenance done for the sake of readability / proper refactoring

I know this because I'm currently at the end of a maintenance 'cycle' for a system I wrote back in 2008. 99% of the things I have changed are not bug fixes (unless you consider performance a bug, but personally I don't)

Quote: "The biggest thing that bugs me about java is no operator overloading... That makes math stuff a HUGE PAIN IN THE BUTT! Bah. I need to write a script that will unwrap something like:
d=(-b+(b^2-4*a*c)^(1/2))/(2*a)
to
d=((b.negate()).add((b.multiply(b)).subtract(a.multiply(c).multiply(4))).pow(1/2)).divide(a.multiply(2))
lines like that make me cry inside :\"


Are all those numeric datatypes? Because Java does a thing called 'auto boxing' / 'auto unboxing' were it can work on an object form of a number (Integer) as if it were the more 'primitive' version (int) so you can in fact just use normal operators (* + - /) on them

09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Oct 2010 18:55 Edited at: 2nd Oct 2010 18:57
Quote: "Are all those numeric datatypes?"

nope - like I said, if each of a, b, c, and d, were weird custom datatypes (that can still be treated algebraically), then a statement like that pretty much becomes necessary... The problem is that I like using a computer to do things that require large mathematical statements on things like complex numbers or quaternions. (like, simplifying the matrix [[a,b][c,d]]^n if you get my notation - you end up with a big equation that took like 60 lines in procedural-style function(result,a,b) format, and I gave up before I got a working version with java)

[edit]
in other news I compiled a lwjgl applet.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 2nd Oct 2010 20:14 Edited at: 2nd Oct 2010 20:14
Quote: "nope - like I said, if each of a, b, c, and d, were weird custom datatypes (that can still be treated algebraically)"


Oh right. You mentioned vectors and quaternions but you didn't say your example was actually one of these calculations

09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
marlou
16
Years of Service
User Offline
Joined: 17th Jan 2009
Location:
Posted: 4th Oct 2010 03:43
Hi NeuroFuzzy,
If you're into Java and 3D, you should take a loot at Ogre3D embedded in a webpage and also irrlicht in a webpage.
Also there is Copperlicht but WebGL isn't supported by commonly used browser versions.

When a person has nothing but a dream, can he dare to dream.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Oct 2010 13:05
The limit for Java is doing skies... hmm, I seem to have misinterpreted that saying.

Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Oct 2010 00:33
Java doesn't have unsigned data types... Hence why you can give items in minecraft -32768 damage, and they will last effectively forever

[b]
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Oct 2010 03:40
So use a larger data type. Reading and writing to streams will do unsigned types.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke

Login to post a reply

Server time is: 2025-05-23 12:51:27
Your offset time is: 2025-05-23 12:51:27