"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." (Knuth, Donald. Structured Programming with go to Statements, ACM Journal Computing Surveys, Vol 6, No. 4, Dec. 1974. p.268.)

How many times do you hear folks excuse shoddy programming in the name of the above dogma? While I agree with the above sentiment, I don't think Knuth meant it to read, "don't worry about putting crap in, you probably won't notice it anyway."

Take for instance, this gem, in Tomcat's JSTL.

Suppose you do

<c:set var="form" value="visible"/>

You can probably imagine how this implemented. Or can you? Here's what i see:

_jspx_th_c_005fset_005f2.setValue(new String("visible"));

And I agree, up until this point, you probably haven't noticed. And i also agree, performance-wise, for this one line, this faux-pas probably doesn't matter. But what kind of crap is this? The JSTL is just beating the garbage collector around the head and neck for no purpose. Consider, for a second, how many times you have a <c:set...> tag in your jsps, and how you are taxing the gc with all those unnecessary new String objects, and maybe it's starts to explain why your pages are slower than they should be.

Come on folks, don't write crap in the name of avoiding premature optimization.



Your Option (Login or Post by anonymous)