[rescue] slow java code...an example of why it might be happening

Joshua D. Boyd jdboyd at celestrion.celestrion.net
Tue Feb 11 15:16:20 CST 2003


On Tue, Feb 11, 2003 at 03:50:23PM -0500, Dave McGuire wrote:

> > It's not that the conceptual level is too high.  Writing slow code like
> > you example is just fine, for a prototype.
> 
>    I would *never* write a program that way, even as a prototype.  And 
> neither would you.

I wouldn't do that particular case, but I've done similar things when in
a hurry.  For instance, I've written code that loads a bitmap several
times into memory (while keeping all the other copies also), then worse
yet, loaded it into OpenGL (presumably onto the graphics accelerator) as
a texture object several times.  Why?  Because there was plenty of ram,
and plenty of texture ram, and I didn't want to take the time to make my
texture class keep a registry of whether a different instance has
already loaded the texture.  So, as I was loading the .3ds file,
everytime a model refered to a different texture than the one I was just
looking at, it would spawn a new texture object, thus loading everything
again.  

Of course, even if I was using C, it would have been just as easy to be
just as wastefull.  I do keep meaning to getting around to fixing that
little issue.  I believe that everyone who wrote any graphics code that
semester has the same issue since the professor never addressed, and
most people wouldn't care at all.  I simply never had the time to fix it
since it wasn't causing trouble.  A more pressing issue was figuring out
things like how to stop doing collision detection between the same set
of objects 20 times a frame (that was from code written by someone other
than me), or why I was having trouble getting the matrix math to work
out (I was accidently stomping all over a queue), or why the hardware
wasn't cooperating (damn beta devices that fall apart on you).

I firmly believe that inefficient code is better than no code, and
sometimes I need to write the bad inefficient version first, or I'll
just get stuck forever doing background detail, and not working on the
real problem.
 
> >   The programmer in question
> > just didn't know how to think on more than one level.  Get him to do
> > assembly, and he probably would never be able to do a single 
> > significant
> > program in his life.
> 
>    Then this person shouldn't be writing software!

I didn't say he should.


More information about the rescue mailing list