Vitavonni

Mon, 30 Mar 2009

Java: 'base' classes and 'final' modifier

In a Java framework I'm working on, 'pairs' arise everywhere. Unfortunately in contrast to e.g. C++, Java doesn't include a predefined 'pair' class. C++ templates are really nice because of the way they are complied and optimized (in particular they also handle what Java calls 'native datatypes'); Java generics aren't up to par with that. (But yes, Java offers other benefits, such as being much easier to parse and thus refactor). Anyway, this is not going to be a rant on Generics.

So I have this interface in Java called Pair<FIRST,SECOND> along with two implementations SimplePair<FIRST,SECOND> and ComparablePair<FIRST extends Comparable<FIRST>,SECOND extends Comparable<SECOND>>.

For performance reasons, SimplePair is declared 'final', and so is ComparablePair. It's written everywhere that making classes final can make a large difference in Java, and since these objects will be used in a lot of places, it seems reasonable to care about this here.

However, it would often be nice to have better readable code, that is assuming I'm using SimplePair<Monkey,Banana>, it would then be nice to make a derived class BananaPreference extends SimplePair<Monkey,Banana>, with added methods getMonkey() and getPreferredbanana() to make the resulting code more readable.

Having readable code is also often quite as important as having performant code, after all ...

If someone with solid experience in Java optimization has some ideas to share, please do so! Email: erich AT debian DOT org - no comments in blog.

Right now, I have one idea on how it could be possible to achieve both (seriously, I could use some feedback from Java Gurus on that): make SimplePair and ComparablePair abstract, all methods there final, then derive final classes as needed. Does that combine the benefits?

[Update: I received from Joachim Sauer the following helpful link: JavaOne presentation on performance tuning and various VMs. Basically this seems to indicate that in all these common situations, any modern Java VM should be able to figure out the inlining options automatically and optimize appropriately, so it won't benefit from any "final" hint by the developer. Note that a C++ compile doesn't do runtime optimization, but allows compile time optimization at a much lower level, so this rule doesn't apply to C++.]

[category: /en | Permalink]

Google Summer of Code 2009

Just a short reminder that the application phase for the Google Summer of Code 2009 is running.

GSoC 2009 logo

So far, we have quite few applications. Deadline is April 3rd, 19:00 UTC. Usually applications arrive rather late, but still I have the impression that we have much less than the previous years. But less copy & paste, too.

If you are interested in doing a GSoC project at Debian:

  • Check the Debian Wiki which has all kind of relevant information.
  • Talk to Debian people
  • Make sure it's related to Debian (and not just "runs on Linux")
  • Talk to Debian people
  • Make sure your application shows your genuine interest and has some original ideas, copy & paste will not be sufficient
  • Talk to Debian people
I hope to see more applications - and good luck that we get enough slots for all of you!

P.S. as far as I can tell, current Debian Developers can be eligible as well, although it has also always been a goal of the project to get new contributors involved.

Fri, 20 Mar 2009

On Facebooks new layout

Lot's of people complain about the new layout, but I guess it's mostly because it has actually changed. I'm okay with it, since it seems to feed me less irrelevant information and more content deliberately generated by the users.

Anyway, what I'm more interested in is the technical background. The last months, I saw lot's of instability in Facebook, and it often gave the impression of being next to breaking down because of load. With the redesign, it feels more stable to me. Given that the 'mobile' page still seems to be pretty much the same, they still seem to be aggregating the same information, and the difference is just in the front page.

Guess their servers just weren't able to handle all the 'live feed' access for all their users. Maybe they'll get some database experts to redesign that feature and bring it back; after all it seems one of the things people most miss in the new layout.

P.S. Add this to your user stylesheet to hide some ads:

@-moz-document domain(facebook.com) {
.UIHotStory_Ad { display: none; }
#profile_sidebar_ads, #sidebar_ads { display: none; }
}
And install this small greasemonkey script I wrote to turn the front page into a two-column layout (filters are moved to the right column) that is more efficent in using the screens real estate.

[category: /en | Permalink]
Menu
[planet.debian]
[planet.xmlhack]
[planet SELinux]
[munichblogs]
[email]
[RSS 2 feed]
[English RSS 2]
Categories
< March 2009 >
SuMoTuWeThFrSa
1 2 3 4 5 6 7
8 91011121314
15161718192021
22232425262728
293031    
Archives
2010-Mar
2010-Feb
2010-Jan
2009-Dec
2009-Nov
2009-Oct
2009-Sep
2009-Aug
2009-Jul
2009-Jun
2009-May
2009-Apr
2009-Mar
2009-Feb
2009-Jan
2008-Dec
2008-Nov
2008-Oct
2008-Sep
2008-Aug
2008-Jul
2008-May
2008-Apr
2008-Mar
2008-Feb
2008-Jan
2007-Dec
2007-Nov
2007-Oct
2007-Sep
2007-Aug
2007-Jul
2007-Jun
2007-May
2007-Apr
2007-Mar
2007-Feb
2007-Jan
2006-Dec
2006-Nov
2006-Oct
2006-Sep
2006-Aug
2006-Jul
2006-Jun
2006-May
2006-Apr
2006-Mar
2006-Feb
2006-Jan
2005-Dec
2005-Nov
2005-Oct
2005-Sep
2005-Aug
2005-Jul
2005-Jun
2005-May
2005-Apr
2005-Mar
2005-Feb
2005-Jan
2004-Dec
2004-Nov
2004-Oct
2004-Sep
2004-Aug
2004-Jul
Other links:
Swing and the City - Lindy Hop in Munich