Universite du SI 2011 – des places a prix (plus) sympa pour certains geeks

Vous m’avez déjà entendu parler de cette conférence en France qui est un TED à la française pour les Geeks et les Boss (pour vous rafraichir la mémoire, cliquer donc ici). L’édition 2011 couvre quatre thèmes:

  • autrement: inspirations issues d’autres domaines (ex: sciences, architecture, médical), éditeurs de jeux vidéo, grands du Web, Big Mashups, DevOps.
  • techniquement: cloud en pratique, virtuoses du code, Big Data, architectures événementielles, architectures mobiles, HTML5 vs propriétaire.
  • humainement: impacts sociétaux de l’IT, dynamique d’animation, facteurs humains, efficacité personnelle, transition vers l’agile et le Lean.
  • prochainement: prospective, évolution de nos métiers par secteur, interfaces futuristes, informatique à la vitesse de la lumière, mariage du Web et de la TV.

Ca se passera le 28 et 29 juin 2011, pour plus d’info, aller voir leur site.

Le grand classique, c’est évidemment, le thème autrement. Hautement inspirant, je recommande. Mais j’avoue que mon faible pour cette année, c’est humainement. D’ailleurs Les Cast Codeurs ont proposé une session pour ce thème. Pas sûr que l’on soit acceptés, vu que c’est, en apparence, hors de nos sentiers battus et qu’il y aura à coup sûr du beau monde mais qui ne tente rien n’a rien. En parlant du thème humainement, je vous conseille cette petite video d’Amber Case, une cyberantropologiste.

Mais bon voilà, l’USI ce n’est pas donné. Octo fait un rabais conséquent sur un nombre limité de places pour des geeks qui n’en veulent: 1000€ HT au lieu de 1950€ HT. C’est sûr, c’est plus qu’un ticket de ciné, mais je vous assure qu’on s’en souvient plus longtemps ;)

Si vous êtes intéressé par ce rabais, contactez-moi à commentaire arobase lescastcodeurs.com. Le nombre de places est limité, donc ne trainez pas trop.

Script to hot switch JDK versions in Mac OS X terminals

Personal note.

Here is a script that lets you switch your JDK version in a terminal window. It also has auto completion.

Put the script in a file and add

source filename

in ~/.profile or ~/.bash_profile and you will be able to call setjdk and use autocompletion (with <tab>) from the command line.

emmanuel@computer $ setjdk 1.<tab>
emmanuel@computer $ setjdk 1.5

Original version at codehaus.

#!/bin/bash

function defaultjdk {
local vmdir=/System/Library/Frameworks/JavaVM.framework/Versions
local ver=${1?Usage: defaultjdk }

[ -z "$2" ] || error=”Too many arguments”
[ -d $vmdir/$ver ] || error=”Unknown JDK version: $ver”
[ "$(readlink $vmdir/CurrentJDK)" != "$ver" ] || error=”JDK already set to $ver”

if [ -n "$error" ]; then
echo $error
return 1
fi

echo -n “Setting default JDK & HotSpot to $ver … ”

if [ "$(/usr/bin/id -u)" != "0" ]; then
SUDO=sudo
fi

$SUDO /bin/rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
$SUDO /bin/ln -s $ver /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

echo Done.
}

function setjdk {
local vmdir=/System/Library/Frameworks/JavaVM.framework/Versions
local ver=${1?Usage: setjdk }

[ -d $vmdir/$ver ] || {
echo Unknown JDK version: $ver
return 1
}

echo -n “Setting this terminal’s JDK to $ver … ”

export JAVA_HOME=$vmdir/$ver/Home
PATH=$(echo $PATH | tr ‘:’ ‘\n’ | grep -v $vmdir | tr ‘\n’ ‘:’)
export PATH=$JAVA_HOME/bin:$PATH

java -version
}

function _setjdk_completion (){
COMPREPLY=()

local vmdir=/System/Library/Frameworks/JavaVM.framework/Versions
local cur=${COMP_WORDS[COMP_CWORD]//\\\\/}
local options=$(cd $vmdir; ls | grep 1. | tr ‘\n’ ‘ ‘)

COMPREPLY=($(compgen -W “${options}” ${cur}))
}

complete -F _setjdk_completion -o filenames setjdk
complete -F _setjdk_completion -o filenames defaultjdk

Mac OS X and IntelliJ crashes

I’ve struggled in the past several weeks with repeated crashes from IntelliJ IDEA on Mac OS X. I suspect it started right after the upgrade to 1.6.5 and the latest Java VM update.

It seems it was cause by a couple of things.

Job scheduler crash

If your crash report shows something like
Thread 55 Crashed: Java: JobScheduler pool 1/2
This is a bug in the garbage collector. You need to pass an additional VM option to fix it
-XX:-ReduceInitialCardMarks
Open /Applications/IntelliJ IDEA x.y.z.app/Contents/Info.plist and update the VMOption key
<key>VMOptions</key>
<string>-XX:-ReduceInitialCardMarks -Xms128m -Xmx512m -XX:MaxPermSize=250m -ea -Xbootclasspath/a:../lib/boot.jar</string>

Font corrupted

Not sure if that was related to the previous issue but I initially had crashes with a different report involving directly the Garbage Collector (GC). My IntelliJ IDEA was using the Inconsolata font which apparently was somehow corrupted.

Removing fonts from ~/Library/Fonts solved the issue. What you can do is move them to a different directory and slowly re-inject them to find the culprit.

I am quite happy all this is behind me. I chose:

  • A Java VM
  • On Mac OS X
  • with IntelliJ IDEA

to precisely avoid this kind of bad experience and time waste :) Back to normal.

Autumn Photo in Bruges

I’ve spent my Sunday working on the backlog of my pictures. I’m far from done but this one really stroke me.

I took the picture last month in Bruges, Belgium with a Panasonic Lumix DMC-LX3 (more metadata information here for the curious).

The Painting Or Not

I don’t think the camera made a big difference as the light was easy that day and I shot from 100-150 meters. This is nevertheless a great compact camera and Gavin did a nice review of it.

Dedicace des auteurs Français ce samedi au Monde En Tique (Paris)

Le samedi 23 octobre à partir de 15h et jusqu’à 18h, Antonio Goncalves, Arnaud Héritier et moi allons faire une après-midi dédicace au Monde En Tique à Paris, la librairie spécialisée (dans l’informatique notamment).

Vu dans les cast codeurs !!!!

Vu dans les cast codeurs !!!!

L’idée est de faire une petite après midi entre geek tendance Java. Que vous achetiez un livre ou pas, venez nous rendre visite histoire de papoter. Il parait qu’il y aura peut être à boire.

On ne fait pas exactement ça pour l’argent. A part Antonio qui va se payer une nouvelle Ferrari, Arnaud et moi espérons pouvoir rembourser notre ticket aller-retour sur Paris (va falloir vendre au moins 4 à 10 livres ;) ). Les livres* en dédicace** seront:

  • Java EE 6 seconde edition (Antonio, Apress)
  • Hibernate Search in Action (Emmanuel, Manning)
  • Maven (Arnaud, Pearson) – le seul en Français

Bref, passez nous voir.

(*) Le livre dédicacé est très tendance pour la saison de Noël 2010, profitez-en!

(**) Une dédicace offerte pour un livre acheté.

To Tor or a Tort

Last night, I read some articles about Tor. Tor is an anonymous network that redirects your communications securely and anonymously across the Tor network before entering the public internet. It prevents people from finding who / where you are and from spying on your internet connection. The idea is that the communication between you and say the web site you want to look at is encrypted and passes via a few other machines running the Tor network. It looks like the last person on the Tor network is surfing the web site you are looking at.

Long story short, it’s a tool emphasizing anonymity and protecting people’s freedom, privacy and confidentiality (quite useful when you are a dissident in a not so open country).

I did install Tor so that my machine ran as a Tor relay and exit node. A Tor relay relays the data flow from one Tor node to another. An exit node is the bridge between the Tor network and the real internet: in my previous example that’s the last guy that appears to look at the website you are surfing.

Why did I do that?
Good question. I was curious first and doing my part to keep the world good is something I try to do from time to time.

What happened?
That’s the sad part. I let the node run all night and when I tried to use my connection in the morning I had a couple of bad surprises:

  • Google thought I was a bot trying to run automated queries and abusing the system. Consequently, every search I was doing was guarded by a captcha (annoying).
  • freenode (IRC) must have thought I was a bad guy cause I could not log onto #hibernate-dev #jboss-dev and co

I suspect some people were abusing the system and hid themselves behind Tor and I was their gateway to the internet. That left a bad taste in my mouth, I’ve disabled my Tor relay.

End of experience.

IntelliJ's Live Template

If you remember, I like to write my getters this way (long story here)

public String getName() { return this.name; }
public void setName(String name) { this.name = name; }
private String name;

I have been doing it manually for a while but it turns out IntelliJ has a super nice feature for that: Live Templating which allows you to use parameterized and contextual templates to generate code.

Go to your Settings->Live Templating and create a new one.

Add this template:

public $TYPE$ get$UpperName$() { return $lowername$; }
public void set$UpperName$($TYPE$ $lowername$) { this.$lowername$ = $lowername$; }
private $TYPE$ $lowername$;

Then edit the variables:

  • TYPE: the expression should be classNameComplete() to refer to the class name context
  • lowername: the expression should be decapitalize(UpperName). Also tick skip if defined to not have to validate the computed value (this saves you one key stroke).

I’ve named my Live Template “get”. When I type “get” and TAB, I am asked to type the property type (which is suggested). The second variable asked is the capitalized property name. Then the Live Template infers the rest (decapitalize my property name to fill up lowername).

Pretty nice feature!

Retour sur l'Universite du SI 2010: geek et boss une equipe qui gagne

J’ai eu la chance d’aller à l’université du SI où Guillaume, Vincent et moi avons animé la session live du podcast Les Cast Codeurs (ça devrait arriver bientôt dans votre iTunes, j’attends toujours le fichier son d’Octo). Qu’ai-je retenu de l’USI? Je vais me limiter volontairement aux deux choses qui m’ont le plus frappé.

Geek et boss: pas une frontière, un gouffre… et pourtant

Ce qui ma frappé, c’est que les geeks et les boss vivent dans des mondes complètements différents, des réalités alternatives presque. C’était particulièrement visible pendant les sessions questions / réponses des keynotes où le micro passe du développeur Java au DSI Renault. Vous aller me dire, on le sait déjà que les DSI ne comprennent rien à la technique. OK mais il y a plus.

M’étant (re)pris une claque avec cette (re)révélation, j’y a réfléchi et j’ai passé du temps à comparer les points de vue pendant ces deux jours. Bien que vivant dans des mondes parallèles, le geek a besoin du boss et le boss a besoin du geek. Aussi bizarre que cela paraisse, c’est presque une symbiose. Comme un animal et son parasite qui le protège de je ne sais quelle autre bactérie (je ne dirais pas qui est le parasite de l’autre). Il y a de l’espoir cependant: au fur et a mesure de ces deux jours, on a vu décrire des techniques et des points de vues qui essayaient de faire parler/interagir les différents niveaux en proposant un langage et terrain commun, en ajoutant des boucles de retour rapides etc (hiérarchies râteau, méthodes itératives, reconsidération de la responsabilité…).

Il y a encore beaucoup de choses a inventer, de progrès à faire. C’est un énorme chantier, particulièrement pour les sociétés françaises. Celles qui prendront le pli gagneront en compétitivité, les autre iront pleurer auprès du gouvernement contre les grands méchants de l’étranger qui leur volent leur clients.

Les keynotes: pour penser plus loin

Une bonne keynote doit présenter quelque chose qui va au delà du thème de la conference, qui fait réfléchir, change les perspectives et fait mal à la tête. L’USI a mis la barre très haut avec 8 keynotes! Toutes n’étaient pas à mon goût mais 6 sur les 8 étaient du gros calibre, voir du gros gros calibre.

Celle qui m’a mis le cul par terre c’est la keynote de Juan Enriquez. Ce monsieur est une pointure en science de la vie et un business man averti. Il a trempé de près ou de loin dans beaucoup des dernières avancées clés en biologie et notamment la récente annonce de la première cellule entièrement synthétique (pour traduire: l’homme a crée la vie a partir de 0).

Juan nous a donne la vision d’un monde:

  • où les usines de chimie étaient obsolètes: une vache génétiquement modifiée génère la molécule anti-cancéreuse qui va bien dans son lait en beaucoup moins de place et de pollution
  • où les matières synthétiques ne sont pas dérivées du pétrole mais générées par des cellules
  • où les donnees génétiques sont du code, les cellules des microprocesseurs et les généticiens des développeurs: geek power!

La vie est la prochaine plate-forme, le vrai post-silicone. Oublier le cloud computing, le cloud computing est l’étape intermédiaire pour nous apprendre à faire du développement massivement distribué. Là où l’informatique silicone manipule des 0 et des 1, le bio développeur manipule des A,C,G,T.

Quelques chiffres clés:

  • 100,000 milliards de cellules (10^14) dans le corps humain
  • 6 milliards de bits dans le génome humain contenu dans chaque cellule (715 Mo)
  • donc le corps humain contient 68.187.713.623 To ou 63,5 Zetta octets (pour info au dessus il y a yotta et puis plus rien :) )

Une fois que le “hardware” sera peaufiné, il nous suffira d’écrire l’assembleur Vie, et la GVM Genetic Virtual Machine. L’expression code smell prendra tout son sens. Cela ouvre des perspectives totalement bluffantes! Cette perspective et cette vision de Juan Enriquez était tellement soufflante que je me suis dit “je veux bosser pour lui”.

Une petite déception d’ailleurs puisqu’à part moi, les autres questions dans l’assemblée étaient négatives ou pessimistes: Quid de l’utilisation en tant qu’arme? Quid des risques de ceci et cela? Quid des règlementations à mettre en place? etc. On reconnait bien la mentalité française :(

L’USI est un mini TED dédié a l’IT. Le format geek / boss et les sessions de 20 minutes fonctionnent bien. Un grand merci aux USI boys and girls qui ont tout organisé et avec un peu de chance, à l’année prochaine :)

Git: how my life has improved since last month when I used SVN

I’ve switched from SVN to Git (more git-svn actually) close to a month ago and that had to be a leap of faith. Rationally convincing someone that a DVCS is better is pretty hard because overall the life in SVN land is not that bad or does not appear to be. Note that I am using git-svn so I don’t benefit from all the power of DVCSes. While nothing replace actually trying it, I thought it was worth the time to explain what I like about this new tool to help people jump too.

This is not a post on why merging is superior in Git compared to SVN (this is something you need to experience), it’s a post on how Git is making my life easier.

This post is split is a few sections:

  • some intro
  • how to import a SVN repo into Git (feel free to skip this tutorial of you are interested in what I liked in Git compared to SVN)
  • use case: multitasking in isolation
  • use case: backporting bug fixes
  • use case: writing better commits and commit histories
  • resources

General

If I had to summarize, Git gives me more freedom than SVN. I am not constrained by the tool in any way:

  • it can follow whatever workflow I want
  • it is fast
  • as a net result my commits are clearer

I’t hard for me to say that but since the move I do enjoy committing stuffs (I know, that’s pretty scary).

The bootstrap

Here is a small tutorial section for people willing to import a project from SVN to Git and keep a bridge between the two. Due to a bug in git-svn for https imports, I am using Git 1.6.5.1 and not the 1.7.1 version.

mkdir project; cd project;
git svn init --trunk=my/svn/repo/project/trunk/ \
             --tags=my/svn/repo/project/tags \
             --branches=my/svn/repo/project/branches \
             my/svn/repo/project

You can optionally create a file containing a conversion between SVN logins and the committers names and email addresses

jdoe = John Doe <jdoe@foo.com>
agaulois = Asterix <asterix@gaule.fr>

In the logs, every time git-svn finds agaulois, it converts it to Asterix <asterix@gaule.fr>. If you want to do that, you need to create this file. Don’t be afraid to miss a couple of logins, if you do, git-svn will stop and ask you to add it. In your Git repository directory, run

git config svn.authorsfile ~/dir/myauthors.txt

The next step is to fetch all the information. This is long, very long. The good news is that you can stop it and restart later.

git svn fetch

Once that is done, you are good to go. To update your Git repo with the new commits from SVN do

git svn rebase

To commit your set of local commits to SVN, do

git svn dcommit

Many people, especially in the open source community, consider DVCS as a bad thing because it encourages committers to keep their work locally and not share with others. In reality, it does not. People who share frequently will continue to do so, people who don’t still don’t and should be fired. Same as usual. In practice for me, I dcommit every 4 to 6 hours.

I do recommend to import one SVN project per Git repository. You will typically get several Git repos per SVN repo. The rule is import the biggest unit that you tag / branch in isolation in SVN. For example, for Hibernate, I’ve several Git repos:

  • Hibernate Core (which contains all the modules)
  • Hibernate Validator
  • Hibernate Search
  • JPA API
  • Bean Validation API
  • Bean Validation TCK

All of these have generally independent release cycles and version numbers. Apparently it is possible to aggregate Git repositories via the notion of superproject but I have not tried.

One golden rule: you cannot share a Git repository and pull changes back with someone else AND use it to commit in a SVN repository. That will be a mess because git-svn rewrites the commit unique identifiers. Forget sharing repos when you use git-svn unless you are abandoning SVN and are doing a one time import.

Multitasking in Isolation

The absolute coolest feature is the ability to work in total isolation on a given topic for very cheap. I am not necessarily talking about the ability to work offline on an island (though that’s nice). I am talking about the ability to work on several subjects in parallel without complex settings.

Let’s take an example. I was working on a new feature for Hibernate Search’s query DSL. I branched master to dsl and started to work, including committing small chunks of work (more on this later). While working on it, I found a bug in the existing query engine. No problem, I literally stopped working on the new feature, put stuff aside (git stash). created a new branch off master named bug123 and fixed the bug. When I was done with the bug fix, I applied it on master and the dsl branch and resumed my work there. There is the workflow:

git checkout -b dsl #create the dsl branch and move to it
#work work commit work commit work
git stash #put not yet committed stuff aside
git checkout master

git checkout -b bug123 #create bug fix branch
#work work #fix bug 123
git commit
git rebase master #apply commits of master on bug123 (not necessary in this case as I did nothing in master)

git checkout master
git merge bug123 #merge bug123 and master
git branch -d bug123 #delete the useless branch

git checkout dsl
git rebase master # apply commits of bug123
git stash pop #reapply uncommitted changes
#work

It looks like a lot of operations but, it’s very fluid and very fast!

What’s the benefit? I’ve fixed a bug in isolation of my new feature even if the same files where impacted. I’ve committed the bug fix isolated: I can easily reapply it to maintenance branches (see below). Had I used SVN, I would have fixed the bug and committed “new feature + bug fix 123″. I would not have backported the fix to our maintenance branch nor would have my co-workers because of the complexity to separate the new feature from the bug fix. In Git the process is so smooth that I even use it to bug fix typos in comments in isolation from my main work.

I should point out that switching branch is super fast and done in the same directory. You IDE quickly refreshes and you are ready to work in the same IDE window. For me that’s a big plus over having to checkout a maintenance branch in a separate directory, set up my IDE and open a second IDE window to work in a different context of the same project: I work on five different projects on average, I can’t afford a proliferation of IDE windows. With Git, the context switching comes with much less friction and saves me a lot of time.

Backporting bug fixes

In SVN land, to backport a bug, I either:

  • generate the patch off of the SVN commit, and apply it on a checkout of the maintenance branch
  • manually read the commit diff and select which change I want to apply (generally because somebody has committed the fix alongside a new feature or because it has committed the feature in 7 isolated commits)

In the first scenario (the easiest), it involves

  • generating the patch
  • saving it as a file
  • optionally checking out the maintenance branch (ie get a coffee)
  • opening my new IDE window
  • apply the patch
  • commit the change with a log message

In Git, you:

  • checkout the maintenance branch (2s)
  • run the cherry-pick command (git cherry-pich sha1) over the commit or commits you want to copy from the main branch (logs are copied automatically though you can change them if needed)

So easy you actually do it :)

Writing better commits and commit histories

A feature I do like is the ability to uncommit things and rewrite / rearrange them. This is something you only do on the commits you have not yet shared (in my case not yet pushed to SVN). That looks like a stupid and useless feature but it turns out I use it all the time:

  • I can commit an unstable work, explore a couple of approaches and come back if needed
  • I can fix a typo or bad log message
  • I can simplify the commit history by merging two or more commits (I typically merge commits I used as unstable checkpoints)
  • These operations typically require 5 seconds or less

The net effect of being able to do that is:

  • I write better log messages
  • I commit more often / in smaller pieces, making my changes more readable
  • If the pieces happen to be too small I merge them before synching with SVN

You can also do some more micro surgery. If you are changing code and realize that these are really two or three sets of changes and should be committed separately (changes from the the same file potentially). You can literally select which file / which line to commit. The tool GitX let’s you do that very easily.

Git can do that because it does not track files, it tracks changes. You can stage some changes for commit (two new files and changes in three files), continue working on the same set of files and commit the state as defined when you initially staged it. Your subsequent changes can then be committed later. This is a subtle difference of approach (content management vs file management) but now that I have used it, I like it better. As a consequence, if you change a file, these changes won’t be committed automatically next time you commit. You need to include them (that’s what the -a option is for when you run git commit).

Resources

I absolutely recommend you to read Pro Git:

  • that’s a top quality book
  • use case oriented
  • and it’s also available for free online http://progit.org (though go buy it too, it’s well deserved)

Aside from that, I do use

git help command

very often, their documentation is pretty good. Otherwise, Google is your friend, there are many resources out there.

I don’t need / miss additional tools to work with Git. The command line is good enough and often less confusing (IntelliJ’s integration confused me, so I don’t use it unless I need to compare files). I do like to use GitX a graphical tool for two purposes:

  • it displays branches and commits graphically
  • it lets you easily stage specific lines of a file for later commit (the micro surgery tool)

That’s it folks,

I hope you enjoyed the read and that I’ve encouraged you to give it a try. git-svn made the try a no brainer really. I’ve lost probably 16 hours to learn, try and understand Git. I’m confident I will get them back within the next three to four months (my ROI is covered :) ). You can also try it on any directory, I am now using Git to keep a revision history of all my presentations. Remember, no need to set up a server or anything complex. Run git init and you are good to go.
Disclaimer: this is not a thorough comparison, just the feedback of a one month old user.

“No meeting” always beats “Meeting”

I was chatting with a colleague on a feature that is loooooooong overdue and proposed to kill a meeting and use the time saved to write the damn thing.

He replied to me

Believe me, I would like to drop a meeting, not sure which one.

To which I replied

That’s easy, anyone of them :)

and gave my thoughts on meetings.

If there is a need for bi-weekly meetings to integrate XXX and XXX, we’ve got a problem that meetings can’t solve.

I have a radical take on meetings, especially regularly scheduled meetings:

  • assuming n persons in the meeting you waste most of the time n-2 people’s time (and if n>10, it’s likely n-1 people’s time)
  • people tend to not prepare meetings. They instead think about the issue at stake while in the meeting and thus wasting n-1 people’s time. Force people to write ideas in a (somewhat short) email, and that will force them to think about the issue more deeply and synthesize.
  • a need for a regular scheduled meeting is a sign of lack of trust, lack of natural communication and/or lack of proper task isolation: in any case, better treat the problem at the source than patching with a meeting.

The key to open source success is multiple but one big component is extreme resource/time stress. This constraint leads to:

  • very focused teams
  • limited need for sync-up style communication (hence the usual small core team)
  • proper separation of tasks to limit waste

I am not against communication, I am against communication wasting time (the asymptotic version being pure noise). I favor 1-1 communication personally as the most efficient brain-picking strategy.