Very nice rant about functional languages

[About cuncurrency:] My problem with the functional programming cure to this problem is that I haven’t seen a cure yet that’s better than the problem. Maybe it’s me. Maybe my tiny Ben brain just can’t comprehend the magic and majesty of OCaml, but every time I’ve tried to learn a new functional language, it’s ended it disaster. First with Erlang, and then Haskell, I’ve now had two aborted attempts to understand the supposed cure to the concurrency problem. The languages are just too complex, too terse, and absolutely full of academic shitheaddery. I mean, seriously, what the hell.

that really made my morning😉

Joel on Mercurial

a very nice introduction into mercurial can be found here. It nicely goes from bashing subversion

The story is this: at some point, they tried to branch their code, usually so that the shipping version which they gave their customers can be branched off separately from the version that the developers are playing with. And every team has told me that when they tried this, it worked fine, until they had to merge, and then it was a nightmare. What should have been a five minute process ended up with six programmers around a single computer working for two weeks trying to manually reapply every single bug fix from the stable build back into the development build.

And almost every Subversion team told me that they vowed “never again,” and they swore off branches. And now what they do is this: each new feature is in a big #ifdef block. So they can work in one single trunk, while customers never see the new code until it’s debugged, and frankly, that’s ridiculous.

to explaining the simple commands, and further to conceptual perspectives like repository distribution.

a nice read.

Wave Panel for Wicket

in case someone thought it was a good idea:

We’re delighted to introduce a new wicket component which will allow you to easily integrate Google Waves right into your application. Please meet GoogleWavePanel !
The idea of making this component came from a recent tutorial which aimed at clarifying the use of Google’s Wave Embed API.

Playing with Wicket’s templates

Wicket comes with some templating facilities. They’re often handy, especially when integrating JavaScript components.

Yet, for some reasons I don’t get, these functionalities aren’t much advertised. Anyway, let’s dig in !

Basically, this templating is about some text containing variables, for example ${variable}, whose values are provided through Java code.

Let’s take a simple example, a template file named javascript.tpl containing :


Wicket is nice enough to provide an easy to access the templates as package resources, through the PackagedTextTemplate class :

public PackagedTextTemplate(final Class clazz, final String fileName)

For example :

PackagedTextTemplate jsTemplate = new PackagedTextTemplate(this.getClass(), "javascript.tpl");

Thus the template can be next to the .html page and the Java class using it, making the whole quite cohesive.

Providing the variables is done through a simple Map :

Map parameters = new HashMap();
parameters.put("variable","test working");</code>

And then, you most probably want to include this template in some html. Wicket provides you different options :

  • as an header contribution :
    add(TextTemplateHeaderContributor.forJavaScript(jsTemplate, new  Model((Serializable) parameters)));
  • directly next to some element in the html file:
    Java side :

    Label myScript = new Label("myScript", new JavaScriptTemplate(jsTemplate).asString(parameters));

    Html side :

    <wicket:container wicket:id="myScript"></wicket:container>

You may have noticed that, in both cases, I didn’t provided the surrounding script tag (and the appropriate inner wrapping). Fear not, Wicket does it for you !
Indeed, the rendered html is :

<script type="text/javascript">
alert('test working');

If the template was about some CSS stuff, one would just need to warp it using a CssTemplate instead of the JavaScriptTemplate.

A bit more info are available there Including CSS resources.


Primitive Array to Object[]

If ever you face the need of ‘boxing’ the elements of a primitive array into an array of Objects, this might be handy:

    public static Object[] convertPrimitiveArray(final Object array)
        final int arrayLength = Array.getLength(array);
        final Object[] result = (Object[]) Array.newInstance(Object.class, arrayLength);
        for (int i = 0; i &lt; arrayLength; i++)
            Array.set(result, i, Array.get(array, i));
        return result;