Archive for July, 2007

Book Recommendation: Beautiful Code

I’m not even halfway through yet, but O’Reilly’s Beautiful Code really is a great book on the arts of programming. It contains about 30 essays by top-notch programmers, including veterans like Brian Kernighan or Charles Petzold, on what they consider beautiful code or programming concepts. The chapters vary greatly in difficulty, including both (rather) easy-to-understand concepts like a regexp matcher in 20 lines that show why simplicity is often a win and very specialized contributions like an image filter in Microsoft’s Intermediate Language. I think this is a book best read not cover-to-cover, instead just pick the most interesting chapters for you and see how elegant code can be.

One thing that also comes to mind reading this book is how short-lived many of the contributions were. Once-glorious hacks like Windows’ bitblt() implementation do not have much relevance in today’s world, where Google’s Map-Reduce provides the foundation of an enormous technological success story.

Leave a Comment

Composite JSF Components

Writing a versatile input/output component for JSF, I realized two things:

  1. Composition works great. It is almost trivial to delegate encoding and decoding to existing components like the JSF core input tags via composition. Facelets templates offer this functionality in a declarative way without coding (or compiling), and I wouldn’t want to use JSF without them at all, but it’s nice that composition is rather easy in core JSF anyway.
  2. You don’t want to pull SelectMany values from ExternalContext#getRequestParameterMap(), but use ExternalContext#getRequestParameterValuesMap() instead.
  3. Doing a “render-time” iterator component similar to Facelets’ ui:repeat is insanely hard to do right. Really. Rendering the child components multiple times with different data is easy, but to let them perform correctly on every stage of the lifecycle is near to impossible without some intimate knowledge of JSF. I’d really like to read a book on these kinds of advanced JSF topics (and not on designing another calendar component), but I’ve yet to find one.

Leave a Comment

Kubuntu: WinTV PVR-150 adventures

Watching TV under Kubuntu with kaffeine and xawtvAfter praising (K)Ubuntu for the last year or so, trying to install a common WinTV PVR-150 TV card was a major setback. Ironically, Ubuntu got the hardest part right all by itself: the TV card got autodetected, and an initial test with mythtv was successful. I could even capture TV with cat /dev/video0 > /tmp/tv.mpg. Very cool – but! There seems to be no reliable way of tuning the TV card. kdetv freezes after scanning about 50% of all channels and requires a reboot to get TV working again. tvtime doesn’t seem to support MPEG-2 cards. Kaffeine or mplayer can render the MPEG-2 stream, but cannot use the tuner. xawtv renders empty black windows (current NVidia drivers don’t support DGA any more, but -nodga gives me only black windows). Mythtv works, but it’s way too bloated for a simple TV viewer.

So I…

  1. Create a channel listing using xawtv’s scantv:
    scantv -c /dev/video0 -C /dev/vbi0 -o ~/.xawtv
  2. Start up xawtv, maximize the window, open channel listing (E).
  3. Start up kaffeine, opening the URL pvr:/
  4. Minimize the xawtv main window
  5. Voila!

Admittedly this might be just a minor problem with my installation, but the fact that it’s virtually impossible to find an application that can render the TV image and supports tuning and is not mythtv when the hardware apparently works is slightly embarrassing. Getting this setup up and running on Windows XP took 15 minutes at most, and it works without a glitch ever since.

Leave a Comment

YourKit Java Profiler 7.0 EAP

Until now I did not really consider commercial Java profilers. The Netbeans profiler works most of the time and usually helps to identify the most glaring hotspots of an application.

Recently I stumbled upon a YourKit EAP build and was rather blown away by its ease of use, integration, and the snappy user interface. Enabling profiling on a local JBoss was actually a matter of one click, not of manually fiddling with agent and LD_LIBRARY paths. It also offers some JavaEE-specific statistics: plain SQL query execution times, as well as JNDI lookup and JSP/Servlet statistics (no JSF-specific stuff yet). And most important: all profiling tasks can be started and stopped at runtime, thus you don’t have to endure a slow application server startup just to profile one page (as with Netbeans). The EAP builds are apparently full builds with no restrictions (except of being beta software), so if you’re looking for a slim, working Java profiler I’d take it for a ride.

Comments (1)