Nicolas Lehuen's Weblog

To content | To menu | To search

Wednesday, April 2 2008

pytst 1.15

I've just released pytst 1.15, you can download it there.

This release fixes a quite important problem introduced on 2006/05/05... For a reason I don't quite remember now, I decided to make the TST C++ template specialization dedicated to the Python bindings privately inherit from the more generic tst<...> template. I guess this was related to some problems I had with SWIG.

The problem is that this broke something in the way SWIG handled inheritance between the two types, the net result being that the Python TST class lost its prefix_match methods and other methods that were declared in the parent class but not in the specialization.

I've reverted the inheritance between the two C++ classes back to public inheritance, and everything is back to normal now.

I really wished I could spend more time working on ctst, since it features theoretically better structures and algorithms, plus to be frank I'm quite fed up with C++, and I'd be more than happy to go back to C.

Also, I must say that the native API for Ruby is very impressive. I've been developing the Ruby bindings for ctst by hand, not using SWIG, and I've spent substantially less time than it took to have SWIG properly handle my C++ code from pytst...

Wednesday, February 13 2008

A tribute to Groovy

My life as a developer :

Update : it's my life as a professional developer, since my life as a programmer began in 1983 on a Sinclair ZX81...

  • 1995 : Java 1.0 beta is released. I begin playing with it. Hotjava browser, applets are all the rage. Soon after, the infamous "Loading Java" status bar message in Netscape is the signal that you'll loose control of your browser for at least 15 seconds while the JVM loads an applet.
  • 1996 : Academic and toy projects in Java. Since JDBC is not out yet, I decide to write my own DBMS in Java. It works but of course it's crappy. Cloudspace, Hypersonic and over 100% pure Java DBMS are safe.
  • 1997 : Wrote an HTTP 1.0 server in Java, with pluggable controller modules named "lumps" (Java <-> coffee <-> sugar lumps, nudge nudge wink wink). Damn, I should have thought about "Servlets". Wrote a lump which interprets a server page language not unlike ColdFusion (that is, as crappy, but at least at that time it already ran on the JVM). Wrote my first server pages which could access an Access database through the freshly released JDBC-ODBC bridge and display data on my browser. As a trainee, I have to work on a project built with Borland Intrabuilder. That was both interesting and very scary, since the thing was drowning in bugs.
  • 1998-1999 : Had to work, first part time, then full time. Of course, it's all about EJB 1.0 beta and my lead developer Laurent Quérel and I try to build something around EJBs and Persistence Powertier which would not look totally unlike Hibernate today. I begin to get the abstraction addiction. It'll take me a few years to get rid of this addiction.
  • 2000-2001 : the future is on the mobile phone, and WAP is going to be the next web. In full abstraction addiction mode, my team and I develop our own specialized application server, so that you can write a web application once and browse it from any web-enabled device, the presentation being abstracted and adapted to the zillion different devices that would soon access our apps. We develop half a dozen application with this application server before the net bubble explodes and we realise that it would need a few more years before the Internet on a mobile phone would become a Big Thing. One good thing, though : when we began this application server business, we drop all the EJB nonsense. We built our own IoC container, much like Spring. And we didn't need an ORM, because all we needed to map to was XML, dude. This was the time when I read & wrote a lot on the xml-dev mailing list.
  • 2002-2003 : I'm done with the abstraction addiction. I've got a challenging job, lots of work to do, and no much time to think and ponder about abstracting anything. The code I write must be straightforward and must get things done. I'm feeling more and more irritated by the verbosity of Java and the zillion XML configuration files I'm forced to write. An IoC container is a nice thing, but honestly, I sometimes feel that a simple scripting language would be much more suited to configure my apps. I begin experimenting with Jython. I also try for the first time Groovy, which is under development, but the language seems a bit goofy at the time, a patchwork of good ideas but nothing really as coherent as Python.
  • 2004 : OK, I finally get it. I need a dynamic language. I hesitate between Python and Ruby ; Ruby is more interesting but less polished, and at the time, a lot of documentation is badly translated from Japanese. I choose to invest in Python. I fall in love with Python. I use it first for any kind of data massaging tasks, then progressively for web development. I begin tinkering with mod_python, which will eventually lead to my active participation in the project. In the same time, I experiment with Zope, find it fascinating and decide to use it for a classic web application project. Big mistake, that I'm still paying for four years after.
  • 2005 : Ruby on Rails appears. People marvel at the thing. I don't get that the scaffolding demos that begin to invade the blogosphere have nothing to do with the real power of RoR. When watching those demos, I told myself "OK, that's really cool, but real apps are much more complicated than just CRUD screens". Of course, Sherlock, but do you really expect that things will be brighter in any other framework you can choose if even the basic stuff like CRUD is complicated ? Oh, and on August, the 23rd, my daughter Violette was born.
  • 2006 : it's time for a comeback to Java (nothing to add to what I've wrote at this time). I also work 50% on my time for Yoono, once again with Laurent Quérel. One day, walking back from lunch in a Parisian street, I recognize Guillaume Laforge, which I knew took over the leadership of the Groovy project. I tell him "Excuse me, but aren't you Guillaume Laforge" ? Yes indeed - I think he found it a little creepy to have reached celebrity to the point of being recognized in the street by total strangers :). Anyway, at the time, in the street in front of our offices, I naively propose him to work for Yoono, as we were looking for top notch Java developers. Of course he declined politely, but now that I know what Guillaume was working on, I'm glad he did !
  • 2007 : for a new big project, I hesitate quite a long time between Java + Spring + Hibernate + Struts, Python + Django and Ruby on Rails. I finally decide to give RoR a go. It's awesome. Nothing to regret as of today, except maybe my choice of MySQL + InnoDB tables which gives strange problems with table locks. Apart from that, I get the same rush than anyone else trying RoR : freedom and power ! However, the deployment model sucks. What, a single-threaded application server ? You have to launch multiple servers and load-balance between them using Apache 2.2 mod_proxy_balancer, lighttpd or Pound ? OK, I've done it with mod_proxy_balancer and it was no rocket science, but seriously, It's a bit of an hassle to manage. And the performance is not so great, I squeeze 60 reqs/sec per instance, with is totally sufficient for the app we built, but come on ? I get easily 4 or 5 times more reqs/sec with any badly configured Python or Java stack (please don't flame me for this obviously inane benchmark).
  • 2008 : Grails 1.0 is out. I have a new look at Groovy. It has been totally morphed into one of the coolest dynamic language out there under the lead of Guillaume Laforge. Groovy is now a true dynamic language, with a seriously good feature set. All my favorites from Python and Ruby are there. And it runs, fast, on the JVM. What can I say ? It looks almost perfect. Of course, writing such a language is a difficult task, and things could get ruined by weird lexical scoping interaction with closures or things like that (no, I don't think about any particular language, Ruby). But at first sight, it looks very, very good. Could I ask more ? A nice web framework running on top of the JVM ? Well, Grails sure looks promising, I can't wait to try it on a real application ! Performance-wise, my first benchmark tell me we're far above Ruby on Rails. Oh, and IntelliJ supports Groovy and Grails with a pretty cool plugin, too. So I guess life as a web developer is now perfect, end of story :).

And now for the punch line : I have now reached a position at work where I'm supposed not to code any more, at all.

WHAT ? All those years of sweating, fighting and yearning, and now that a good web development stack is out in the wild, I'm supposed to retire as a developer and become a friggin' MANAGER ? I tell ya, there's no justice anymore in this world.

Oh, and 13 years after, my browser still hangs for more than 15 seconds as soon as I try to load a page with an applet. Meanwhile, Flash objects load almost instantly, without any problem...

Monday, December 10 2007

Une idée lumineuse !

Ce matin dans le métro, une magnifique opération marketing du Groupe France Mutuelle pour promouvoir leur produit FC Santé.

Distribution générale d'une boite en carton 100% non recyclé, contenant une bonne dose de mousse 100% vrai pétrole équitable au sein duquel était lové une merveille de petit GiFiMi (la mascotte du groupe) en pur plastique du même métal.

Quelle merveilleuse attention en ces périodes de fêtes ! On imagine des milliers de petits neveux mal-aimés ou de belles-filles ingrates qui se verront refiler cet ersatz de Bibendum à Noël. Le dispositif doit être redoutablement efficace : le petit bonhomme pas en mousse planté au sommet du sapin de Noël, qui pourra hésiter à souscrire à une mutuelle avec franchise cautionnée (lire : si tu es malade, c'est de ta faute, tu paies, sinon on te redonne un petit bout de tes versements) ?

Bien sûr cela a donné lieu à un face-lift des plus tendances de la station (en l'occurrence, Mairie de Montreuil, mais apparemment d'autres stations ont subit le même sort) :

Ces photos ne sont que la partie visible d'un iceberg de boites éventrées qui débordaient de toutes les poubelles de la station, dans les couloirs, etc.

A en juger par la signature sur le flyer se trouvant dans la boite, c'est The Marketingroup et son sens de la relation qui ont oeuvré à cette réussite.

Le plus beau était sans conteste le volet événementiel de l'opération : le moment où en pleine heure de pointe, sur un quai bondé, le conducteur du train resté quelques minutes de trop à l'arrêt demande à tout le monde de sortir "pour cause de colis suspect dans le train". Au final, c'était une fausse alerte (et je ne sais pas si c'était lié) mais c'est sûr, on les regarde tout de suite avec plus de respect, ces centaines de boites en carton donc chacune pourrait contenir un pain de plastic de taille respectable.

Ecologique, ciblé, efficace et citoyen, que demander de plus ?

Thursday, May 10 2007

PullXML renamed to PushXML, hosted on Google Code

As the API for PushXML is definitely not a pull API (it is based on a callback instead), I've renamed PullXML to PushXML.

I have also decided to host this small project on Google Code, so that I can have a public Subversion repository, issue tracking and so on.

Here is the link to the project and here is a direct link to the latest version of PushXML.

Friday, April 27 2007

PullXML : an XML Pull Parser for PHP 5

You've got a big, big XML file to parse. You need to do it in PHP. Well, you're in deep trouble. Unless I've missed anything, here are the different alternatives I've seen, none of which satisfied me :

  • Use SimpleXML. Not possible here because your big, big XML file won't fit into memory.
  • Use DOM or DOM XML. Same problem, the file won't fit into memory, PLUS this time you get a notoriously crappy API.
  • Use XMLReader. No memory problem, this time. However the API is awkward, maybe it gets better using a combination of calls to XMLReader::expand() and XMLReader::next(), but then again it's back to the crappy DOM API.
  • Use The SAX-like streaming XML parser. This works, no memory problem, but then again it's pretty awkward, you have to implements a stack-based machine to do anything remotely useful if the XML document is a little bit complicated.

Well, after messing around with PHP for a few hours (man, this language is soooo weird ! I miss Python...), I came up with PullXML, an XML Pull Parser. It works in PHP 5, it could be ported to PHP 4 but frankly this is not something I look forward to doing :).

PullXML is implemented with the SAX-like streaming parser. It builds objects that look like SimpleXML objects, but instead of loading the whole document in memory, it builds them chunk by chunk and calls a callback you provide when a chunk is ready.

The chunks are delimited by the pivot, which is a simplified XPath expression that gives the path that each chunk must match. For example, if the pivot is /foo/bar, then PullXML will call your callback for each bar element that is in a foo element, including the content of the bar element, of course (otherwise this would be quite useless). But the best way to see how it works is to have a look at the source code and experiment with the example at the end.

I'm no expert in PHP and I haven't much used SimpleXML, so this must be quite buggy for the moment. Yet, it already does the job as expected on one of my projects. If you have any remark about the source code or any suggestion for a better compatibility with SimpleXML, feel free to leave me a comment.

Friday, March 16 2007

Ideas Worth Sharing and the Gapminder

This presentation from Hans Rosling is a definite must-see. The message about world health is enlightening, and the visualisation tools are impressive. This is one of the coolest thing I've seen for a long time, I mean in a "we should have thought about it before" way.

The great news is that you can do your best Hans Rosling impersonation by using the tools his Gapminder venture developed. They are available here, here and here.

Sunday, March 11 2007

Switched to DotClear 2 beta 6

Hi ! This is my first post under DotClear 2 beta 6. I've apparently succeeded in migrating from DotClear 1.2.5.

I only had a small problem with permalink begin moved to /index.php/2006/... to /index.php/post/2006/..., but I solved it by making a full export, tinkering the exported file with regexps, then performing a full import. Problem solved !

Now I need to customize the templates and re-add all the annoying widgets that my former blog had (or not). But that will be for another day, because I've got some work to to right now.

In any case, kudos to the DotClear 2 development team for this great release !

Wednesday, February 28 2007

It's about time !

It is now 2007 and for the first time in the history of mankind cometh a project management software that can handle multiple levels of undo. That was one of my main pain point with all the existing PMS.

It's even mentioned as a feature ! It's like they just discovered that multiple level undo was actually useful, and was worth being advertised. Like this was not a standard feature in every other kind of professional software (ahem... except those with web-based UI, of course).

Anyway, this might be the first actually usable PMS, so let's stop bitching and start evaluating the beast !

Update : well, I've tried it and it works. As expected. Now that I've got it, there's not much to be excited about multi-level undo :). I think it's been something like ten years now since I first played with MS Project, and apart from this "cool" new feature the product doesn't really seem to evolve. See the other pain points I've got with it there.

Friday, December 22 2006

Ma très chère Free.

Moi qui pensais avoir tourné la page l'an dernier sur deux ans d'incompréhension mutuelle, de silences gênés, de mesquines attaques financières, me voilà fort surpris et déçu.

Surpris, je le fus en te retrouvant au détour d'un relevé de banque, un an après notre séparation glaciale.

Je rappelle les faits : atteinte d'amnésie, tu m'obliges après un déménagement à faire plusieurs demandes d'ouverture de dossier. Tu m'ignores ensuite lorsque je demande le dégroupage total.

Enfin, un jour, tu m'entends mais m'envoie la Freebox je ne sais où (apparemment à mon ancienne adresse) et sans me tenir au courant. Parallèlement, les dossiers s'ouvrent en cascade, mais toujours sans dégroupage. Malheureusement, je ne pensais plus jamais avoir à ressasser tout cela, et les pièces justificatives me manquent aujourd'hui, disparues dans un grand autodafe libérateur, mais ce fut en tout cas une histoire très confuse et surtout très coûteuse.

En effet, quelques mois plus tard, tu me factures 400 euros pour non restitution d'une Freebox que je n'ai jamais reçue (voir le paragraphe suivant, il faut suivre). S'ensuit une longue lutte, des échanges maladroits, des appels infructueux à la coûteuse hotline, des recommandés avec accusé de réception, pour au final que j'obtienne gain de cause et que tu me rembourses (hormis les frais de procédure, comme on dit).

Note que j'étais toujours chez toi mais toutes ces maladresses avaient quelque peu entamé ma confiance en notre relation. Néanmoins, pour prouver ma bonne volonté et m'investir un peu plus dans notre couple, j'ai redemandé le dégroupage de ma ligne pour profiter de ton alléchante offre triple play.

Combien de couples malheureux pensent que faire un enfant leur permettrait de sortir de l'ornière ? Je ne sais, en tout cas plus de six mois après avoir fait ma demande sans être entendu de toi, je n'en pouvais plus. Lassé de payer les sempiternels 29 euros et des poussières par mois pour un ridicule 2 Mb sans téléphonie gratuite ni télévision, je décidais finalement de résilier mon abonnement pour refaire ma vie avec un autre fournisseur. Et de ce côté là, ça va très bien, merci.

J'étais donc surpris de recevoir des nouvelles de toi dans mon relevé bancaire, mais déçu de leur teneur. Apparemment, tu vis dans un monde fantasmagorique où mon numéro de téléphone fixe est toujours 01 43 78 WX YZ, et où je suis toujours abonné à tes services. En conséquence de quoi, tu as continué à me prélever consciencieusement 29,99 euros par mois depuis plus d'un an.

Oh, je sais, c'est un peu de ma faute, j'aurais dû vérifier de plus près mes relevés de banque, et ce depuis longtemps. Mais que veux-tu, je suis comme ça, confiant dans mon prochain, et malgré toutes nos difficultés, je ne pensais pas que tu pourrais vivre dans un tel déni de la réalité.

Tu vois, je te parlais d'une histoire coûteuse, et je sens confusément que ce n'est pas fini, car nous allons encore devoir nous échanger moults recommandés avec A/R, moultes additions salées à ta hotline payante (il y en a encore pour longtemps), et moults énervements de ma part, qui ne se facturent pas à court terme mais qui finiront bien un jour par grever le budget de la Sécurité Sociale. Mais si mes comptes sont justes, après les 400 euros de la Freebox, c'est maintenant près de de 360 euros que tu m'as injustement prélevés, et pour lequel tu me forces à me battre.

Mon premier réflexe lorsque je me suis rendu compte de on problème, je l'avoue, était de me mettre en colère. J'ai derechef appelé ma banquière préférée pour faire opposition à tes prélèvements. Cela manquait de cordialité, j'en conviens, mais songe au temps qu'il te faut pour répondre à chacune de mes solicitations (deux mois minimum), tes prélèvement concomittants auraient compliqué les choses.

Tu me permettras néanmoins de trouver une certaine ironie au mail que j'ai reçu de ta part ce matin à 6h30 (je me suis permis de l'annoter) :

Bonjour,

Hey, baby, ça farte ? Ca fait un bail !

Vous êtes abonné au forfait Free Haut Débit sur la ligne 014378WXYZ.

Plus vraiment, non, tout est fini entre nous depuis un an. D'ailleurs je ne suis plus non plus abonné à France Télécom donc à ce numéro, je n'habite même plus au même domicile.

Conformément à la facture N° 12-53437260 établie le 02 Décembre 2006
nous avons émis une demande de prélèvement d'un montant de 29.99 euros
auprès de votre établissement bancaire.

A quelle adresse m'as-tu envoyé cette facture et toutes celles qui ont précédé ? J'ai souscrit à un transfert de courrier suite à mon déménagement, je n'ai malgré tout rien reçu...

Il semble que ce prélèvement ait été refusé par votre Banque pour le
motif suivant :
       Tirage contesté par le client (70)

Je veux, oui... Plus de tirage entre nous, ma poupée.

Pour régulariser votre situation auprès de nos services, il serait
souhaitable de nous envoyer au plus vite :
   - Soit par chèque pour un montant de 29.99 euros à l'ordre de
       Free Haut Débit (Ne pas oublier de mentionner le numéro de téléphone
       de la ligne concernée au dos du chèque)
       à envoyer à l'adresse suivante : Free haut Débit  75371 Paris cedex 08

       - Soit par carte bancaire en téléphonant au 3244 (0,34 TTC par mn à
       partir dun poste fixe) du lundi au vendredi de 8h30 à 19h00.

Ouh la, je vais me dépêcher alors. Et puis, c'est vraiment la grande classe de faire payer 0,34 euros TTC par minute, car j'imagine que ce sont des euros, pour payer une mensualité qui n'est pas dûe. Franchement, baby, tu me déçois.

Si vous avez changé de banque, merci de nous retournez les documents
ci-dessous :
- le RIB d'un compte bancaire valide pour effectuer les prochains
prélèvements
- une autorisation de prélèvement correspondant au nouveau RIB fourni
(disponible sur http://adsl.free.fr/comptes/modification.html )

En parallèle de votre modification à Free Haut Débit, vous devez prévenir
votre établissement bancaire et/ou postal de la mise en place du prélèvement
automatique qui sera intitulé "Free Haut Débit" code NNE 459654.

C'est amusant, j'ai exactement fait le contraire : interdiction de prélèvement pour le même code. Ah, et il y a une faute de grammaire, c'est "merci de nous retourner".

Si vous ne régularisez pas rapidement votre situation, nous serons
contraints de bloquer votre accès à Internet et d'engager les poursuites
nécessaires pour recouvrer les sommes dues.

Alors bon, je sais, cela va être dur, mais on va faire comme avec un sparadrap, d'un coup sec : mon accès à Internet n'existe plus depuis longtemps ! Je suis curieux de voir comment tu peux le bloquer. En ce qui concerne les sommes dues, j'en ai autant à ton service. Tu me dois du temps, aussi.

Nous vous rappelons que votre Facture est consultable en ligne à tout
moment à l'adresse :
       http://adsl.free.fr/conso/

Aaaah, c'est pour ça que je n'ai rien reçu ! Bon je vais voir. Euuuh :

La page demandée n'est pas disponible sur ce serveur

Bon ça a changé... Il faudra changer ce mail type quand tu écris à tes exs, ça ne fait pas sérieux. Je clique. Aaah, mais on me demande un identifiant et un mot de passe ! Mais ma pauvre petite, si tu crois que je m'en souviens... Bon, je clique sur "Vous avez oublié votre mot de passe". Tu me demandes mon identifiant... Je l'ai oublié aussi. Je mets un identifiant qui pourrait être vaguement le mien... Ah super, ça marche, tu vas m'envoyer mon mot de passe ! Pris d'un doute tout de même, je reviens en arrière et saisis connard. Ah super, tu vas lui envoyer son mot de passe, à lui aussi ! Youpi ! Allez, maintenant je tape lapin... Ouiiiiiiiii ! Et pere.noel ? Ohhh, lui aussi va le recevoir ! Franchement, tu es la pingre la plus généreuse que je connaisse.

L'équipe Free Haut Débit.

FAQ: http://faq.free.fr/?q=1075

Eh bien salut, Free, franchement tu ne me manques pas. Comme je te sens un peu dure de la feuille, je me suis permis de mettre tout ça sur mon blog (http://nicolas.lehuen.com/index.php/post/2006/12/22/120-ma-tres-chere-free), histoire que tous mes amis soient au courant, eux qui m'ont aidé lorsque tu me rendais si malheureux, lorsque je me sentais si seul, trahi par toi.

J'espère juste qu'un jour tu ouvriras les yeux et que tu réaliseras : non, Nicolas Lehuen n'est plus un de tes clients, et tu lui dois 360 euros. Franchement, si tu avais des problèmes d'argents, je ne dirais trop rien, mais ce n'est pas le cas...

Par ailleurs, si tu as besoin d'un peu de liquide, tu peux demander à ton patron, Xavier Niel, il a la méthode !

Update : bien sûr, lorsque j'essaie de répondre à ton mail à l'adresse de l'expéditeur, hautdebit@freetelecom.fr, j'ai une erreur car l'adresse n'existe pas. Décidemment, quelle classe !

Update 2 : je viens d’avoir une de tes collaboratrices au téléphone, m’indiquant que selon toi, je suis toujours abonné (sans blague) et que devais fournir la preuve de ma demande de résiliation. Figure-toi qu’après un an, je n’ai plus trace de mes justificatifs d’accusé réception. Comment va-t-on procéder ? Faute de mieux, je te réenvoie un formulaire de résiliation, prêtant ainsi le flanc à une vile attaque de ta part du style « puisque vous résiliez maintenant c’est que vous n’aviez pas résilié auparavant ». Hélas…

Tuesday, November 7 2006

Yoono at Web 2.0 Conference


Yoono at Web 2.0 Conference
Vidéo envoyée par nico2304
Froggies at the Web 2.0 conference, SF, CA.

Tuesday, October 24 2006

This is so true I'm practically crying

What should and should not be added to C/C++

Please, please, someone hear this guy and make us a programming language designed for portable performance on modern architectures !

Monday, October 9 2006

I wish I learned Japanese

When I was young (I'm talking days of yore, here, about ten years ago) and innocent, I was an engineering student at the INSA (Institut National des Sciences Appliquées, meaning National Institute for Applied Sciences). I was there for 5 years, and two of the best teachers I had were not math or physics teachers, but English teachers. Their courses were very important to me because they not only taught English, but also how to make a clear presentation and manage meetings. I'm using this every day, now. If I compare this to the tons of math I've learned (sometimes at 30 hours a week doses, the rest being computer science), which I'm using at somewhere near 5% now, the yield of those English courses is clearly superior. Mr. and Mrs Souillard, thank you ! I hope my awkward writing won't be a disgrace to your teaching standards.

Anyway, Mr. Souillard also taught optional Japanese lessons, but I've decided not to follow them, because, you know, I had much more interesting things to do, like more maths or physics (and, to be comprehensive, drink booze, play video games and make out with girls).

So, it looks like there is a justice, after all, because my pytst code has been noticed by some Japanese people, and I can't understand what they write about it. Masaki Yatsu contacted me today to announce that he ported pytst to Ruby, apparently using SWIG. He also added support for multibyte character sets, which is obviously pretty important in Japanese. This is the part I've understood, because he wrote me in English. Unfortunately, his blog is in Japanese. Check out the Google Translation result, if you want to have some fun. I can barely understand 25% of what Masaki writes (and to be clear, it's only my fault :).

As for odz's blog entry, it was much worse, because I couldn't get whether he had better or worse results using pytst versus Perl regexp (it turns out my code performs ten times better for his use case, yay!).

I'm not sure one or two years of learning Japanese would have helped me much in this situation, though. I guess in the best case I would have the same level of understanding that Google Translation gives me. But at least I wouldn't feel such a dork, instead I would be bragging about my deep knowledge of kanji.

Anyway, it's good to see one's code reused by people from the other side of the planet, with different alphabets and character encodings, apparently without too many problems. I'm getting a warm and fuzzy feeling from that :).

Incidentally, since I've posted a comment on odz's blog, some spam crawler has fetched my email address, and I now receive spam in japanese. Wonderful. My bayesian anti-spam filter is so happy to get all those new words to learn ! Actually it's not.

Saturday, October 7 2006

Neat trick : a Factory embedded in the interface of the object it builds

I've seen this trick performed by IntelliJ when using their integration with Google Web Toolkit. Usually, you've got an API defined as an interface, and you need a factory to build an implementation of the interface. The factory uses some configuration information to choose an implementation :

public interface MyService {
    // ...
}

public class MyServiceFactory {
    public static MyService getMyService() {
        // ... load configuration and return an instance of a class implementing MyService
    }
}

// Usage example : 

MyService serviceP = MyServiceFactory.getMyService();

Of course there are hundreds of variations to this pattern, with or without singletons for the factory etc. The trick I've seen performed by IntelliJ relies on the fact that you can define an inner class in an interface :

public interface MyService {
    // ...

    public static class Factory {
        public static MyService getMyService() {
            // ... as before...
        }
    }
}

// Usage example :
MyService serviceP = MyService.Factory.getMyService();

It doesn't change much but it feels cleaner like that ; of course you can't implement factories of factories of factories, if that's your pleasure, but to me it's way simpler to have the factory defined right in the interface.

Java Map literals, continued

Here is a better map literal, since it keeps keys close to their values :

public class Literals {
    // ...

    public static <S, T> MapBuilder<S, T> map(S key, T value) {
        return new MapBuilder<S, T>().map(key, value);
    }

    public static class MapBuilder<S, T> extends HashMap<S, T> {
        public MapBuilder() {
        }

        public MapBuilder<S, T> map(S key, T value) {
            put(key, value);
            return this;
        }
    }
}

// Example usage :
import static Literals.map;

Map<String,Integer> example = map("hello",1).map("world",2).map("!",3);

pytst 1.14 for Python 2.3, 2.4 and 2.5

It's been a few months since my last release of an official version of pytst. Seeing that someone in Japan uses it made me have a look at the project once again. If I remember correctly, the latest evolutions where mostly refactorings in the hope that I could come up with on-disk storage of the tree, plus a few experiment on my full text indexing system based on the TST (which I won't release yet). So, I'm releasing the latest version, having made sure that it compiled correctly for Python 2.3, 2.4 and 2.5 on Win32 and Ubuntu Linux (I only tested Python 2.4 on Linux)

I've been pretty busy lately, what with the fact that I now have TWO regular jobs (both theoretically being at 50%) : I'm still CTO at The CRM Company, but I am now VP Product & Marketing (and developer :) ) at Yoono on top of that. Interesting times...

My work on TSTs has been used at Yoono ; my friend (and now boss) Laurent Quérel and I have gone a bit further with TSTs and came up with a kind of TST which can store multiple characters per tree node. Any time some part of a prefix can be shared by multiple keys, the part is fully stored in the node and not duplicated, thus saving a lot of unnecessary nodes and navigation. Though it surely exists somewhere, we haven't seen it anywhere else, so we decided to simply call this kind of TST a CompactTST. What's interesting in this TST is that it has a very low memory overhead : the indexing structure only adds 10% to the bulk volume of the data (string key + integer value in our case) it contains.

As I've wrote previously, my work on Yoono made me switch back to writing Java. Hence, the CompactTST is written in Java, but with a low-level edge : like I've did in C++ for pytst, we didn't want to build a Java instance per tree node. Our solution is a bit rough but it does work perfectly : we store nodes in a byte[], manually managing the layout of nodes and the storage of their data in the byte array. The result is pretty fast, very compact and the GC doesn't work at all.

This gave me the idea of reusing this method to store a big number of objects in memory. Now that we have 64 bit servers with 8 Gb memory, why not make the most of it ? So currently I'm on my way to storing tens of millions of objects in memory through my own memory allocator system, implemented on top of multiple byte arrays, without any problem caused by memory or GC overhead. Of course, this means that I can't rely on the GC anymore, but it's the whole point anyway. We now have a way to store millions of String, int, List<Integer> and List<String> in an efficient way. I'm sure die hard Java developers would cringe at what we are doing, but it's fun and worthwhile.

I'm still planning on writing pytst 2.0, this time with a proper storage layer which will make me able to switch from memory-based to disk-based storage. Now that we have a neat CompactTST in Java, I'll take the opportunity of porting the algorithms to C++ at the same time. It's only a matter of finding the time to do it, which is easier said than done...

Tuesday, September 12 2006

DailyMotion is fun...


White Man Can Dance......
Video sent by Cha_Cha_Chandni
This is a test of direct blog posting from Dailymotion... Looks like this is working great !

Friday, July 21 2006

The Rise and Fall of CORBA

A few weeks ago I compared SOAP to CORBA. Well, be scared, because looking at the history of CORBA gives a lot of information about what issues SOAP might encounter. Granted, things may be a little bit more rosy with SOAP, and the use of HTTP, URLs and XML solved a lot of technical problems, but the part about the political reasons of the CORBA mess still apply today.

One thing that surprised me while reading the article is that the rise and fall of CORBA really took place during the late nineties, when I started my career. As a rookie I thought CORBA was an established and proven technology. How naive I was :).

Tuesday, June 20 2006

The Scala programming language

The Scala Programming Language. Pretty interesting. There are even features that match my wildest dreams. Runs on the JVM.

Tuesday, May 30 2006

SOAP Web Services : awkward. Python and Web Services : painful.

So, I had managed to dodge it until now, but that's it, we're in 2006 and I need to use SOAP web services. Back in 2002 I was implementing and consuming REST+XML or XML-RPC web services all over the place. At the time, SOAP smelled like... well, let's says it definitely didn't smell like soap. Today, I'm not a slightiest bit more convinced, but when you gotta do it, you gotta do it.

So yes, I used Java and the AXIS web services library to consume web services, namely the Google Adwords API and the Amazon Electronic Commerce Services. Of course, Java isn't a dynamic programming language, so you have to generate a bunch of code using the WSDL2Java compiler, but it's not that difficult. You then get a true Java API that smells like... well, it doesn't smell very soapy either.

I mean, I've already given a sample of the need to instantiate a factory to get a locator service that will build a service implementation that you need to configure. It isn't pretty. But that's only the initialization part. Then, you use an API that has been obviously generated by a computer and doesn't feel user friendly at all. It's a bit like a DOM API from another dimension. Well, let me pat myself on the back for this cunning analogy, because it is in fact exactly that : the AXIS toolkit did its best to build wrappers around the structure of request and response documents. XML documents, mind you, and I won't even add insult to injury by reminding my wide audience that those structures are specified in the Ruth Goldberg XML Schema format.

Well, give me embedded XML litterals like in E4X or C# 3.0, and native XPath support like in... well LINQ (also in C# 3.0, there's a thing going on here), and you've got a proper toolkit to consume web services. But here, AXIS generates a bunch of wrappers that are quite awkward to use as soon as the document structure is a tad complicated. Pretty soon you wish you could stop using those wrappers and access the raw XML nodes (preferably using the XOM API, but that's another story). I'm sure there's an option somewhere that allows you to do that, but I could not find it, and given what I saw, I expect the result to be quite messy.

Anyway, while struggling with all those bells and whistles, I told myself "Hey, all this mess is caused by the static typing of Java, why not try to do it in Python ?". Why not, indeed ? Well, because if using SOAP Web Services in Java is awkward, in Python, it's actually painful, because It Just Won't Work™.

Oh, I know the documentation are wonderful, and dynamic typing allows for wonderful proxy thingies that all work my magic... CORBA is just sweet in Python (see omniORB), because you don't have to worry about code generators and compilers and so on. You give your ORB an IDL file and bam, it works. Or not. But that's another story.

Well, it's not, actually, because SOAP Web Services are actually a stripped down, crappy version of CORBA, WSDL being a tricky, complicated version of IDL. So you'd expect the experience to be similar, and it is : you give your SOAP library a WSDL and bam, it works.

Except it doesn't. Because in the Python world, XML libraries in general and Web Services in particular are either half implemented or not unmaintained since the heidy days of 2000-2002. One of the brand new things in Python 2.5 is the inclusion of ElementTree, a replacement Python-friendly DOM API for the pile of non-standard crap that we have right now. Isn't it about time ?

For web services, the situation is much worse, and the sad truth is that you can use ZSI or SOAPy to consume web services, but you've got a very high chance that it won't be compatible with obscure web services like the one proposed by Google, Amazon or Yahoo. Thanks god the two later also provide REST APIs... But right now it's the Google APIs that interest me. And Google said "thou shall use SOAP, SOAP thou will use". And the Python SOAP APIs don't understand. We might as well use CORBA, for that kind of "interesting" incompatibilities.

raimondas says "Python Web Services - Not Quite Painless", but I feel that for the sake of precision, we should simply say "Python Web Services - Actually Quite Painful".

The good thing is, like for all painful things, it's a relief when it stops. I really didn't expect to enjoy using Java and AXIS for this. Oh, well...

Friday, May 19 2006

Yoono was at XTech 2006, will be at Supernova 2006

Yeah I know, I should have written this before going to the XTech 2006 conference in Amsterdam... But anyway, we saw some pretty interesting presentations, met nice people like Daniel Glazman, Tristan Nitot, Mike Shaver, Chuck Bearden and a bunch of other people, quite a pleasant crowd indeed. It was nice to get out of the wood and start explaining Yoono to new people, practicing my pretty poor english pronunciation.

This was a nice training for our trip to the Supernova 2006 conference in San Francisco (Yoono is a proud sponsor of the conference BTW :). This time I'll try to bring a slim enough digital camera ; in Amsterdam I couldn't carry around my ante-diluvian Canon Powershot S30, it wouldn't fit any of my pockets...

Aaahhhh, San Francisco... In 2000 I attended the JavaOne conference, and it was great. I love this city, I just hope this time we'll manage to accomodate a few hours here and there to visit it more thoroughly.

- page 1 of 6