20

Ok, I know that most people say "java isn't slow these days, it just has a slow startup phase" but nobody can look me in the eye and tell me that using netbeans or eclipse or jedit is as responsive as say, visual studio or textmate, even after running for hours of "warmup" time. Oh, startup time is definitely a problem (cough eclipse) I'll admit, but I'm talking general responsiveness here. Jedit has a small noticeable lag when you resize windows, for example.

A reasonable apples to apples comparison would, I think, be jedit (or any java based text editor) versus TextMate, SciTE.

The question it really boils down to is "if netbeans/eclipse were rewritten entirely in C, with the same feature set, would you expect it to have the same performance characteristics as it currently does."

Any ideas?

And a few observations:

This simple swing-based editor [1] has very odd lags when you resize the window, but scrolling feels quite responsive. Also, with netbeans, when you start resizing, until you "stop" resizing the window it draws an ugly black background [4]. Perhaps swing refuses to do any refreshes while the window is being dragged?

Here is an simple swt simple text editor [2]. It is quite responsive to both dragging and scrolling.

Here is another simple (jface) swt editor [3]. It resizes so poorly I think it must be a bad fluke. I hope.

I've also noticed that notepad and visual studio tend to have show temporary white "blips" when they refresh (ex: when using page down through a very long document). swt and swing apps don't seem to ever have those extra white blips, so I'm wondering if they have some extra internal buffering or something. This could cause a small slowdown, perception wise

[5] is a related, but not quite the same, question.

My current guesses, based a little on the existing answers/comments:

  • Netbeans has just become bloated. Maybe there's something about editing java that makes editor creators go overboard? Maybe they don't optimize their editors for some reason?
  • Java editors use tons of RAM maybe that keeps things out of L2 cache?
  • Java editors edit java, so maybe they have to keep constantly calling out to, say, javac, which incurs the slow startup penalty over and over again each time?
  • SWT is an abstraction layer over native widgets, which maybe slow things down.
  • Swing has an awful resize refresh policy, which makes it "appear" slow.
  • Netbeans uses the client VM, so maybe it just isn't tuned for speed? (see also [6] which contains a link to another question with an answer that is a slew of parameters you can pass to netbeans to try and speed it up).
  • Swing/SWT appear to have fewer artifacts during scrolling than native windows apps. Perhaps this means they have buffering "helpers" to help avoid artifacts, causing perceived slowness since it doesn't refresh immediately.
  • Perhaps Java has no megalithic benchmarks, so maybe it is not optimized for that type of loads? Maybe there is some hidden inefficiencies.
  • Relatedly, maybe java can be "made to be" fast, but somehow the editor creators aren't using it efficiently ("the core library will save me speed-wise!").
  • Maybe it just "feels" slow since (at least netbeans) has to constantly call out to new java instances to run debuggers, etc., which each take their own slow startup time hit.

Thanks! -roger-

[1] http://www.picksourcecode.com/articles/explan.php?id=6c9882bbac1c7093bd25041881277658&ems=9a0fa83125d48ab7258eab27754dd23e&lg=10

[2] https://gist.github.com/972234

[3] http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/BasicEditor.htm compile/run it like java -cp .;swt\win32.jar;jface/* BasicEditor

[4] http://twitpic.com/4xi8ov

[5] Is Java really slow?

[6] is there a way to make netbeans use the hotspot server vm

Community
  • 1
  • 1
rogerdpack
  • 62,887
  • 36
  • 269
  • 388
  • 1
    I'd guess it has to do with the performance of Swing/AWT. – Rafe Kettler May 13 '11 at 21:00
  • How is a comparison with TextMate relevant? I cannot speak of Eclipse, but I must say I find Netbeans to quite snappy. – melkamo May 13 '11 at 21:00
  • I second that - Eclipse runs pretty fast, but it's using SWT – dfb May 13 '11 at 21:01
  • It's not because of Swing or SWT. That idea has been beaten to death for so long, someone needs to bury it. – Edwin Buck May 13 '11 at 21:03
  • 4
    I don't think comparing "UI snappiness" over different programs is a good way to measure language speed. Are you sure jedit to notepad and Visual Studio to Netbeans / Eclipse is really an apple-to-apple comparison? I like Visual Studio very much, but even with ReSharper you really can't say the two IDEs are doing the same thing (at least in terms of live code analysis). I'm not saying that there isn't an overhead for using a abstract and SO independent High Level GUI toolkit, versus, for example native SO gui toolkits. Just saying that this kind of analysis is very subjective. – Anthony Accioly May 13 '11 at 21:42
  • I've never found Eclipse slow or unresponsive after it starts. Are you running it on decent/modern hardware with enough RAM? Eclipse is a pretty big application and needs plenty of RAM. – mikera May 14 '11 at 13:36
  • eclipse does feel a bit faster. I almost wonder now if the problem is that eclipse/netbeans become bloated over time... – rogerdpack May 14 '11 at 17:30
  • 1
    @rogerdpack: it's mainly because as much as Java **can** be made to be nearly as fast (and sometimes faster) than C, most Java programmers don't know how to do it. Most Java programmers don't understand why *Map{Integer,Long}* is an issue. They think: *"Java is fast"*, *"the default Java collection rocks"*, *"wrapper classes and auto-(un)boxing is fast"*, etc. They don't realize every object they create does have an impact on perfs. They don't realize every regular API they're using was designed by people having the same utterly bogus thought process *(more to come)...* – SyntaxT3rr0r May 17 '11 at 20:09
  • 2
    @rogerdpack: These programmers think *"lets buy more CPU on the server"*. They don't realize that optimizing on the client-side means times **millions** of cycles saved, on every people running the software. However some **do** understand that. For example *TIntLongHashMap* **owns** a Java map as you have no idea. And some IDE authors do understand that. For example the snappy and fast and Eclipse-owning IntelliJ IDEA is using, guess what, Trove. That's just one example. Basically it's an entire culture *"Java is fast"* spread by people not understanding how Java can be made to be fast – SyntaxT3rr0r May 17 '11 at 20:12
  • See also http://programmers.stackexchange.com/questions/368/why-do-people-still-say-java-is-slow (mentioning it just because its first answer is funny :) – rogerdpack Nov 04 '13 at 17:21
  • Regarding the long startup time of IDEs, at least in NetBeans it seems to be disk I/O operations and not Java itself. With NetBeans on an SSD it always opens within 5 seconds. – Tuupertunut Dec 13 '16 at 14:11

4 Answers4

8

To do all of that "on the fly" code syntax checking and highlighting, you basically have to write your editor to understand (that means lex, parse, type check, syntax verify, etc) the java language and verify the contents of the text editor during every intermediate state between you starting off with a nearly empty class and finishing your program.

Also for cross reference integrity, you have to hold enough information about all the other classes in memory so you can really make sure that when you call a method on an object, it really exists on that "other" object.

That's not to mention all of the other places where items are indexed, etc.

In short, it's slow because it's doing a lot, even if all of the stuff it is doing isn't immediately appreciated by a person who is only concerned with the letters on the screen (and not all the features of the IDE).

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
  • To the downvoter, the entire navigation tree (which references even the methods and attributes of the class) requires constant updating as you add classes, methods, and atrributes. For a normal text editor, such a navigation tree doesn't even exist. For a normal file indexer, such a tree doesn't delve into the class's inner details. All of those navigation nodes cost something in memory footprint, and the parsing of files / updating of the navigation links are all overhead compared to a regular text editor. – Edwin Buck May 13 '11 at 21:09
  • 4
    You've answered why an IDE for a particular language is slow, not why one written in Java is slow. I don't think the OP is specifically talking about IDEs or Java editors in particular, just editors written in Java. I haven't used jEdit in a while, but even just editing raw text, it seemed less responsive. – dfb May 13 '11 at 21:11
  • 6
    Can you actually point to an IDE that's as feature-ful as Eclipse or Netbeans in a language other than Java? Even VisualStudio doesn't keep up with all of the available features (or the inexhaustible ability to extend). For goodness sakes, people even extend / replace IDE components to shortcut the delivery of fat client applications. – Edwin Buck May 13 '11 at 21:13
  • 2
    How are people voting this answer up as useful? It totally misses the question! – John Y May 13 '11 at 21:14
  • You're still missing my point (which may or may not be the OPs, feel free to chime in here). Compare jEdit to Notepad, what *specifically* (Window toolkit? Native code compilation? ...?) makes it appear less responsive. This has nothing to do with VS vs Netbeans in my opinion – dfb May 13 '11 at 21:16
  • 1
    My point is that you are assuming that jEdit and Notepad do exactly the same thing, which they don't. One has many more features than the other, and whether you personally value those features or not, you pay for them in responsiveness. – Edwin Buck May 13 '11 at 21:18
  • Fair enough, but, because we have no way of comparing apples to apples in this manner, I don't think that covers other possible explanations without more information on the performance individual aspects. What makes you say that the e.g., windowing toolkit has nothing to do with this. – dfb May 13 '11 at 21:21
  • 1
    John Y: the explanation is a good description of a believable mechanism for a rather vague generic problem that is hard to put one's finger on. Certainly that's why I've given it a vote. I've almost given up on a vendor's website because they went all jazzy, and slooow. – Philip Oakley May 13 '11 at 21:21
  • 1
    @Edwin Buck: Fine, Notepad doesn't do as much as jEdit. Try comparing the real-world performance of jEdit with similar editors written in other (fully compiled ahead of time) languages, like SciTE, PSPad, or Geany. – John Y May 13 '11 at 21:50
  • 1
    @Philip Oakley: If the original question had been "Why are full-featured IDEs slow?" then yes, the answer would actually be good enough to get an upvote from me. But the actual question is "Why are applications written in Java (seemingly) slower than comparable applications written in other languages?" This answer says absolutely nothing about that. – John Y May 13 '11 at 21:54
  • @John Y. The point is precisely that comparing two "similar" programs is not a good way to determine if one language is faster than the other. The only way of measuring "UI snappiness" would be to write two identical text editors using the same algorithms and techniques for the job... And even doing that would produce very subjective results. @Edwin pointed that out, that's why I up voted his answer. – Anthony Accioly May 13 '11 at 22:04
  • @Anthony Accioly: Where in Edwin's answer does it point out that "comparing two similar programs is not a good way to determine if one language is faster than the other"? Where in Edwin's answer does it point out that "results are subjective"? Please read his answer. It says "An IDE *is* slow, because an IDE is doing a lot." – John Y May 13 '11 at 22:17
  • @John At the other halve of the phrase you quoted "even if all of the stuff it is doing isn't immediately appreciated by a person who is only concerned with the letters on the screen (and not all the features of the IDE)." To the good listener, half a word is enough. – Anthony Accioly May 13 '11 at 22:23
  • If there's a java based editor out there that's as fast as TextMate/SciTE for both scrolling and resizing please mention it so I can learn of its existence, though this is a good answer for why netbeans itself is slow, per se. I just wonder if netbeans were completely rewritten in C, with the same features, would it show the same performance characteristics? – rogerdpack May 14 '11 at 15:28
  • @rodgerpack, do you really think that text editors scroll and resize at the speed the machine is capable of executing? Such actions have built-in delays so the text won't scroll off the screen faster than you can read it. You seem to associate UI responsiveness with programming language, but you haven't made a case that the two are actually related. – Edwin Buck May 16 '11 at 16:32
  • -1 Everything mentioned in this answer could be done in a background thread to avoid making the UI lag. – Casey Rodarmor Sep 14 '13 at 16:16
  • @rodarmor Nobody said anything about UI responsiveness. He could easily be complaining about some other aspect, like code highlighting for compiler / stylistic errors. – Edwin Buck Sep 14 '13 at 19:21
3

This doesn't directly answer your question but here's some more info regarding window toolkit benchmarks

It is hard to give a rule-of-thumb where SWT would outperform Swing, or vice versa. In some environments (e.g., Windows), SWT is a winner. In others (Linux, VMware hosting Windows), Swing and its redraw optimization outperform SWT significantly. Differences in performance are significant: factors of 2 and more are common, in either direction. Code written in C/C++ using the X library performs somewhat faster than code written in Java using SWT, with the speed-up being from 5% to 10%

Source http://pub.cosylab.com/CSS/DOC-SWT_Vs._Swing_Performance_Comparison.pdf

dfb
  • 13,133
  • 2
  • 31
  • 52
0

Perhaps java uses more memory typically (at least, in my experience it does, and the alioth benchmarks seem to agree...

Please be careful not to confuse differences in default memory allocation with differences in Memory-used when the task requires programs to allocate more than the default memory.

regex-dna, reverse-complement, binary-trees, k-nucleotide, mandelbrot require allocating memory.

Also notice that some of the programs are written for multicore and allocate additional buffers to accumulate results from multiple threads.

igouy
  • 2,547
  • 17
  • 16
  • Agree. At first I was wondering if maybe Java's memory characteristics prevented it from using L2 cache as effectively, but my guess is that it does, so I removed the comment. – rogerdpack May 14 '11 at 15:37
0

Perhaps you're confusing 2 different things:

  • "java isn't slow these days, it just has a slow startup phase"

JVM operates as a byte code interpreter until hot methods have been identified, and only then compiles them to native code.

For the -server VM configuration (which may be the default on your hardware) methods are not compiled until the number of method invocations/branches is > XX:CompileThreshold=10000

  • even after running for hours of "warmup" time. Oh, startup time is definitely a problem (cough eclipse)

Even after running, say Eclipse, for hours do you think you've used the same method 10,000 times? (Try starting your Java editor using the -client JVM flag.)

Eclipse is a large IDE - it really isn't a basic text editor - maybe it's just trying to accomplish a whole lot more when it starts up than a basic text editor is trying to do?

igouy
  • 2,547
  • 17
  • 16
  • interestingly, netbeans uses the client VM by default, so I suppose I could say netbeans "could" get faster after a warmup phase but chooses not to? – rogerdpack May 17 '11 at 19:39
  • @rogerdpack - You still seem confused about "warmup". You seem to keep confusing the JVM transition between interpreting byte code and compiling to native code, with your perception of how quickly UI events happen. Your perception of how quickly UI events happen has a lot to do with how well the programmer distracted you from noticing, rather than how long those events actually take. – igouy May 19 '11 at 16:25