<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1141" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Bonjour à tous,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Squeak et Java, une collaboration 
fructueuse.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV><FONT face=Arial size=2>
<DIV>Voici un exemple élémentaire des avantages à utiliser deux langages et un 
middleware <BR>plutôt qu’un seul langage.</DIV>
<DIV>&nbsp;</DIV>
<DIV>L’exemple se veut le plus simple possible afin de se concentrer sur 
l’approche en terme <BR>d’architecture et non en terme d’algorithme. </DIV>
<DIV>&nbsp;</DIV>
<DIV>Le programme consiste en deus itérations imbriquées avec incrémentation 
d’une variable <BR>de type Long.</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR><U>Voici le programme complet en Java :</U> </DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV><STRONG>&nbsp;&nbsp;&nbsp; long x = 0;<BR>&nbsp;&nbsp;&nbsp; long timeStart 
= 0;</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV><STRONG>&nbsp;&nbsp;&nbsp; timeStart = 
System.currentTimeMillis();</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV><STRONG>&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; 1000; i++) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int j = 0; j &lt; 
100000000; j++) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x = x + 
1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; 
}</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV><STRONG>&nbsp;&nbsp;&nbsp; timeStart = System.currentTimeMillis() - 
timeStart;<BR>&nbsp;&nbsp;&nbsp; System.out.println(new 
Long(timeStart).toString());<BR>&nbsp;&nbsp;&nbsp; System.out.println(new 
Long(x).toString());</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV><EM>Le temps d’exécution est de 487 secondes.</EM></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><U>En Squeak l’équivalent est :</U> <BR><STRONG>Time millisecondsToRun: 
[<BR>|&nbsp; x |<BR>x := 0 .<BR>1000 timesRepeat: [ <BR>100000000 timesRepeat: [ 
x := x + 1 ] ] ].</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV><EM>Je n'ai pas eu la patience d'attendre, ce genre de "calcul" n'étant pas 
le point <BR>fort de Smalltalk en général.</EM></DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>Maintenant, utilisons BirdView, le framework d’accès à Bird of Java 
pour aider Squeak, <BR>en le faisant collaborer avec Java.<BR>On confie à Java 
la responsabilité de la boucle interne de 1 à 100000000 et de <BR>retourner le 
résultat à Squeak : </DIV>
<DIV>&nbsp;</DIV>
<DIV><U>La méthode Java :</U> <BR><STRONG>public String iteration() 
{<BR>&nbsp;&nbsp;&nbsp; long x = 0;<BR>&nbsp;&nbsp;&nbsp; String value = 
null;</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV><STRONG>&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; 100000000; i++) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x = x + 1;<BR>&nbsp;&nbsp;&nbsp; 
}</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV><STRONG>&nbsp;&nbsp;&nbsp; value = new 
Long(x).toString();<BR>&nbsp;&nbsp;&nbsp; return value;<BR>}</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV><BR><U>Le programme Squeak : <BR></U><STRONG>Time millisecondsToRun: [<BR>| 
bv x |<BR>bv := BirdView 
new.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
"instance create"<BR>bv ipAddress: '127.0.0.1'&nbsp;&nbsp; ipPort: 
2010.&nbsp;&nbsp; &nbsp;"connection à un listener Bird of Java"<BR>bv ltnName: 
'ltn_postgresql'.</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV><STRONG>x := 0.<BR>1000 timesRepeat: [<BR>bv rpcPackage: 'test' rpcClass: 
'TestSpeed' rpcMethod: 'iteration' .<BR>bv rpcEval.<BR>x := x + (bv evalResult 
at: 1 asInteger) . ] ]</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV><EM>Temps d’exécution : 317 secondes, soit 170 secondes de moins que le 
programme full Java !</EM></DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>Même si l ‘exemple est limité, il démontre que Squeak et Java peuvent 
parfaitement <BR>fonctionner ensemble, et fournir un niveau de performance 
supérieur en étant associé <BR>que pris séparément.<BR>Cela permet de sortir 
Squeak de son relatif isolement vis-à-vis de l’ensemble des <BR>ressources du 
monde Java, très prisées en ce moment.<BR>Dans cette configuration de test, 
pourtant peu favorable, BirdView et Bird of Java <BR>qui intègre dans son noyau 
la ‘connaissance’ de Smalltalk offre un solution efficace <BR>d’interopérabilité 
Squeak-Java. </DIV>
<DIV>&nbsp;</DIV>
<DIV>Je présenterais d’autres exemples sur Squeak et BirdView notamment sur 
l’accès aux <BR>bases de données à travers JDBC et la conception d’interface 
graphique avec Squeak <BR>et des données.<BR></DIV>
<DIV><BR>Cordialement,<BR><BR>Christophe Allegrini<BR><BR>email : <A 
href="mailto:squeak@birdtechnology.net">squeak@birdtechnology.net</A><BR><A 
href="http://www.birdtechnology.net">www.birdtechnology.net</A><BR></DIV></FONT></BODY></HTML>