Today’s thoughts about programming languages

Maybe some of you have heard me ranting about this already?

  • I’m not productive enough in C++ and I feel too limited by Java
  • A large chunk of Java frameworks seem to serve no other purpose than to workaround limitations in Java
  • I believe (and hope!) that Java will cease to be the default language in the non-Microsoft world, and that other JVM-based languages such as Scala, Groovy and JRuby will become more important
  • How can I convince a client to allow Scala, Groovy or JRuby in a project?
  • I should really get some C# experience!
  • It seems like I almost always resolve to PHP when I need to get something done quickly… which reminds me of an upcoming blog post about a recent fight with SoapServer and SimpleXML to implement WSSE UsernameToken authentication.

The C++ cut is the deepest

When you hear me speaking about C++,  you probably notice the passion. I might expose a similar passion when I pinpoint some of Java’s weaknesses. Maybe I do sound like “Dick” in the article Java is Slow! at The Daily WTF?

From GW-BASIC on my first computer I went through QBasic, QuickBasic, QuickC and Turbo C++ until “reaching” Visual C++ in high school. It is more than 10 years since I wrote CalcEm, the first Open Source emulator for Texas Instruments calculators TI-82 and TI-83. It is hopelessly outdated now, but it was a great achievement for me at the time. (I’m actually sitll proud; the last CalcEm version is ranked as 102 on the all-time top downloads list at ticalc.org with 43556 downloads.)

Maybe C++ entered at a sensitive point of my life? When learning Java at the university it only felt crippled when I already knew C++, so I only used Java when I had to and C++ (as in g++) when I got to choose. Sometimes the choice was bad, but it was about learning after all. I remember that our Kalah C++ implementation ruled the competition!

C++ made me feel in control! I never felt as much in control when using Java, and I still don’t. But I’ve learned not to demand so much control.

My friends may have heard me dreaming of working at Tandberg. I don’t languish for ThoughtWorks so much these days. (They do have Martin Fowler, but they also use Lotus Notes. Go figure.)

This is why I never applied for a job at UIQ. I like C++ so much that I cold not stand the horrible subset of C++ that Symbian has inherited from Psion. Instead I got stuck with a stone-age C++ compiler on Tru64. But I got away and now I’m your Java man!

Just let me do a little PHP, Python, Ruby, Scala or Groovy too! And wouldn’t C++ be great for something? 🙂

Instantiating Java objects of generic type parameter

I was going to write a really grand blog entry about how to instantiate a Java object of the type specified as parameter to a generic class but I figured that someone must have done that already. The blog article Java Generics: Instantiating Objects Of Type Parameter Without Passing Class Literal To Instance sums it up pretty good. My implementation supports a deeper inheritance hierarchy (caused my Javassist in my case) but I was not clever enough to extract the hack, I mean magic, to a generic Factory class as suggested by the first comment to the article.

The final statement in the article is that This pattern is frequently used for generic DAO classes, and yes I first saw it at hibernate.org – Generic Data Access Objects, but I think it is a bit scary that this workaround is common enough to be called a pattern.

SpringSource to stop providing maintenance releases for free

Is this possibly the latest Java community buzz? SpringSource Announces Enterprise Maintenance Policy.

Mats Henricson asks What is SpringSource doing with its license? and while the SpringSource Enterprise Maintenance Policy FAQ states that there is no license change, the SpringSource Enterprise Maintenance Policy sure is a change. They summarize it quite consise themselves:

After a new major version of Spring is released, community maintenance updates will be issued for three months to address initial stability issues.  Subsequent maintenance releases will be available to SpringSource Enterprise customers. Bug fixes will be folded into the open source development trunk and will be made available in the next major community release of the software.

Entity bean bloat

I’m currently getting acquainted with JBoss, SpringSource Application Platform, JBoss Seam and Spring Framework.

One thing that amazes me is the amount of code required for some simple O/R mapping, or I am missing something? I hope to be wrong about this, but it seems like an EJB3 "entity bean" requires, for each column in a database, the following items written and maintained:

  • a private member variable
  • a getter method
  • a setter method

As I have some Ruby on Rails experience, where inheriting from ActiveRecord gives you those things out-of-the-box, I am amazed of the sheer amount of boilerplate code needed in Java for the same thing! I asked a friend wih ZendFramework knowledge about how it worked there, and it seems like Zend_Db_Table_Abstract works just like ActiveRecord.

I can’t be the first one perplexed by this, especially not when the development guide for the ASM 3.0 Java bytecode engineering library contains exactly the above parts as an example of generating bytecode! (See section 3.1.3.)

Andi Gutmans: “Java is losing the battle for the modern Web”

Andi Gutmans (of PHP fame) has written a very interesting blog post about Java’s future on the web. The article is called Java is losing the battle for the modern Web. Can the JVM save the vendors? He gives some good arguments for using a LAMP stack for web applications.

One of the interesting quotes is:

Project Zero’s Chief Architect is one of the first IBMers to admit in public that Java today can be considered as a system language and is not desirable for building RESTful Web applications […]

This was apparently a bit out of context, according to the comment by Jason McGee, but fun to read nevertheless.

He makes a prediction that shall be interesting to see if comes true:

It has taken over 10 years for the Java stronghold to admit Java’s poor ROI on the Web and with the current recession it is likely that many Java customers are going to be making more informed investments. As a result there will be considerable rise in uptake of dynamic languages.

Is required in or not?

In an XSLT script I didn’t use <xsl:text> inside of <xsl:message>. It worked fine in xsltproc, but the Java XSLT implementation we use complained. What was wrong then? The text in an <xsl:message> was not inside an <xsl:text> element.

Bad code:

<xsl:message>Don't do like this</xsl:message>

Good code:

<xsl:message><xsl:text>Do like this</xsl:text></xsl:message>

To avoid making the same mistake (or another) I wanted to validate my XSL. Searching for “xslt.xsd” turned up something that seems out-of-date. Some further searching revealed the Validating XSLT 2.0 article that include a link to xslt10.rnc. For some reason Jing didn’t recognize this file until I converted it to XML syntax with Trang. Unfortunately the above mistake was not caught by the RELAX NG schema either!

Actually, the <xsl:message> example at w3schools.com does not use <xsl:text> in their example, so maybe it is simply an implementation issue.