Beemer (dr_tectonic) wrote,
Beemer
dr_tectonic

Java is lame yet again

Things to hate about Java, #5801:

I get why Java has both Strings and StringBuffers. There are advantages to each, and times when you want to use one rather than the other.

Like, if you're building a long string up out of a lot of little pieces, it's a whole lot more efficient to do it with a StringBuffer, which is designed for that kind of thing, than do it with Strings, because they're immutable and the '+' operator gets translated invisibly into a temporary StringBuffer and some calls to append(), so why not do it that way explicitly in the first place, right?

So, given that the number-one usage of StringBuffer is almost certain to be to concatenating a bunch of Strings together, and given that StringBuffer is just as much a part of the Java language core as String, and given that you can use the '+' and '+=' operators on Strings...

Why in the name of all that is holy is '+=' NOT aliased to 'append()' for StringBuffers?

Argh, I say. Argh.
Subscribe

  • The Dependency Principle and the Litany Against Fear

    Two thoughts on COVID-19: First, from Iain M. Banks' Excession: There was only one problem with the Land of Infinite Fun, and that was that if…

  • Ultravision

    I fell out of the habit of posting while work was so busy last fall, and now I've been feeling like I need to Say Something Important about my life…

  • Holiday Recovery

    I think, maybe, I am finally recovered from the end of 2019, which was exhausting. Basically, a bunch of work deadlines all converged, most of which…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 7 comments