Monday 23 July 2012

JVisualVM

"Premature optimization is root of all evil" - I agree with that as mush as I can. But there are times, that you just need to make you code work faster. Joshua Bloch in his Effective Java is has put some light also to this area, for example in Item 5: Avoid creating unnecessary objects or 51: Beware the performance of string concatenation, etc. You can surely call them good practices that have to be known (and ofc most of things that this book is about).

But sometimes knowing basics is not enought, or project is too big to look deeply to every line of code, and  you just need to spot bottle neck quickly... What you need then? Java profiler! 


Guess what... - it's already with SDK (open consone + type jvisualvm), so no aditional effort is needed! Isn't that awesome? :)

Some performance issues in my current work, and especially reading AMA with high performance java code writer were eye openers for me... I will not pretend to be guru, and give you tips how and when you profiler - I'll just provide you with some link, that look permanent, and were enough to start effectively testing my application today's morning.

http://blog.xebia.com/2008/09/15/loitering-objects-make-web-company-lose-money/ - very pleasant to read blog entry, that forced me to try it all on my own - I couldn't write it better, so I don't event try :)

https://blogs.oracle.com/nbprofiler/entry/profiling_with_visualvm_part_1 - less blog-like, slightly less chilling, but this1 has some info that I found missing in previous link.

Both readings combined seems to be even more then you need to try it yourself, with pretty good knowledge what are you doing.

EDIT:
Feel the power of community! ;) - link provided by my mate (thanks Marcin!), that seems to be perfectly fetting in here - Eclipse Memory Analyzer - fast and feature-rich Java heap analyzer that helps you find memory leaks and reduce memory consumption. This time he seems to be knowing what he's talking about, so this tool should be worth the effort to know more about its capabilities. ;)

Sunday 22 July 2012

"Effective books"

For some selfish reasons, and encouraged by words that I have read today, something like forget about real programming, if you can't read in English - I have made first entry in English. Not Java, nor C/++/C#, Scala etc., English is the most important language in programming. http://stackoverflow.com is a good playground for practicing it, but let's go straight to main topic.


I needed stimulus to write something here, and today it has come!


That stimulus was reading a great AMA (ask me anything) with some successful Polish Java Developer, who is currently working for some real money in Switzerland http://www.wykop.pl/link/1209873/ama-programista-z-doswiadczeniem/# There are tons of interesting questions and answers (of course that's true only if you know Polish;)), that can be good signboards for low and mid experienced programmers, and even more for still wannabe-programmers. One of them was about books that he is recommending.


So, going to the point:

Effective Java

Java Puzzlers

Java Concurrency in Practice








Doing further research I've found another awesome thing to read - a great presentation on the optimizations used by modern JVMs on the Jikes RVM site:
Dynamic Compilation and Adaptive Optimization in Virtual Machines


And... that's all - I'm pretty excited and in rush to read Java Puzzlers*, which seems to be really enjoyable book and next go back to concurrency (I find it being hard to read, but it surely will be rewarding lecture) or take on reading about JVMs optimizations and of course I'm sure that all mentioned readings are worth to be red by you as well.

*UPDATE:  After some reading of Java Puzzlers, I have to say, that I feel disappointed. This book is too much about some error prone things, that are so error prone, which make them obvious that those kinds of code shouldn't be written without some testing before. And in most cases they are so unreadable, that wouldn't be written by anyone in first place. To sum up - if you don't have anything waiting to be red - go for Java Puzzlers, if you do - don't waste you time ;)


BTW. I'm really surprised every time I hear that someone hasn't read at least Effective Java yet...