Amazing how easy it is to paste C code into Java. Takes surprisingly few adjustments to work. This applet demonstrates the “Rationalization” algorithm mentioned a post or two earlier.
Note 1: RiverLayout is a fine little LGPL layout manager which made this applet much easier than it would have been with the standard Java layout managers. All of which I hate, by the way. RiverLayout was exceedingly simple to use for this kind of basic stuff.
Note 2: I looked around at various other online math applets and found one thing in common about them all, which I hated, and that was that one had to press a “Compute!” button before the answer would be, aah, computed. So I omitted that antifeature from mine.



Nice work, David. “Compute” buttons are indeed the devil. Most people still don’t get it that computers are super insanemagifiicently faster than we can possibly imagine, and it’s best to just do everything “on the fly” until proven otherwise.
…And, I’m having a hard time thinking of a good “proven otherwise” situation. For example, Eclipse — in contrast to every other IDE I’ve used — initiates syntax checking as you type, and a full build whenever you save your file.
As long as it doesn’t interfere with the the user-interactivity, where’s the harm?
That’s exactly right. As long as it doesn’t make the task at hand take longer than the user would like, or steal too much power from the rest of the user’s tasks, then “it’s fine.”
Too many programmers have an unnecessary desire to preserve instruction cycles, as if they were in danger of extinction.
There are many situations where a “Go” button is desirable. Any operation that takes a significant amount of time should require explicit confirmation to begin. Obviously, simple math does not fall into that category. Complex math, like calculating the mandelbrot set, does (I once wrote a Java applet to do that as part of an intro to programming course. Yes, I gave it a “Calculate” button).
Hi Ryan — I would phrase the requirement vaguely as, “The program should do as much as it can automatically, as long as that doesn’t get in the way of the user.”
And one way I might interpret that for a mandelbrot generator is to, truly, begin calculations immediately for every input action… but halt them immediately, too, if new user input invalidates that work.
Amusingly, in my distant distant past I wrote a Mac program called “MegaBrot” which supported our company’s demo NuBus board which did exactly one thing: used 3 hardware multipliers to compute Mandelbrot iterations. It was fast then, but slower than any computer at CostCo today. I’m pretty sure it had a “Calculate” button, too. :-)
Oh dear… found a usenet posting mentioning it, even. Pardon the digression… your comment triggered a dormant neuron.