Generalized Rant Thread

Both your ‘optimizations’ should be avoided. In most cases HotSpot does the loop unrolling and rewrites the for loops.

Indeed Riven is right (again). Once upon a time loop unrolling in java (and C) was something you did and it would be faster. That was a long time ago. Compilers in C/C++ unroll for you and so does JIT. Even better JIT can unroll using parameters that you don’t know at compile time. Things that can be shown not to change are also typically moved out of the loop. JIT can and does often eliminate bounds checks too when it can prove that out of bounds never happens. Even micro benchmarks can show all this.

On top of all that even in the old days you would never unroll all 256 elements of a loop. Perhaps you would unroll 16 or so and loop 16x. But since the compiler/JIT can tune these to the particular loop, its always “better”.

Thing is Java was designed specifically in mind of “make your code look neat and tidy and easy to understand, and we’ll worry about making it fast enough”. By and large they have achieved this goal admirably. Almost no-one ever has any serious performance problems in Java that are fixable with this sort of micro-optimisation. Except on Android, where sadly stuff like caching .length in a loop comparison is still a valid optimisation.

Cas :slight_smile:

There, FTFY.

The Sun JRE was meant to be a reference implementation. Only when there didn’t seem to be a fast, freely available alternative, Sun started to put major resources towards performance.

In some pervert way coding against dalvik is fun becouse you have to do every small thing for yourself. Its like c with bad compiler using java syntax.

Sun have done extremely well with their compiler :slight_smile: Actually IBM did as well but for some reason never really did attempt to compete.

Cas :slight_smile:

A good chunk of the fast parts of the sun implementation is from IBM as I understand. Or at least comes out of IBMs work on JIT.

As I understand it, it came from the Self team, which left Sun to write Strongtalk, then got re-hired to write Hotspot.

Masturbation Programming (MP): A common programming technique that involves coming up with a brilliant solution to a problem and then rapidly banging out the code. On completion (assuming it is achieved) then end result is usually an embarrassing mess.

Agile Programming: A software engineering methodology that involve iterative application of the MP technique. Agile developers make impressive claims about their style.

Programming Pairs: MP as a team sport. One partner watching the other generating code, injecting any helpful hints as needed and then later: they trade roles.

Masturbastion Posting (MP): making seemingly provocative claims nobody else really cares about. Typically involving necroing threads for added effect.

:point: Who’s been drinking then?

Cas :slight_smile:

Probably both of us.

Snarky is my middle name, from this day on :emo:

I apologize in advance and wish Roquen strength, for which a medal seems a poor fit, symbolically, but nonetheless invaluable.

* Riven sips from his drink.

Why on earth? I feel no shame over either my masturbation programming nor posting (SEE: operator overloading thread #1001 for reference). Errr…where’d that bottle go?

… Why are we getting into a discussion about how generalized techniques (such as optimizations and design patterns) are bad anyway? Isn’t this thread really the absolute waste of time everyone so valiantly speaks of?

Come on, it is the “stereotypes” of computer science. Everyone gets caught up in them once in their career and just laughs and learns from it afterward. The only time any programming practice is “bad” is when it actually turns into a religious belief.

Optimization 99% of a time is the biggest waste of time you can do on a program. The amount of work to get 1-2 more FPS or even 10 - 15 more bytes of memory is never worth the time. The only time that optimization of code should take place is as a “last resort”. In today’s age, there is no way we are going to run out of memory, or not have enough speed to perform a simple task.

Personally, design patterns are just a byproduct of trying to make computer science a mindless job. The fact is, we like computer science, but we don’t want to code it. If there was a way to translate our thoughts on the computer without typing them down, we’d all flock to it like a bunch of buzzards. I think entity systems, API, and tree node systems all have their place. In no means should we go insane and try to apply them to our code just for the sake of it. Just like you don’t use all your wooden blocks to build a castle, some pieces of design should be left out so you can get something built.

… But, yet, here I am wasting my valuable time again. The more time I spend in computer science, the more I believe it is more like Computer Architecture.

A: work avoidance technique #23.

So many words to state that one is wasting their time… ::slight_smile:

And ctomni231 seemed to have missed my serious points.

Which is exactly the point on both mentioned, optimization & design pattern. Patterns are just snippets that are useful or not and shouldn’t replace data-structure, algo & design knowledge. On optimization…real optimization is non-linear and higher level and “premature optimization” is just a single example of wasting one’s time and (in my experience) a very unimportant one.

I would like to note that time is a resource and is not infinite. If I have to “optimize” for a week and only get a measly 0.1ms speed in overall average execution time, i’d say that time can be better spent elsewhere.

Tipping point.