Java

Do you like Java?

  • Yes

    Votes: 9 50.0%
  • No

    Votes: 4 22.2%
  • It's OK

    Votes: 2 11.1%
  • Never tried it, not going to

    Votes: 3 16.7%

  • Total voters
    18

mrchimp

Newbie
Joined
Jul 19, 2003
Messages
1,928
Reaction score
0
I just made my first Java app and I must say my experience with Java so far has been very good. Only haveing to reffere to one API is fantastic and the way java forces you to do certain things is brilliant. The documentation isn't half bad either, although it seams to presume you already know a programming language when it comes to a certain subjects.

As for speed which is why i have never used it untill now, I can't say it's that slow atall. I'm sure it's quite a bit slower than native code but java programs like Azureus never slow down or slow my comp down (even when gameing).

Anyway here's my program, I call it a parser but it's probably just a filter, I used the netbeans IDE which is pretty damn good too:

Code:
/*
 * FilerParser.java
 *
 * Created on 20 May 2004, 22:03
 */

package FileReader;

import java.io.*;

/**
 *
 * @author  Chimp
 */
public class FileParser {
    FileReader OpenIF(String PathN){ //Open Input File
        FileReader TextF = null;
        boolean rdy = false;
        try{
            TextF = new FileReader(PathN); 
        }
        catch(FileNotFoundException e){
            System.out.println("Input File Not found");
            System.exit(0);
        }
        try{
            rdy = TextF.ready();
        }catch(IOException e){
            System.out.println("Input File Can not be read: IOException");
            System.exit(0);
        }
        if(rdy == true){
            System.out.println("Input File is ready to be read");
        }else{
            System.out.println("Input File can not be read");
            System.exit(0);
        }
        return TextF;
    }
    FileWriter OpenOF(String PathN){ //Open Output file
        FileWriter TextF = null;
        try{
            TextF = new FileWriter(PathN);
        }catch(IOException e){
            System.out.println("Output File can not be opened");
            System.exit(0);
        }
        return TextF;
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        FileReader TextIF = null;
        FileWriter TextOF = null;
        FileParser FP = new FileParser();
        
        int FileS = 5000000; //Guestimate File size in chars with room to spare
        int Counter = 0;
        boolean EOT = false; //End of text
        TextIF = FP.OpenIF("c:\\E-mails.txt");
        TextOF = FP.OpenOF("c:\\mail.txt");
        char TextI[] = new char[FileS]; //array of characters, about 9.5mb in size
        char TextO[] = new char[FileS];
        try{
            TextIF.read(TextI);
        }catch(IOException e){
            System.out.println("Read Error");
            System.exit(0);
        }
        for(int I = 0, N = 0; I <= FileS; I++, N++){
            switch(TextI[I]){
                case ' ':{      //When a space is found it skips 6 chars to filter out the crap
                    I += 6;
                    TextO[N] = ';';  //puts a ";" in the space 
                    Counter++;
                    break;
                }
                case '|':{      // "|" indicates the files end
                    EOT = true;
                    break;
                }
                default:{
                    TextO[N] = TextI[I];  //Copy's the valid char
                    break;
                }
            }
            if(EOT) break;
        }
        try{
            TextOF.write(TextO);
        }catch(IOException e){
            System.out.println("Write Error");
            System.exit(0);
        }
        System.out.println("Text Parsed");
        System.out.println("File contains: "+Counter+" Emails");
        System.exit(0);
    }
    
}
 
Java rocks. I've been programming with it since January now. I'd say the documentation is much more than ok. It has a huge set of standard libraries that are documeneted very well. Naturally, Java is a little slower since it's compiled to byte code that the JVM translates just in time, but it really isn't that slow at all. It used to be, but that was before Java 2 (1.2; current version is 1.4.2_04 and 1.5 is coming relatively soon). Besides, with almost any application I would rather have the massive compatibility Java offers rather than a small performance boost. So you can do it 10% faster with C++? Have fun porting it to every OS, or running it on something that's not x86.

I use Eclipse.
:cheers:
 
We've been doing Java for the first year of our Computer Science degree. I have to say, it's a great language for learning OO style, and getting to know how programing in general works. The API sure helps alot, and the built in classes make it really easy to build something that serves a purpose and isn't just in the console after very little time with it. (Our first graphical program was 3 weeks into our first course...). However, Java is slightly limited, especially if you want to do something like, say, mod half-life... Guess it's time to move to C++.
 
Java is great for building GUIs, very easy to multithread, awesome network support, etc.
 
I must say, JAVA is awesome. Though I have experience programming in C and C++, I always find myself turning to JAVA to create a programme.

On the subject of using it for 3D-programming... it is said that C and C++ are better languages to do so (kinda been proven, looking at all those shiny engines :)), I would find it quite interesting creating a 3D world in Java, since it hasn't really been done yet (well, it has been done, though not on such a high scale as with C-language).

I sure hope Sun will restart investing more time & money in the Java3D API, once v1.5 comes out.
 
Indeed, there is one.

API's from SUN:
JoGL (OpenGL for JAVA)
JoAL (OpenAL for JAVA)
 
I don't get what's so great about it. It distances you from the low level language. Makes me feel like less of a programmer, and Sun has like 8000 different compilers that are slow as balls.
 
My first Java program was a nice little application but I deleted it long ago. I did most of my work in NotePad though and compiled it using my command prompt. I love have when theres an error Java point you to exactly where the problem is. On this old C++ Compiling program I had it only pointed you in the general area of where the error was, so you had to search for it. I like OO programming, you naturally I loved java. The fact that your java program will work on every OS on every computer is also a plus. I have a friend who hates java with a passion but thats because he sucks at coding in it. I feel however its a very nice language and its on the rise.
 
I'm using Netbeans 3.6 or Borland JBuilderX and I must say, none of these are slow.
Especially with the changes they've made recently I think they're quite competitive versus MS's Visual Studio .NET
 
Besides, with almost any application I would rather have the massive compatibility Java offers rather than a small performance boost. So you can do it 10% faster with C++? Have fun porting it to every OS, or running it on something that's not x86.
- psyno​

Instead of just deciding that 10% faster sounds like a good amount to prove your point, how about either (a) doing an speed comparison yourself or (b) find someone else's, repeatable, speed comparison. Either way your going to find a number considerably different than 10%.

Here are two repeatable speed comparisons,
1) A slightly outdated test (java 1.1.5, java 1.2, java 1.3 beta used... note 'Java 2' is java 1.4) using a bubble sort with varying data structures. C++ never does worse than twice as fast for like data structures, and using best data structures C++ is incredibly faster.
link :: http://verify.stanford.edu/uli/java_cpp.html

2) A recent test using java 1.4.2 (1.5 beta is the next, and latest, version). This test results in c++ being roughly twice as fast as java.
link :: http://cgi.eaglecentre.force9.co.uk/blog/archives/000314.php

Speed is not the only weakness of java. Java is horrible for development of large applications (100,000+ lines of code). System architectures are forced to be clumsy and difficult to develop/maintain/update. These problems are not noticable at all for small applications (0-10,000 lines) though.

As far as portability is concerned, java can't just run on any computer. The java virtual machine must be installed on the computer first. This is better, but not by much, than installing a c++ compiler on a computer and compilling source code. And just like the c++ compiler, the java virtual machine has to be rewritten for new instruction set architectures. And about running c++ on something that's not x86, C/C++ are compatable (have compilers written for) with many more processors than java is... so where is that comment coming from?

That being said java still has the strengths of built in security, simple network programming, and quick development of (simple) GUIs (though using the MSVC++ MFC editor is just as easy for creating GUIs).

The key thing is that no person in their right mind would write the front-end of a web based application in C++. And this is the true strength of java, the one place where java can beat C++ into a bloody pulp.

So don't dismiss either java or c++ completely because they both behave excellently when used for right job. Don't go and use java as a general purpose programming language to solve all your problems. Similarily don't use C++ as a general purpose programming language to solve all your problems (for example; fortran is far better than c++ for doing complex mathematical calculations, and no other language can compete with assembly for raw speed and efficiency).
 
As far as portability is concerned, java can't just run on any computer. The java virtual machine must be installed on the computer first. This is better, but not by much, than installing a c++ compiler on a computer and compilling source code. And just like the c++ compiler, the java virtual machine has to be rewritten for new instruction set architectures. And about running c++ on something that's not x86, C/C++ are compatable (have compilers written for) with many more processors than java is... so where is that comment coming from?

Your missing the point, Java has one API that works on all supported platforms and one file format. C++ has lots of cross platform API's but there not all the same quality or have the same support as the Java API, they don't all behave the same on different platforms either. I have tried and failed to use many of these API's (e.g GTK, FLTK...), alot of the time I couldn't even get them to compile. Not only that but the vast majority only deal with one aspect of application programing e.g GUI,Sound.

As for MSVC++ MFC I'v never used it, why? Because it's too damn expensive unlike netbeans which is free. When I get round to writeing a 100,000 line program I suppose I'll have to check it out but untill then I think I'll stick with Java . :dozey:

Don't get me wrong I do think C++ and it's standard librarys are much better than Java but it gets to you when the API you have been useing isn't compatible with STL unless you change some windows header files and the compiler is giveing you an error message that appears to written in latin. :rolleyes:
 
Back
Top