Yes, printing to a display device is *extremely* slow. It is not a complicated OS issue, but rather the nature of video displays. Let's do a little back-of-the-envelope calculation.
Let's assume you have a 60Hz display. (Your display will have higher or lower frequency, depending on the quality of your display and video hardware, but this is close enough.) So, to display anything, there can be a delay of up to 1/60sec, or approximately 17 milliseconds. In round figures, let's assume 10ms.
Your computer, if it is a 1GHz Pentium machine, typically executes about 1.5 billion instructions per second. So, in the time it takes to wait for a line of text to appear on your display, your computer can execute about 25 million instructions. Each line of code in a typical Java program requires roughly 100 instructions to execute, so this is very roughly about 250,000 lines of Java code.
Now, in actuality, your video hardware will have a large buffer, and so your program doesn't actually have to wait unless there is some direct feedback required from the user (so the user has to actually see something). But the basic point is that computers are very fast, and video displays are very slow. |