Home → 2003 / « 09 »

24 days

24 days to decide if I should stay in a new land I just arrived in. Land that I am not familiar with. Land where things are a little bit slower than they are in my native land.

Going there was easy. Living there will be difficult at first. I will have to learn even the most basic things that their people are already so familiar with. So familiar that I am afraid that I will have trouble obtaining quick help about the most basic survival tricks.

When I traveled to their place, I did not have to give up my rights to go back to my home. But in 24 days, I may not be able to come back unless I buy my right to come back. 149.00$ cdn. Not a lot of money. But I must decide between staying in this free land with all the insecurity I will experience, or go back home where everything is where I expect it to be.

Home → 2003 / « 09 »

Java > Python > XPath/XSLT

Still reading about Python. In Dive Into Python, the first Object-Oriented example is about listing MP3 files in a given directory. The module contains around 50 lines of code. In Java, I guess there would be twice as many lines. But would'nt it be cool if there was a command line XPatn/XSLT app that could do file system searches? Something that may look like this:


c:\>dir -xsl <for-each select="/dir[@name='music']//file[@type='mp3']"> \
               "name = " <value-of select="@name"/> \
               " title = " <value-of select="@title"/> \
               " artist = " <value-of select="@artist"/> \
               " album = " <value-of select="@album"/> \
             </for-each>

I guess this already exists.

More on Java's Checked exceptions

These days, on my spare time, I dive into Python. Well, I am still in the air at this time with only my fingers in the water. But the water is very welcoming.

Introspection

Python makes introspection simple. As I read about it, I remembered how Java's introspection and reflection APIs can sometimes give headaches. These headaches are in fact indirectly caused by Java's checked exceptions (There are many discussions about advantages or disadvantages of checked exceptions in Java as opposed to unchecked exceptions in Python.)

When using reflection to invoke methods, if the method invoked throws any exception, this exception is wrapped inside a java.lang.reflect.InvocationTargetException before returning from the invoke call. This also applies to instantiation methods (newInstance for example). But often, you will bump into code that looks like this:


 1  ...
 2  try {
 3    ...
 4    method.invoke(object, args);
 5    ... // do other stuff that may throw SomeException
 6
 7  } catch(SomeException e){
 8    // do something special about this exception
 9  } catch (Throwable e){
10    // do something else
11  }
12  ...

If the invoked method throws SomeException, the caught exception at line 7 will not catch it. The exception that will pop up here will be an InvocationTargetException that embeds SomeException. To behave as expected, this code should be minimally rewritten as:


 1  ...
 2  try {
 3    ...
 4.1  try {
 4.2    method.invoke(object, args);
 4.3  } catch(InvocationTargetException e){
 4.4    throw e.getTargetException();
 4.5  }
 5    ... // do other stuff that may throw SomeException
 6
 7  } catch(SomeException e){
 8    // do something special about this exception
 9  } catch (Throwable e){
10    // do something else
11  }
12  ...

With this change, we rethrow the exception thrown from the invoked method. This exception is then caught as expected at line 7.

Of course, the first code excerpt is not good code even if it compiles without warnings: It is not recommended to place a lot of code inside a try/catch block. If we had been careful in catching exceptions along the way, but without paying attention to the InvocationTargeException, we may have written this:


 1  ...
 2  try {
 3    method.invoke(object, args);
 4  } catch(SomeException e){
 5    // do something about SomeException
 6  } catch (Throwable e){
 7    // do something else
 8  }
 9  try {
10    ... // do other stuff that may throw SomeException
11  } catch(SomeException e){
12    // do something special about this exception
13  } catch (Throwable e){
14    // do something else
15  }
16  ...

Once written, you compile it and boom!, there is an error at line 4: SomeException is never thrown in try block. Or something like that. Using a better programming style would have caused the error to be identified early: we would have wondered why this does not compile and soon realize that the invoke method throws a InvocationTargetException which may embed SomeException. We would have changed code according to this fact at compile time, which is a good thing.

Java has forced checked exceptions on us programmers with the hope to see better code out there. As a result, it is harder to write good code and laziness being such a strong force of nature, we take short cuts with traps that hide bugs. And these bugs can take a lot of time to identify.

+1 to Python in this domain.

Home → 2003 / « 09 »

In French: 'À hauteur d'homme'

Excerpt:

À peu près tout a été dit à propos du documentaire sur M. Landry. Je vais quand même exprimer quelques opinions là-dessus. Premièrement, je suis dans le camp de la majorité qui croit que M. Landry a été bien... more

Home → 2003 / « 09 »

In French: 'Le 11 septembre'

Excerpt:

Attentat poétique "Le meilleur des Mondes" d'Aldous Huxley C'est à la lecture de ce livre il y a longtemps que j'ai compris que le consensus social n'est pas nécessairement acceptable.... more

Home → 2003 / « 09 »

In French: 'Sites multilingues'

Excerpt:

Il y a quelques mois (ironiquement, le jour de la fête de la St-Jean), je publiais un article intitulé "English only please" (et sa suite). En gros, j'y mentionnais que je crois préférable de ne pas offrir de contenu... more

Home → 2003 / « 09 »

In French: 'Téléréponse: attention'

Excerpt:

J'ai appris dernièrement qu'avec le service Téléréponse de Bell, on peut maintenant écouter la personne qui laisse un message PENDANT qu'elle laisse le message. Sur le coup, je me suis dis "big deal", enfin le système de Bell se comporte... more

Home → 2003 / « 09 »

Spam origin

When I am forced to enter my email address before a download, or during a subscription process, I very rarely use my main email address. Instead, I use an email address that contains the web site where I am submitting this information. For example, if I subscribe to JDJ for whatever reason, I will use the email address jdj@mydomain.net where mydomain, of course, is replaced with one of my domain names. This does not prevent spam to end up in my mailbox: anything sent to my domain ends up in my inbox (filter rules may be applied to these incoming messages but this is not the point.) Using these addresses, I can identify the sites that do not respect their own privacy policy.

JDJ. Java Developers Journal. This company is the worst of all identifiable subscriptions I made. I keep receiving spam sent to jdj@mydomain.net. Generally, it comes from JDJ, but today, I received something from Verisign sent to this address. So Verisign is a spammer as well. JDJ sells its readers email addresses to other companies. JDJ is a spammer.

Home → 2003 / « 09 »

Blogging about blogging

If you look at my blogroll (the links on the left), you can notice that most sites discuss weblog-related stuff (this is true on September 3rd, but may not be true if you read this later.) It is a little bit as if you like photography so much that you end up taking pictures about how to use a camera. In the process, you forget to take pictures that really mean something to you.

Blogs tend to naturally organize themselves into circles of interest. When you get into a circle, you eventually end up identifying the leaders. Once you have found important leaders, you generally do not need to go further as the rest of the bunch (those like me) is generally referring to these leaders. Consequently, my blogroll lists some leaders in the weblogging community that blogs about blogs.

I am a Java expert. So I am now looking for weblog leaders in the Java development circle. I started at JavaBlogs and I found a potential leader (I cannot tell for sure since I am just peeking at this circle.) He is a funny guy, I must say. Rude, but funny. I especially liked the faked interviews. I will refer to him as the DiveIntoJava guy -- style wise.

Here is an excerpt from the faked interview with Marc Fleury:

BB: You've often advocated the powers of JBoss caching, can you tell us a bit more about it?

MF: Actually, JBoss caching is very clever and complex. We give you the fabled option D to compete with options A, B, and C. We allow for incredible amounts of tweaking of cache behaviour, we've even implemented some truly mind boggling paradigms that reflect real world needs. Performance is clearly an academic issue, in the real world, people simply like as many options as possible. JBoss is so clever that it allows you to tweak these options to your heart's content, yet we always ensure we come out last in any performance test, in order to maintain consistency. We realize that every single application server other than JBoss has superior caching configuration and performance, but what we lack in those areas, we make up for in tweakability and lack of documentation.

Home → 2003 / « 09 »

'En vrac', and the blackout

Mostly French links. But here is help from an Iraqi editorial on how to handle a blackout : Try to keep bottles of water around and avoid opening the fridge looking for snacks. And most important of all, make sure to buy a hand-held fan. And when it's all over, just think, it only lasted a day. Now, try it for four months. Do you get it? (Via Salam Pax)