LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 10-22-2005, 10:12 AM   #1
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Question So, why not Java?


This is not only a question, but also a general wondering. Maybe I'm just being paranoid here, but I don't see Java and Open Source going so hand-in-hand together and I wonder, why not Java?.

I can see peoples typing fast now telling me two reasons:

1 - It's a proprietary language;
2 - It's slow;

While the statement number 1 is totally correct, saying that it's either a negative or a positve thing is very difficult to tell without using your personal point of view.

The second statement, "java is slow", is not much an issue today, in my honest opinion. Since 1.4 SDK, speed in java have got way faster. I found 1.5 to be absolutely fantastic, not only by the speed improvements, but also the syntax itself got nicer and has many new features on the API itself. You can google for Java and C++ comparisons and you will see it's not as bad as one may think, depending of the test, indeed.

You may even say that Java does not perform well in older hardware, but I fail to see that as an issue also. And for the record, not every application out there is created with older machines or speed in mind. Look at KDE... for example...

As many of you know, I love games, not only on the "playing" level, but also the "programming level", and there're not many games written in Java which are not silly applet card games. I would like to point this site for some great 3D Java games:

http://www.brackeen.com/home/scared/index.html

Please, try both Scare and Race3d. I've found a very interesting 3D FPS written using Java technology. I've downloaded and installed the demo and loved it. Kicks the heck out of many known games out there. The only problem that I've noticed is that the maps takes a bit too long to load. It could be because it's just a demo though, since the in-game performance is great.

Unfortunately, it's not possible to buy this game everywhere... or else I would have added into my cart

http://www.java.com/en/games/desktop/specforce.jsp

Worthy trying. I guess the demo is a Windows only installer. There're also some great ports of Quake 2 coded in Java flying the net. Worthy google for them too .

http://www.java.com/en/games/desktop/specforce.jsp

The advantages of using java in game programming are many. Off the top of my head, you get: Great API, well documented language, simple multi-thread, real OOP-oriented, auto-garbage collection, lots and lots of free tools and IDE's and don't forget portability.

And it's not that you can't use java with other API's, like OpenGL:

https://jogl.dev.java.net/

and if you really need optimizations, you can use HotSpot VM, since you can run parts of your game and application in native code during runtime. It's also possible to compile Java to machine code, with compilers as gcc (gcj), but that loses also the portability part. Some parts of Java are also native for every system. If you check the API hierarchy, you will find many "native" classes.

I would like to make clear that I'm no java programmer(yet). I'm taking a Java class and reading two books right now: Developing games with Java and Introduction to Java: Comprehensive Version, to fresh my memory since I read Java at school before, but years ago

To me, it looks like the only ones taking Java seriously today is IBM and other companies interested on the micro edition, as Nokia. Few applications out there are worthy mentioning. I like LimeWire, jedit and DrJava, but that's pretty much it. A lot of day-to-day tools could be written with it, as ftp-clients, instant messengers, IRC-clients, games, front-ends for a bunch of programs and the list goes on...

So, programmers out there: Why not Java? Or am I wrong and Java actually is more used then it looks like? If so is the case, please tell me, I'd love to hear it

Last edited by Mega Man X; 12-07-2005 at 07:37 AM.
 
Old 10-22-2005, 10:55 AM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"The second statement, "java is slow", is not much an issue today, in my honest opinion. Since 1.4 SDK, speed in java have got way faster. I found 1.5 to be absolutely fantastic, not only by the speed improvements, but also the syntax itself got nicer and has many new features on the API itself. You can google for Java and C++ comparisons and you will see it's not as bad as one may think, depending of the test, indeed."

Java is an interpretive compiler. Interpretive compilers are inherently slow because the source has to be compiled on every execution. A binary program will always run faster than the same source running on an interpretive compiler.

---------------------------
Steve Stites
 
Old 10-22-2005, 11:18 AM   #3
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Original Poster
Rep: Reputation: 65
Thanks jailbait for your input. However, I'm not trying to prove that Java is faster then C++ by any means (there're already a lot of java-natics out there trying to prove that, gheheh), but in some cases, it could be. Like, depending of the way you program an application (let's say a graphical one), the API you choose has more impact on the performance then the language, or even the compiler for that matter. I found QT applications to be slower then their equivalents in gtk, for example.

The way I see it, the reason why Java is not (apparently) well received by the Open Source community lies somewhere else besides Java "slowness". As I said, a hell lot of open source projects out there don't have low-end systems in mind, as KDE and QT-based applications...
 
Old 10-22-2005, 12:20 PM   #4
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
Java is my primary programming language for web applications or desktop applications even if I know how to code c++, vb, and .Net(C# and VB.net).

Java is a lot used in companies for web applications or desktop applications using java web start.

A this time i am trying to finish a java based xml editor http://xpontus.sourceforge.net/
 
Old 10-22-2005, 12:24 PM   #5
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Original Poster
Rep: Reputation: 65
Nice editor mrcheeks. I hope you get it done. Count on me if you need somebody to test it .

Out of curiosity, are you using an IDE? At school we used Bluej, but I not really liked. I like DrJava, but I had problems when running Swing applications (like, if I use an image on a button when working with Swing, the image won't be displayed) from inside the IDE. Netbeans is a bit too heavy for what I'm trying to do. So far, Eclipse is my IDE of choice.

Last edited by Mega Man X; 10-22-2005 at 12:25 PM.
 
Old 10-22-2005, 12:59 PM   #6
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Java has way too much stuff to protect you from your own stupidity. Garbage Collection and Strong Types are examples of this. Other bad things are that all methods are virtual, which means it has to look it up in the virtual function table, a slow operation. Java has no header files, which are so useful as mostly self-documention. Also, I hate the try-catch Exception system, it is so ugly and inefficient. Eclipse is the best IDE to use, but most of the tim I just use vim+javac for all my needs.

Last edited by tuxdev; 10-22-2005 at 01:02 PM.
 
Old 10-22-2005, 01:03 PM   #7
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Rep: Reputation: 50
Why I like and use Java:

1) I'm a web freak. I asked my dad for "something on programming" for christmas- he got me a HTML book. Java is just a progression, in my mind.

2) it was the language of the CompSci AP.

3) In my house, we have windows 98, 2000, MacOSX and linux running. run anywhere is cool.

the way I work while coding is this:
(on any platform, but mac currently)
drjava is my editor. really like it. use that to write and compile code. then java whatever in the cli.

titanium_geek
 
Old 10-22-2005, 01:05 PM   #8
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
Thank you. I fixing few bugs and working features for the editor.
I am using netbeans now with the apache maven plugin(mevenide). I started with a text editor to optimize the code+apache ant(compile, create jar, deploy).
I then moved to eclipse 2.X to 3.X but it started to freeze too often on my pc. When netbeans 4.0 was out i tried it and found it more responsive on linux/bsd. than eclipse.

Displaying icons in buttons is easy when you use the getClass().getResource(String image) syntax.
Assuming that the image icon.gif is located in the directory classes/mypackage/images/icon.gif, you would do:
Code:
java.net.URL url = getClass().getResource("mypackage/images/icon.gif");
javax.swing.ImageIcon icon = new javax.swing.ImageIcon(url);
javax.swing.JButton button = new javax.swing.JButton(icon);

Last edited by mrcheeks; 10-22-2005 at 01:07 PM.
 
Old 10-24-2005, 08:51 PM   #9
Four
Member
 
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
Java is good but here is what I don't like about it:
1. Its all classes, you can't have a function thats not in a class.
2. The names of files must respect its name in the file.

When I was writing this I thought I would have more reasons, but If java was changed like that I would use it more often

Other than that I like java, I can't really say much because I didn't do much programming in java.

One feature to really speed java up (But slows its startup greatly) take the compiled java code and further compile for the current machine. If that can happen it would be great, but I don't think thats even possible to do.
 
Old 11-10-2005, 02:26 PM   #10
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Original Poster
Rep: Reputation: 65
Quote:
Originally posted by Four
Java is good but here is what I don't like about it:
1. Its all classes, you can't have a function thats not in a class.
2. The names of files must respect its name in the file.

When I was writing this I thought I would have more reasons, but If java was changed like that I would use it more often

Other than that I like java, I can't really say much because I didn't do much programming in java.

One feature to really speed java up (But slows its startup greatly) take the compiled java code and further compile for the current machine. If that can happen it would be great, but I don't think thats even possible to do.
It uses classes for everything to keep as organized (from a OOP perspective) as possible. The code is so much clear that way. Simple inheritance and the use of interfaces and abstract classes makes the code not only easier to learn, but also to update. And you still can code in a procedural form, but that is against the language purposes...

Last edited by Mega Man X; 12-07-2005 at 07:35 AM.
 
Old 11-10-2005, 03:39 PM   #11
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
I do think I like gcj a lot cause having to run everything thru the VM is really annoying to me.

What I hate the most though is that a lot of the Exceptions are not really exceptional. If they just passed back null when it can't do something, then this code to figure out whether a function with a specified name is part of java.math package would be a lot simpler (only working with doubles here, fortunately).
Code:
public static boolean isMethod(String name)
{
   try
   {
      // check if it is a unary method
      Class[] sig={double.class};
      Math.class.getMethod(name,sig);
      return true ;
   }
   catch(Exception e1)
   {
      try
      { 
         // not a one parameter method
         // check if it is a binary method
         Class[] sig={double.class,double.class};
         Math.class.getMethod(name,sig);
         return true ;
      }
      catch (Exception e2)
      {
         // not a method
         return false ;
      }
   }
}
Passing back null on getMethod...
Code:
public static boolean isMethod(String name)
{
   // check if it is a unary method
   Class[] sig={double.class};
   if(Math.class.getMethod(name,sig)!=null)return true;
   // not a one parameter method
   // check if it is a binary method
   sig={double.class,double.class};
   return Math.class.getMethod(name,sig)!=null;
}
Of course, if they just included something like this in the API already, it wouldn't be necessary.

However, one of the nice things about java's GC is that to empty any collection, just set all the member vars back to null.
 
Old 11-10-2005, 06:03 PM   #12
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
On Java's binary portability: Sun designed it so Java programs would be run in many systems. It's a issue when the source isn't available, but it's gonna be slow... But with open source, why Java? Java is better suited for the web for this binary portability. The same API and language's goodies may be used currently through gcj, but speed is still an important issue! And as long as it is important, there will be further design into alternative ways. Java considerably slows the system. How many Java programs may be run in parallel? There's still no definite port of Java in the BSD world. See http://www.freebsd.org/java/
 
Old 11-12-2005, 02:30 PM   #13
aldimeneira
Member
 
Registered: Jun 2005
Distribution: Ubuntu
Posts: 132

Rep: Reputation: 15
I think too that Java is more suited for web tasks in the form of AJAX.
 
Old 11-14-2005, 01:15 AM   #14
Haystack
Member
 
Registered: Nov 2005
Location: Utrecht, Netherlands
Distribution: Gentoo, Ubuntu
Posts: 65

Rep: Reputation: 15
hmm.. java... I'm pretty new to Java. I decided in august this year to learn Java at university college because it's so widely used... But i don't see the pro's yet.
Java claims to be Platform-independent, which i think is not true... What's so independent about a language that depends on the Java-platform. The java-platform is huge.
And then that scary Swing-thing. I think it's very arrogant when a programmer uses another Look-and-feel as the OS does. When I use a program I want the buttons and stuff look the same as the rest of my system. Programmers should realize (OK i'm getting a bit extreme now) that grandma's are getting confused when a program acts like they expect.

And yes.. it's slow...
 
Old 11-14-2005, 03:59 AM   #15
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Original Poster
Rep: Reputation: 65
Quote:
Originally posted by Haystack
hmm.. java... I'm pretty new to Java. I decided in august this year to learn Java at university college because it's so widely used... But i don't see the pro's yet.
Java claims to be Platform-independent, which i think is not true... What's so independent about a language that depends on the Java-platform. The java-platform is huge.
And then that scary Swing-thing. I think it's very arrogant when a programmer uses another Look-and-feel as the OS does. When I use a program I want the buttons and stuff look the same as the rest of my system. Programmers should realize (OK i'm getting a bit extreme now) that grandma's are getting confused when a program acts like they expect.

And yes.. it's slow...
You can change Java's Look and Feel. Currently, Java supports 3 different look and feel:

- Metal
- Motif
- Windows

Windows style is just available in Windows, for obvious copyright reasons. Motif is pretty much the way things looks in Unix and Metal is the "default" Java look. Don't tell me that running a gtk application in KDE makes that application to look like a QT application, or vice-versa.

I could agree with you that Java sometimes is not so platform independent. But not in the way you put it. For example, I'm trying to run a little game I'm creating in full screen mode. For the ones interested, here is an early screenshot:

http://goto.glocalnet.net/torch/temp/x-wing.jpg

Works fine in Windows, but not quite in Linux or Solaris (I'm working on it though). The idea of having a the Runtime environment does, makes Java platform independent. That's exactly how everything works out there. How do you think Gimp can run on Windows or Mac? Because you've to install the GTK-libraries. It's the exactly same thing: It has to depend on something else in order to run .
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java plugin installed correctly for Firefox but not able to view any java applet tvn Linux - Software 10 04-15-2010 02:13 AM
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 03:04 AM
Web start java not working (java works fine) powadha Debian 5 06-05-2004 12:57 PM
Updated Java... now java apps dont work zidane2010 Linux - Software 6 05-04-2004 08:02 PM
2 Questions: java calling system commands? PERL vs Java? randomx Programming 28 11-28-2003 08:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 09:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration