Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Is Java slow?

  • 01-08-2004 2:54pm
    #1
    Registered Users, Registered Users 2 Posts: 5,111 ✭✭✭


    Hey I was wondering what you guys thought about Java.

    Let me explain, I haven't touched programming since the advent of mainstream object orientated platforms, thus the highest level I have used is basic, (I know, I know), now I would very much like to get back into this whole thing as a hobby again, but dont know which platform to use.

    I have heard great things about Java, (its free, its directly web compatible, etc..) but I have also heard it is very slow. I know that a badly written programme leads to a slow programme, but Im not to sure about the whole thing and am not going to learn hoe to write Java if it is a crappy language, any advice?


Comments

  • Registered Users, Registered Users 2 Posts: 7,740 ✭✭✭mneylon


    Java per se is not slow, but if you write bad code it can be. The same can be said about any programming language.


  • Registered Users, Registered Users 2 Posts: 5,111 ✭✭✭tba


    Good, I figured as much, would it be a good starting point to get back on the ladder?


  • Registered Users, Registered Users 2 Posts: 1,375 ✭✭✭DoesNotCompute


    Compiled Java code is not run directly on a machine's architechture - hence the reason it's highly portable. "Write Once, Run Anywhere", or something like that. However the downside to this portability is that Java bytecode (i.e. compiled Java code) has to be run on what's called a "virtual machine", which is basically an abstraction of the actual machine on which the Java program is running. Every line of bytecode has to be interpreted by this virtual machine (and I'm pretty sure there's a security feature that examines each line of code to make sure it's not going to do something dodgy if it is run). It is the on-the-fly intrepreting that the virtual machine does that make Java code run so slow.

    So, basically, Yes, Java is slow, but with modern processors and caches, it doesn't really matter, IMHO.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    The primary reason that Java has been accused of being slow is most probably down to the fact that it requires a virtual operating system to execute. In particular on Windows based OS, this can lead to a bloated memory hungry JVM which will slow down the machine it’s running on.


  • Registered Users, Registered Users 2 Posts: 21,084 ✭✭✭✭Stark


    It's faster than other interpreted languages.

    I found Java applets on websites to be horrendously slow though.

    I also found Java Applications written using the Swing toolkit to be very slow. Applications written using the SWT toolkit are much faster and look like native applications, but you do lose some portability.

    The worst thing about running in a virtual machine is the virtual machine startup I find. Once the virtual machine is started up, you're unlikely to notice any slowness on modern machines. In fact, modern JVMs have hotspot technology so if parts of code are doing a lot of processing, these get compiled rather than interpreted.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    1.1 used to be slow for the technology that was around when it came out.

    The newer versions 1.3, 1.4, etc are not slow.

    Web Applets are the worst examples of java imho. Normal Applications, servlets are better examples.

    ... SWT might be faster because afair it makes native calls. But it depends on the machines as well. I don't have any machine which seems to show any serious slowness to java, but I have seen the same kinds of applications work slower on older machines. Where as the same machines might not show the slowness with a native application.


  • Registered Users, Registered Users 2 Posts: 5,111 ✭✭✭tba


    I'll give it a go then

    No doubt you will see me back again asking more questions


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    try eclipse.org . The IDE there is written in java, but you wouldn't know it.


  • Closed Accounts Posts: 423 ✭✭Dizz


    Can't beat a bit of slashdot for this...
    http://developers.slashdot.org/developers/04/06/15/217239.shtml?tid=108&tid=126&tid=156
    Benchmarks (ya know what they say about statistics ;) ) java (client and server JVMs) v's C++ both on i386 and i686

    Dizz


  • Registered Users, Registered Users 2 Posts: 491 ✭✭Silent Bob


    Java could be much faster than it currently is if Sun had decided to go with a register based virtual machine instead of a stack based one. There are many well known optimisations that can be performed on register based machines while stack-based ones have fewer available.

    Also, Java is the only environment I know of which can use up to 64MB of memory just to fork and exec an 'ls' process


  • Advertisement
  • Closed Accounts Posts: 1,669 ✭✭✭DMT


    Is there a Java compiler capable of making Windows executable EXE files?


  • Closed Accounts Posts: 423 ✭✭Dizz


    Is there a Java compiler capable of making Windows executable EXE files?
    Yup - gcj (java compiler from gcc) http://gcc.gnu.org/java/

    Dizz


  • Registered Users, Registered Users 2 Posts: 1,375 ✭✭✭DoesNotCompute


    Dizz wrote:
    Yup - gcj (java compiler from gcc) http://gcc.gnu.org/java/

    Dizz

    That kinda defeats the purpose of using Java, doesn't it? I mean unless you find C++ too hard to learn, I can't see the point in using a language that was designed to portable to compile native machine code... :rolleyes:


  • Registered Users, Registered Users 2 Posts: 7,740 ✭✭✭mneylon


    Applets are usually slow because they run client-side not server-side, so you have to download everything to your machine first.
    You can also find "interesting" problems with JVMs, as there are still some people writing stuff for the now defunct MS implementation (for example AIB's online business banking) which will refuse to run on Sun's JVM


  • Closed Accounts Posts: 423 ✭✭Dizz


    That kinda defeats the purpose of using Java, doesn't it?
    
    C'est vrai! But gcj has it's uses - nice fast builds of eclipse on linux... hell any platform gcc runs on actually. But yea if you are implementing systems I wouldn't rely on gcj - stick to your jvm of choice

    Dizz


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Dizz wrote:
    Benchmarks (ya know what they say about statistics ;) ) java (client and server JVMs) v's C++ both on i386 and i686
    Interesting study, however, I wonder if you'd get the same results for the other 90%+ that don't use Linux as their OS... :rolleyes:


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    That kinda defeats the purpose of using Java, doesn't it?

    Sure, if you assume that portability is always going to be one of the reasons someone has chosen to use Java for a given project.

    jc


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    bonkey wrote:
    Sure, if you assume that portability is always going to be one of the reasons someone has chosen to use Java for a given project.

    jc
    I think you should always code to portability. Not doing so, leads to bad habits and can be a serious headache when you do go to port. You also end up locking yourself into the current OS (Regardless if it is Win/Linux/etc).


  • Registered Users, Registered Users 2 Posts: 7,740 ✭✭✭mneylon


    Hobbes:
    Very true, but you'd be amazed/appalled at the number of references we find in peoples code to C:\ when they put their JSP/Servlets on our servers!
    Then they wonder why it doesn't work!


  • Registered Users, Registered Users 2 Posts: 27,370 ✭✭✭✭GreeBo


    blacknight wrote:
    Hobbes:
    Very true, but you'd be amazed/appalled at the number of references we find in peoples code to C:\ when they put their JSP/Servlets on our servers!

    Yikes, glad I dont have to use that code.

    Hardcoding anyone?

    Java is "too slow" if you are going to be using it for mission critical systems, for everything else it should be grand. Expecially if you are just trying to learn/get into it.
    As for IDE's, try intelliJ, they have an Early Access Programme that lets you use early verisons of releases and its the best IDE I have seen.

    I find Eclipse....annoying. :mad:


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 834 ✭✭✭fragile


    redoxan wrote:
    Java is "too slow" if you are going to be using it for mission critical systems, for everything else it should be grand.

    Depends what you are running it on ;) and mission critical is more to do with robustness/reliability/scalability which is where Java excels. Oracle is currently developing products that support Java across all tiers of its Network Computing Architecture, and I may be wrong here but aren't most of Novells networking apps Java based.

    The RTSJ(Real Time Specification for Java), which is currently a JCP proposal should see Java being used in more embedded safety and mission-critical applications in the future.

    tba, any of the following apps should demonstrate how Java performance has reached an acceptable level on any modern hardware - Azureus, IntelliJ IDEA, jEdit, Eclipse.


  • Registered Users, Registered Users 2 Posts: 384 ✭✭mrhappy42


    Dont forget the garbage cleaning can sometimes kickin and slow things down.

    Your question however is one of 'what should I start coding in again'...and assuming this is a hobby then Java is a good solution and will keep you busy especially when you get to working on the bean stuff and the web server stuff.

    However if you want to stay in the Windows domain and dont want to spend a lot of time setting up bits and pieces or just bored you could look at C# :-)


  • Closed Accounts Posts: 888 ✭✭✭themole


    well,

    to learn programming i still think C is easier.
    It lets you use as much as you know.

    To learn object oriented programming i do think Java is a good choice.
    It will be slower due to its interpreted nature, much in the way compiled C is slower than human written assembly, but its usually acceptable.

    The advantage with Java is that lots of people work on it and make the slow parts faster, anyway good luck and pardon my drunken late night post.
    ]


  • Registered Users, Registered Users 2 Posts: 491 ✭✭Silent Bob


    themole wrote:
    It will be slower due to its interpreted nature, much in the way compiled C is slower than human written assembly, but its usually acceptable.
    Firstly, Java is not interpreted, it is compiled but it is compiled to byte code, not machine code. This byte code is then run on a virtual machine.

    Secondly it is only in extremely limited circumstances that a human can write better machine code than a compiler. Compilers are capable of analysing entire programs and performing optimisations you would never even be aware of since you cannot retain that much information in your head all the time.


  • Registered Users, Registered Users 2 Posts: 597 ✭✭✭bambam


    A lot of java's slow perception is from its first outings years ago. These days java performance isn't really an issue. This has been helped due to efficient jvm's. Current jvm's like BEA's JRockit and Sun's own vanilla jvm have clever optimising tricks like Hotspot technology. These features analyses code on the fly and detect often executed portions of code. These sections are then compiled to native code. These vm's have other clever features like adaptive optimizing of code - performing inlining etc...

    On the point raised about garbage collection, please be aware that there are many algorithms available with the Sun VM to handle GC including asynchronous garbage collection. Granted it takes a bit of reading, but I see this as a required portion of a developers java tuning knowledge.

    As for performance, my current project is an Internet Banking software project, my last job was a project for a full suite of business software for a telecoms provider before that was another Internet Bank implementation. All these projects use J2EE on IBM websphere or BEA Weblogic, and of course were all Enterprise level systems servicing a lot of concurrent users.

    As for the concerns about interpreted languages, .Net code and java kinda get executed in the same fashion. .Net's runtime environment uses a Just In Time Compiler to convert the code to native code, this is not to far away from the model that java virtual machines uses.

    And of course, lest us not forget that sh!tty code can bring the best of architected environments to its knees!


    Hotspot info : http://java.sun.com/j2se/1.5.0/docs/guide/vm/index.html
    JRockit : http://dev2dev.bea.com/products/wljrockit81/index.jsp


Advertisement