• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

I can't be the only person to dislike Java...

Elledan

[H]ard|DCer of the Month - April 2010
Joined
Oct 18, 2001
Messages
15,913
So for a few weeks I've been programming in Java for the school course I'm following, and I'm finding that I'm running out of reasons why it might be a good idea to develop certain applications in Java.

First of all, 'write once, run everywhere' hasn't been true since the early 90s. Second, the VM is a real pig. Bloated, (relatively) slow and everything but elegant. I'd never thought I'd say this, but I'd rather develop in C# for .NET. I've heard that C# has better documentation as well.

*cough* sorry for the rant ^_^

My programming background is mostly in C/C++, PHP and some Perl and Python (a few small scripts), so I'm no stranger to OOP and weird language constructs. My main issue so far has been the documentation, namely the inconsistencies which exist between the two books (Java 2 in 24 Hours, Core Java 2), the official Java documentation by Sun as well as other tutorials and documentation provided by IBM, Sun and various sources on the internet. After spending around ten hours on AWT and Swing I've never produced so little result and felt such hatred towards a single library as with any other language.

Is Java really that different from C++, or is it only AWT/Swing which lacks proper documentation? Also, why use Java when you can use Python, Ruby or another interpreted language with a JIT-enabled runtime element?

Now if you'll excuse me, I'm going to write this application I've been working on so far in Python instead of Java so that I don't feel like I haven't done anything today >_<
 
That's so wrong it's funny ekliptikz.

Elledan, I'd highly recommend the book Hackers and Painters by Paul Graham, in which he goes in search of the perfect programming language and rags on Java pretty hard. You should program in whichever language that works best for you, that will enable you to get the job done correctly and efficiently, and is easy to maintain.

Java has been backed by a huge Sun marketing machine, which attributed to much of its growth. Companies jumped on the bandwagon, because of the attention, and because it became easier to find lots more Java developers than python and Ruby developers. I'm not saying Java is bad, but it's just one of many tools available for getting the job done.
 
As an Amazon Associate, HardForum may earn from qualifying purchases.
Do a search on monster.com for programming jobs. Half of them are for Java programmers. Like it or not, you've got to know it these days...
 
I don't see how Swing is that poorly documented. Sure if your trying to figure out how to use it by just reading the JavaDoc API, you'll have a hell of a time.

But this is why Sun created a set of tutorials to explain everything.

You can find it here: http://java.sun.com/docs/books/tutorial/uiswing/

What I found most informative is the how-to section: http://java.sun.com/docs/books/tutorial/uiswing/components/componentlist.html

Overall I feel that the standard classes for Java is well documented. I can't say the same for C++ STL and Window's API. With Java's standard classes you can do everything that found in C++ STL and Window's API and at the same time is better documented.
 
Pyrolistical said:
I don't see how Swing is that poorly documented. Sure if your trying to figure out how to use it by just reading the JavaDoc API, you'll have a hell of a time.

But this is why Sun created a set of tutorials to explain everything.

You can find it here: http://java.sun.com/docs/books/tutorial/uiswing/
I actually read through that tutorial already, but it only added to the confusion. I was reading IBM's and other tutorials at the same time and found a lot of inconsistencies, mostly in regards to setting up the window, I mean (J)Frame, and where (and how) to place components in that window. One of the books I mentioned (Core Java) was especially strange in that it suggested I should extend the JPane class, define my own paintComponent function and then proceed to put 'JButton button = new JButton' and such definitions in it.

Overall I feel that the standard classes for Java is well documented. I can't say the same for C++ STL and Window's API. With Java's standard classes you can do everything that found in C++ STL and Window's API and at the same time is better documented.
If I need to find something on C++, I look in 'The C++ Programming Language' by Bjarne Stroustrup himself and find everything about the STL I need in minutes. There aren't many libraries included with C++, so I just use the libraries I like and harass the developers about how to use it if their documentation isn't clear enough :)

I won't deny that being used to C/C++, PHP/Python, etc. has made me biased, but I was properly motivated when I started with Java, yet quickly lost this motivation with every new source I consulted showing yet another different way to do things.

Oh, and the 40+ MB (loaded into RAM) pig of a Java VM. I'm still not certain I'll ever be able to come to terms with that ^_-
 
Well I don't use any book references, only online ones. Maybe that's why I am having a hard time figuring out parts of the STL.

One of the books I mentioned (Core Java) was especially strange in that it suggested I should extend the JPane class, define my own paintComponent function and then proceed to put 'JButton button = new JButton' and such definitions in it.

Whoa! wtf!! I have no clue what they are trying to do...

Anyways, give me a example of something you want to see in Swing, and I'll code up the example. Everything is pretty simple.
 
To paraphrase the saying about dogs:
The more I get to know MSDN, the more I appreciate Suns documentation.

When you get the feeling for how things go together to get things done, the javadoc system they use is very useful. Until you get that far, it's a complete mess.
 
Everyone has their right to an opinion on what they like and dislike about languages but this is a forum for *civil* discussion on the topics of Webmastering and Programming. Please refrain from trolling with posts that do not cite concrete reasons for your opinion.

Now on topic: depending on your level of experience, you may find that having a copy of the
Source Code around to be very useful. :)

--KK
 
Well I've never coded in Java (flirted with the idea but the documenation was all inconsistent as mentioned) but from an end user perspective I'd say it sucks. My favorite BT client uses it (Azureus, my PVR app of choice also uses it) and theres no reason why Java should be taking up 60+ mb of memory (thankfully an update came out and now it's only 30mb :rolleyes: ) when only one app is using it.

So I thank you for not coding yet another app in Java. :)
 
Pyrolistical said:
Well I don't use any book references, only online ones. Maybe that's why I am having a hard time figuring out parts of the STL.
Oh, definitely. I use online references for C/C++ as well, and find that I often have to hunt around quite a bit before I find the information I'm looking for.

Whoa! wtf!! I have no clue what they are trying to do...
That was my reaction as well :p

Anyways, give me a example of something you want to see in Swing, and I'll code up the example. Everything is pretty simple.
Earlier I was attempting to construct something akin to Winamp's GUI, albeit somewhat simplified.

A rough layout:

A top menu which allows one to open a file and exit the application.
Below that a status display which shows things like 'stopped', 'playing', 'paused', etc.
Next to that a display containing the filename once a file has been loaded.
Below that three buttons, labeled 'play', 'pause' and 'stop'.
 
CrimandEvil said:
[..] theres no reason why Java should be taking up 60+ mb of memory (thankfully an update came out and now it's only 30mb :rolleyes: ) when only one app is using it.
Fortunately, when you load a second Java app, the Java VM doesn't suddenly take up lots more memory. Unfortunately, it's also bloated enough that no one in his right mind would write a small Java application for trivial tasks, such as an FTP or IRC client.

I found that when using Azureus I couldn't watch movies on the same system, as the video would lag. Using Eclipse felt about as graceful as dragging a large bag filled with bricks through thick mud.

Compare that to an app like BitTornado, of which I didn't even knew it was written in Python until I read it on the author's site :D

So I thank you for not coding yet another app in Java. :)
I can assure you, the pleasure is completely on my side ^_-
 
Alright, here is it. As I wrote this I realized knowing how to make the GUI is only half the battle. The other half is know how to connect everything and make your data/logic flow. Anyways, this is a fairly basic outline, but I hope you can understand it. To move on to the next step you'll need to learn about MVC or your whole app will look like spaghetti code.

My code may look bad, but once you understand how to do something, you will realize my code is the most compact way to express it.

winampclone9hk.png


Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class WinampClone extends JFrame {
    public WinampClone() {

        // set the title
        super("Winamp Clone");

        // pushing the little [X] in the top right corner exits the program instead of just hiding the frame
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        setResizable(false);

        setLayout(new BorderLayout());

        JMenuBar jmb = new JMenuBar();

        JMenu jm = new JMenu("File");
        jmb.add(jm);

        JMenuItem jmi = new JMenuItem("Play File...");
        jm.add(jmi);

        jmi = new JMenuItem("Play URL...");
        jm.add(jmi);

        jm.addSeparator();

        jmi = new JMenuItem("Open playlist...");
        jm.add(jmi);

        jm.addSeparator();

        jmi = new JMenuItem("Exit");
        jm.add(jmi);

        jm = new JMenu("Play");
        jmb.add(jm);

        jmi = new JMenuItem("Blah");
        jm.add(jmi);

        jm = new JMenu("Options");
        jmb.add(jm);

        jmi = new JMenuItem("Blah");
        jm.add(jmi);

        jm = new JMenu("View");
        jmb.add(jm);

        jmi = new JMenuItem("Blah");
        jm.add(jmi);

        jm = new JMenu("Help");
        jmb.add(jm);

        jmi = new JMenuItem("Blah");
        jm.add(jmi);

        setJMenuBar(jmb);

        // status icons
        add(new JLabel(">,S,||"), BorderLayout.WEST);

        // filename
        add(new JLabel("Song Artist - Song Title"), BorderLayout.CENTER);

        // buttons, uses inner class - common method with java guis
        add(new PlayerButtons(), BorderLayout.SOUTH);

        // makes everything as compact as possible
        pack();

        setVisible(true);
    }

    public static void main(String args[]) {
        new WinampClone();
    }

    private class PlayerButtons extends JPanel {
        public PlayerButtons() {
            super();
            // this is not need since FlowLayout is the default LayoutManager
            //setLayout(new FlowLayout());

            JButton jb = new JButton("Play");

            // an example of an action performed if you put the play button
            // also an explain of anonymous class, often used for actionlistners
            // you also use this method to add actions to JMenuItem(s)
            jb.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JOptionPane.showMessageDialog(PlayerButtons.this, "You pushed Play!");
                }
            });

            add(jb);
            add(new JButton("Pause"));
            add(new JButton("Stop"));
        }
    }
}
 
Elledan said:
First of all, 'write once, run everywhere' hasn't been true since the early 90s.

When was that ever true? In other words, what event happened in the early 90's that caused Java to no longer be WORE?

Elledan said:
Second, the VM is a real pig. Bloated, (relatively) slow and everything but elegant. I'd never thought I'd say this, but I'd rather develop in C# for .NET.

I think the URT ends up being smaller than the Java runtime, and I don't know about speed. But apps written for either VM platform are not exactly svelte compared to apps developed in native code.
 
Elledan said:
Unfortunately, it's also bloated enough that no one in his right mind would write a small Java application for trivial tasks, such as an FTP or IRC client.
Yeah, exactly. I love Java and having been programming in it since about 1996, and I would never consider writing something that trivial in it. I don't "dislike" sledgehammers just because I can't hang paintings with them; in fact, they're pretty handy when you need that extra power.
 
HorsePunchKid said:
Yeah, exactly. I love Java and having been programming in it since about 1996, and I would never consider writing something that trivial in it. I don't "dislike" sledgehammers just because I can't hang paintings with them; in fact, they're pretty handy when you need that extra power.
What 'extra power'? For big applications, is a JIT runtime really faster than native code written by someone who knows what he's doing, and compiled by a halfway-decent compiler? My experience with larger applications written in Java (Azereus, Eclipse, among others) point towards 'no'.


(did I just start an interpreted/bytecode vs native code debate? :eek: )
 
Pyrolistical said:
Alright, here is it. As I wrote this I realized knowing how to make the GUI is only half the battle. The other half is know how to connect everything and make your data/logic flow. Anyways, this is a fairly basic outline, but I hope you can understand it. To move on to the next step you'll need to learn about MVC or your whole app will look like spaghetti code.

My code may look bad, but once you understand how to do something, you will realize my code is the most compact way to express it.

http://img375.imageshack.us/img375/7298/winampclone9hk.png[IMG][/QUOTE]
Your code doesn't look bad at all. In fact, I like it :D

Once I get the hang of actionlisteners it shouldn't be that difficult (famous last words ^_- ) to write the non-GUI part.

Thanks a lot for taking the time to write this GUI for me :)
 
I like how nobody's even mentioned the fact that Java works across almost all platforms with the same code, which is probably one of the biggest reasons people are using it these days.
 
Elledan said:
First of all, 'write once, run everywhere' hasn't been true since the early 90s.

Minishark said:
I like how nobody's even mentioned the fact that Java works across almost all platforms with the same code, which is probably one of the biggest reasons people are using it these days.

Some quotes. :p
 
John Carmack said:
Write-once-run-anywhere. Ha. Hahahahaha. We are only testing on four platforms right now, and not a single pair has the exact same quirks. All the commercial games are tweaked and compiled individually for each (often 100+) platform. Portability is not a justification for the awful performance.

More quotes, I hate java simply for garbage collection and the interpreter.
 
Pyrolistical said:
Alright, here is it. As I wrote this I realized knowing how to make the GUI is only half the battle. The other half is know how to connect everything and make your data/logic flow.

Looks like that code does nothing more than build the UI and show the resulting window. What's the working set of the application?
 
mikeblas said:
Looks like that code does nothing more than build the UI and show the resulting window. What's the working set of the application?

There was never any intent to have a working app. It was just to show the basics of how to make a GUI using Swing.
 
http://www.jwz.org/doc/java.html :p

As for me, I don't like being forced into an OO-paradigm. I don't like memory management taken out of my hands (mind you, I was weaned on C and C++, pointers rock!). I don't like not having operator overloading.

Still, I have to use it, so I have to live with it. I gotta write a compiler in the language now.
 
Pyrolistical said:
There was never any intent to have a working app. It was just to show the basics of how to make a GUI using Swing.

Yes, I know. What's the working set when it runs?
 
mikeblas said:
Yes, I know. What's the working set when it runs?

I have no clue what you mean by that. Are you implying I made the full application, but is just showed the GUI code?
 
Pyrolistical said:
I have no clue what you mean by that. Are you implying I made the full application, but is just showed the GUI code?

The working set of an application is the set of all pages the application uses. In other words, it's the amount of memory the application uses for it's code and data, plus all the shared code it maps into its address space.
 
mikeblas said:
The working set of an application is the set of all pages the application uses. In other words, it's the amount of memory the application uses for it's code and data, plus all the shared code it maps into its address space.

Ah ok, my operating systems 101 is coming back to me now...

I don't exactly know how to measure the size of the working set, but task managers says java.exe is using 14,844 K of memory.

That includes the JVM though, so I wrote a small program that has nothing expect:
Code:
while(true);

And that program takes 6,300 K.

Therefore that small GUI uses 8,544 K.
 
Pyrolistical said:
Therefore that small GUI uses 8,544 K.

Thanks.

Arguably, it takes 14,844 kilobytes of memory, since it requires the JVM. Even using 8,544 kilobytes, you're using eight to ten times the memory that a similar program in C++ would require.
 
I am certainly no programmer, but I have to say that as a user I (and most of my coworkers) dislike Java. It seems we need a different version of the JRE for almost every app. Currently I have 5 loaded. Also, the newest version won't work for any of the apps we use. Finally, as brought up before, it hogs memory. If I get a bunch of different apps open at once (very common, since so many critical tools use it) my machine starts choking.
 
i hate java. ive programmed with it, and i prefer C++.

of course this is coming from someone who isnt particularly interested in computer science... id rather be programming microcontrollers than writing a GUI interface..
 
BillLeeLee said:
:eek:

I already decided that I don't like the lack of (function) pointers and Java's idea of strings, but I see that I've got a lot more nasty surprises waiting for me. I'm getting a headache just thinking how to circumvent those things.

As for me, I don't like being forced into an OO-paradigm. I don't like memory management taken out of my hands (mind you, I was weaned on C and C++, pointers rock!). I don't like not having operator overloading.
I find the lack of flexibility in Java compared to C/C++ completely astounding. Whether it's because it is determined to do everything the OO way, or simply broken I leave for the experts to decide, but I already miss the ability to 'dive under the hood', so to speak, and do fun stuff with arrays, strings, functions, etc. in combination with pointers.

Assigning memory with new and freeing it up with delete is only a problem if you're a sloppy programmer. It's like closing your braces: for every new there's a corresponding delete :)

Still, I have to use it, so I have to live with it. I gotta write a compiler in the language now.
So far I'm getting the impression that the majority of programmers who have ever worked with Java dislike it, but managers find it a wonderful addition to their 'buzzword'-collection :D
 
Back
Top