Tuesday, July 26, 2005

Java is more productive than Ruby/Rails

I have been doing some Ruby On Rails, for 2 small projects. While I think it is good, I think it is overhyped as well. It is well designed, has good ideas (easy configuration), and focus on the right problem, architecture. But my conclusion is that I am not more productive with it than with Java.

I think most of the development time is not spent coding, but thinking. It is a very obvious statement, and yet too often ignored.

The current Joel On Software article is just making my point: if you look at how much time it took the students to complete their program, you can see it is not the writing that took that much time. And I am sure you noticed the same on your own projects.

So all the nice features of the Ruby language don't save you a lot of time. And actually when your code size is growing, it becomes increasingly difficult for an outsider to understand your program. Everything can be so dynamic, and your only help is a syntax coloring editor. Compare that to Eclipse, or IDEA, or Netbeans, where you have very convenient search, not text search, but search for declarations, for calls, of methods, variables, classes, all that just a mouse click away. Strong typing goes a little bit in the way while writing, but helps understanding better in many cases (personally I wish Java had type inference, as all the verbosity is not always needed). And when if you really want less verbosity, then you have access to a handful of JVM languages.

A drawback of Java is maybe that you have access to too many libraries. Sometimes, making a choice among the bazaar is not easy and the hype gets scattered.

Tags:

Java is more productive than Ruby/Rails

I have been doing some Ruby On Rails, for 2 small projects. While I think it is good, I think it is overhyped as well. It is well designed, has good ideas (easy configuration), and focus on the right problem, architecture. But my conclusion is that I am not more productive with it than with Java.

I think most of the development time is not spent coding, but thinking. It is a very obvious statement, and yet too often ignored.

The current Joel On Software article is just making my point: if you look at how much time it took the students to complete their program, you can see it is not the writing that took that much time. And I am sure you noticed the same on your own projects.

So all the nice features of the Ruby language don't save you a lot of time. And actually when your code size is growing, it becomes increasingly difficult for an outsider to understand your program. Everything can be so dynamic, and your only help is a syntax coloring editor. Compare that to Eclipse, or IDEA, or Netbeans, where you have very convenient search, not text search, but search for declarations, for calls, of methods, variables, classes, all that just a mouse click away. Strong typing goes a little bit in the way while writing, but helps understanding better in many cases (personally I wish Java had type inference, as all the verbosity is not always needed). And when if you really want less verbosity, then you have access to a handful of JVM languages.

A drawback of Java is maybe that you have access to too many libraries. Sometimes, making a choice among the bazaar is not easy and the hype gets scattered.

Tags:

Thursday, July 21, 2005

féminisme et statistiques

Sur ce lien, un article un peu trop long, mais avec pas mal de points intéressants:
  • 6 femmes par mois décèdent, en France, par violence conjugale, soit plus que le nombre de victimes du metro anglais sur un an. Pour toutes les statistiques sur les chances de mourir suivant les causes, aux Etats-Unis, cliquer ici (on voit notamment que le plus grand risque est l'accident de voiture, ou la chute, ou le suicide par arme à feu, devant les attaques par arme à feu).
  • Un petit rappel sur l'antiféminisme chrétien, les femmes y étant qualifiées: de «défectuosité naturelle», de «raté de la création», d’«animal inquiet», de «mouche éphémère», de «méchante bête», de «porte du Diable», de «sac de fiente», de «diable domestique», de «racine du Mal», de «rejeton de tous les vices», de «piège tendu par l’ennemi», de «terre puante», d’«appendice de la race humaine». Ce qui lui permet d'ajouter: «Au lieu d’expliquer la misogynie des hommes par celle des religions, ne faudrait-il pas plutôt expliquer la misogynie des religions par celle des hommes?».
  • Une citation intéressante sur le voile en France: «ces filles qui affichent leur voile dans une société laïque sont le pendant exact de celles qui le refusent dans une société musulmane» laisse à réfléchir; et aussi un développement sur Theo Van Gogh dépeint ici en tant que raciste, misogyne et opportuniste, un avis que je ne partage pas.
C'est un peu extrême par moments, mais souvent juste. Sur le même sujet, Le Monde avait un petit article sur les wagons réservés aux femmes à Tokyo. Bon, j'ai peut-être un peu pété les plombs avec toute cette lecture.


Tags: .

féminisme et statistiques

Sur ce lien, un article un peu trop long, mais avec pas mal de points intéressants:
  • 6 femmes par mois décèdent, en France, par violence conjugale, soit plus que le nombre de victimes du metro anglais sur un an. Pour toutes les statistiques sur les chances de mourir suivant les causes, aux Etats-Unis, cliquer ici (on voit notamment que le plus grand risque est l'accident de voiture, ou la chute, ou le suicide par arme à feu, devant les attaques par arme à feu).
  • Un petit rappel sur l'antiféminisme chrétien, les femmes y étant qualifiées: de «défectuosité naturelle», de «raté de la création», d’«animal inquiet», de «mouche éphémère», de «méchante bête», de «porte du Diable», de «sac de fiente», de «diable domestique», de «racine du Mal», de «rejeton de tous les vices», de «piège tendu par l’ennemi», de «terre puante», d’«appendice de la race humaine». Ce qui lui permet d'ajouter: «Au lieu d’expliquer la misogynie des hommes par celle des religions, ne faudrait-il pas plutôt expliquer la misogynie des religions par celle des hommes?».
  • Une citation intéressante sur le voile en France: «ces filles qui affichent leur voile dans une société laïque sont le pendant exact de celles qui le refusent dans une société musulmane» laisse à réfléchir; et aussi un développement sur Theo Van Gogh dépeint ici en tant que raciste, misogyne et opportuniste, un avis que je ne partage pas.
C'est un peu extrême par moments, mais souvent juste. Sur le même sujet, Le Monde avait un petit article sur les wagons réservés aux femmes à Tokyo. Bon, j'ai peut-être un peu pété les plombs avec toute cette lecture.


Tags: .

Wednesday, July 20, 2005

Ruby, Python, JavaScript, Lua, Java, C++ benchmark

Simple benchmark but with interesting comments here:

Some of the conclusions are:
  • Java interpreter is very good
  • Java JIT is as fast as C++
  • Ruby, JavaScript, Python are of similar order of magnitude speed, Ruby the slowest.
It would have been interesting to benchmark interpreted languages for the JVM.

Now for most projects, architecture, not language is key in achieving good performance.

Tags:

Ruby, Python, JavaScript, Lua, Java, C++ benchmark

Simple benchmark but with interesting comments here:

Some of the conclusions are:
  • Java interpreter is very good
  • Java JIT is as fast as C++
  • Ruby, JavaScript, Python are of similar order of magnitude speed, Ruby the slowest.
It would have been interesting to benchmark interpreted languages for the JVM.

Now for most projects, architecture, not language is key in achieving good performance.

Tags:

Tuesday, July 19, 2005

Fowler On Your Future: editing the abstract representation of a program

This Fowler article on "language workbench" reminds me of Gosling Jackpot ideas: it is about a different interaction with your program where the source code does not matter so much, but its structure. It must be fascinating to work on this kind of project.

Maybe MDA sounds similar to you, after all, actual language workbench systems are generating source code. But the fundamental difference is that a workbench generated program is much richer and can capture everything you want to do (MDA is too based on UML to be that powerful), also, the source could disappear and be replaced by byte codes only.

Now this all seems very nice, but unfortunately, there are always problems, and Fowler does not miss them: vendor lock-in (not that big of a deal if source is generated), integration with dev tools (especially version control), maturity. It looks like an open source language workbench would help here.

It is interesting to see that Intellij (yes, the company behind IDEA) is already well on its way. You can check it out in Fowler examples. His examples are a bit too simple and not very far off rules in rules engines, but the language definition tool does look very neat.

As Rainer Joswig shows in his video, LISP seems like a particularly good language to do this. This is hardly surprising since LISP is very near the abstract tree structure and therefore already very used in the AI circles.

Tags:

Fowler On Your Future: editing the abstract representation of a program

This Fowler article on "language workbench" reminds me of Gosling Jackpot ideas: it is about a different interaction with your program where the source code does not matter so much, but its structure. It must be fascinating to work on this kind of project.

Maybe MDA sounds similar to you, after all, actual language workbench systems are generating source code. But the fundamental difference is that a workbench generated program is much richer and can capture everything you want to do (MDA is too based on UML to be that powerful), also, the source could disappear and be replaced by byte codes only.

Now this all seems very nice, but unfortunately, there are always problems, and Fowler does not miss them: vendor lock-in (not that big of a deal if source is generated), integration with dev tools (especially version control), maturity. It looks like an open source language workbench would help here.

It is interesting to see that Intellij (yes, the company behind IDEA) is already well on its way. You can check it out in Fowler examples. His examples are a bit too simple and not very far off rules in rules engines, but the language definition tool does look very neat.

As Rainer Joswig shows in his video, LISP seems like a particularly good language to do this. This is hardly surprising since LISP is very near the abstract tree structure and therefore already very used in the AI circles.

Tags:

Saturday, July 16, 2005

Jython instead of Ant: sample code

Here is an example of how to use jython to deploy a web application under tomcat. The application is supposed here to be WAR packaged in a 'web' directory. Libraries used for the web-app are already in web/WEB-INF/lib, classes are compiled automatically by Eclipse under web/WEB-INF/classes, and resources are copied automatically by Eclipse. If necessary, it is very easy to script those actions in the python script, with very little code.

The longest code is the TreeCopier class, that should probably be part of any python make script. The reload method could be reworked to provide a generic method for reloading a tomcat web application. The following is just a working sample code as proof of concept.

# call jython make.py method1 method2, ...
# to invoke method1 and then method2, ...

import sys, os, os.path, shutil, urllib, base64, re
web_dir = 'web'
webapp_name = 'myrestaurant'
tomcat_dir = 'c:/java/Tomcat 5.5'

#copy web directory to tomcat app dir
def deploy():
target_dir = tomcat_dir+'/webapps'+'/'+webapp_name
copier=LatestTreeCopier()
copier.copytree(web_dir,target_dir)
print "copied %s file(s) to %s" % (copier.count,target_dir)

#reload tomcat web application
def reload():
url = "http://localhost:8080/manager/reload?path=/"+webapp_name
base64string = base64.encodestring("%s:%s"%('michelin','michelin'))[:-1]
opener = urllib.URLopener()
opener.addheader('Authorization',"Basic %s"%base64string)
h = opener.open(url)
print h.read()
h.close()

class TreeCopier:
def __init__(self):
self.count = 0

def filter(self, srcname, dstname):
return true

def filterDir(self, srcname):
return true

def copytree(self, src, dst, symlinks=0):
"""Recursively copy a directory tree using copy2().
"""
names = os.listdir(src)
if not os.path.exists(dst):
os.mkdir(dst)
count = 0
for name in names:
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
try:
if symlinks and os.path.islink(srcname):
linkto = os.readlink(srcname)
os.symlink(linkto, dstname)
elif os.path.isdir(srcname):
if self.filterDir(srcname):
self.copytree(srcname, dstname, symlinks)
else:
if self.filter(srcname, dstname):
shutil.copy2(srcname, dstname)
print srcname
count += 1
except (IOError, os.error), why:
print "Can't copy %s to %s: %s"%('srcname', 'dstname', str(why))
self.count += count

class LatestTreeCopier(TreeCopier):
def __init__(self):
self.count = 0
self.excludePattern = re.compile(
'(^\.svn.*|.*\.swp$|.*\.bak$|.*~$|.*\.swo$)',re.I)
self.excludeDirPattern = re.compile('^\.svn.*',re.I)

def filter(self, srcname, dstname):
return (not self.excludePattern.match(os.path.basename(srcname)))
and (os.path.getmtime(srcname) > os.path.getmtime(dstname))

def filterDir(self, srcname):
return (not self.excludeDirPattern.match(os.path.basename(srcname)))


if __name__ == "__main__":
if (len(sys.argv)) >= 2:
methods = sys.argv[1:]
for m in methods:
method = m+'()'
print "launching %s" % method
eval(method)
else:
deploy()
reload()


technorati tags:

Jython instead of Ant: sample code

Here is an example of how to use jython to deploy a web application under tomcat. The application is supposed here to be WAR packaged in a 'web' directory. Libraries used for the web-app are already in web/WEB-INF/lib, classes are compiled automatically by Eclipse under web/WEB-INF/classes, and resources are copied automatically by Eclipse. If necessary, it is very easy to script those actions in the python script, with very little code.

The longest code is the TreeCopier class, that should probably be part of any python make script. The reload method could be reworked to provide a generic method for reloading a tomcat web application. The following is just a working sample code as proof of concept.

# call jython make.py method1 method2, ...
# to invoke method1 and then method2, ...

import sys, os, os.path, shutil, urllib, base64, re
web_dir = 'web'
webapp_name = 'myrestaurant'
tomcat_dir = 'c:/java/Tomcat 5.5'

#copy web directory to tomcat app dir
def deploy():
target_dir = tomcat_dir+'/webapps'+'/'+webapp_name
copier=LatestTreeCopier()
copier.copytree(web_dir,target_dir)
print "copied %s file(s) to %s" % (copier.count,target_dir)

#reload tomcat web application
def reload():
url = "http://localhost:8080/manager/reload?path=/"+webapp_name
base64string = base64.encodestring("%s:%s"%('michelin','michelin'))[:-1]
opener = urllib.URLopener()
opener.addheader('Authorization',"Basic %s"%base64string)
h = opener.open(url)
print h.read()
h.close()

class TreeCopier:
def __init__(self):
self.count = 0

def filter(self, srcname, dstname):
return true

def filterDir(self, srcname):
return true

def copytree(self, src, dst, symlinks=0):
"""Recursively copy a directory tree using copy2().
"""
names = os.listdir(src)
if not os.path.exists(dst):
os.mkdir(dst)
count = 0
for name in names:
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
try:
if symlinks and os.path.islink(srcname):
linkto = os.readlink(srcname)
os.symlink(linkto, dstname)
elif os.path.isdir(srcname):
if self.filterDir(srcname):
self.copytree(srcname, dstname, symlinks)
else:
if self.filter(srcname, dstname):
shutil.copy2(srcname, dstname)
print srcname
count += 1
except (IOError, os.error), why:
print "Can't copy %s to %s: %s"%('srcname', 'dstname', str(why))
self.count += count

class LatestTreeCopier(TreeCopier):
def __init__(self):
self.count = 0
self.excludePattern = re.compile(
'(^\.svn.*|.*\.swp$|.*\.bak$|.*~$|.*\.swo$)',re.I)
self.excludeDirPattern = re.compile('^\.svn.*',re.I)

def filter(self, srcname, dstname):
return (not self.excludePattern.match(os.path.basename(srcname)))
and (os.path.getmtime(srcname) > os.path.getmtime(dstname))

def filterDir(self, srcname):
return (not self.excludeDirPattern.match(os.path.basename(srcname)))


if __name__ == "__main__":
if (len(sys.argv)) >= 2:
methods = sys.argv[1:]
for m in methods:
method = m+'()'
print "launching %s" % method
eval(method)
else:
deploy()
reload()


technorati tags:

Tuesday, July 12, 2005

Java development without Ant

When Ant came out, I welcomed it. It was better than Makefiles for Java, it solved the path and classpath format difference between Windows and Linux, did not rely on shell programs. It did provide a platform independent way for building Java software. At that time, there was another alternative, JMK which had a lisp like syntax, and solved the same problems as Ant. But Ant was backed by apache, and this were the times of XML everywhere.
I got more and more fed up with ant scripts over the years. During a long time you had to resort to an XML trick just to include other ant file, you did not have conditionals, but more importantly, it is quite a pain to write long ant scripts in XML. XML is not that good to write logic with, XSLT did not become as big as it could have been partly for this reason.
Recently, Java IDEs (Eclipse) have made Java coding really comfortable, but why is it that for each project, you need to have to setup your project classpath, build, and write an ant script that does the same? In many companies I have seen ant scripts taking minutes to do a build in order to test your latest modification. This is crazy when it took a few seconds to eclipse to compile it, and it's already compiled, so why not using that output for testing your development? Ant, despite its codebase and age, does not do much: it does not calculate dependencies, it leaves that to the java compiler, it does not keep checksums of files to check if one has changed, it just uses file system dates (which can be a problem if you retrieve an older version of some file).
Now I am using a Jython script that justs copies my eclipse build and packages it appropriately, it works well, it is fast, it is flexible (all the power of python), and platform independent. You need to be a bit careful how you choose to design your Jython script, but hey, even with Ant limitations on messing everything around, I have seen so many awful Ant scripts.


Technorati tags:

Java development without Ant

When Ant came out, I welcomed it. It was better than Makefiles for Java, it solved the path and classpath format difference between Windows and Linux, did not rely on shell programs. It did provide a platform independent way for building Java software. At that time, there was another alternative, JMK which had a lisp like syntax, and solved the same problems as Ant. But Ant was backed by apache, and this were the times of XML everywhere.
I got more and more fed up with ant scripts over the years. During a long time you had to resort to an XML trick just to include other ant file, you did not have conditionals, but more importantly, it is quite a pain to write long ant scripts in XML. XML is not that good to write logic with, XSLT did not become as big as it could have been partly for this reason.
Recently, Java IDEs (Eclipse) have made Java coding really comfortable, but why is it that for each project, you need to have to setup your project classpath, build, and write an ant script that does the same? In many companies I have seen ant scripts taking minutes to do a build in order to test your latest modification. This is crazy when it took a few seconds to eclipse to compile it, and it's already compiled, so why not using that output for testing your development? Ant, despite its codebase and age, does not do much: it does not calculate dependencies, it leaves that to the java compiler, it does not keep checksums of files to check if one has changed, it just uses file system dates (which can be a problem if you retrieve an older version of some file).
Now I am using a Jython script that justs copies my eclipse build and packages it appropriately, it works well, it is fast, it is flexible (all the power of python), and platform independent. You need to be a bit careful how you choose to design your Jython script, but hey, even with Ant limitations on messing everything around, I have seen so many awful Ant scripts.


Technorati tags:

mad cows!

mad cows!