Sunday, November 28, 2010

Revenge of Smalltalk

(Joke inside)

In Paul Graham's essay Revenge of the Nerds (Read it, good ideas there):

Appendix: Power

As an illustration of what I mean about the relative power of programming languages, consider the following problem. We want to write a function that generates accumulators-- a function that takes a number n, and returns a function that takes another number i and returns n incremented by i.

(That's incremented by, not plus. An accumulator has to accumulate.)

In Common Lisp this would be


(defun foo (n)
  (lambda (i) (incf n i)))


In Smalltalk the code is slightly longer than in Lisp:


foo: n                              
  |s|                      
  s := n.                          
  ^[:i| s := s+i. ]

because although in general lexical variables work, you can't do an assignment to a parameter, so you have to create a new variable s.



Well, the Lisp code has 34 significant characters while the Smalltalk code has only 25 significant characters (we can remove the last dot). So the Smalltalk code is 26% shorter than the Lisp code :)


  • Perl example: 32 characters
  • Javascript example: 46 characters
  • Python example: 54 characters
Yeah, Smalltalk is really powerful ;P


Update:
Looking at Parser code we can easily remove the temp. variable limitation and write:
foo: n               
  ^[:i| n := n+i]

So
  • One power of Smalltalk is to be able to change the system.
  • 17 significant characters: Smalltalk 100% more powerful than Lisp :D
  • (still a joke - but ....)


Why this design decision ? Some explanation from Nicolas and Adrian.

Thursday, October 28, 2010

Three views of OO Programming

By Ralph Johnson, quoted in The Myths of Object-Orientation p.624:


I explain three views of OO programming. The Scandinavian view is that an OO system is one whose creators realise that programming is modelling. The mystical view is that an OO system is one that is built out of objects that communicate by sending messages to each other, and computation is the messages flying from object to object. The software engineering view is that an OO system is one that supports data abstrac- tion, polymorphism by late-binding of function calls, and inheritance.


It seems that in (French) schools we learn the engineering view. Then with experience we can agree on the mystical view. With Smalltalk I think I now understand the Scandinavian view.


Oscar Nierstrasz have written in Ten Things I Hate About OOP:

For me the point of OOP is that it isn’t a paradigm like procedural, logic or functional programming. Instead, OOP says “for every problem you should design your own paradigm”. In other words, the OO paradigm really is: Programming is Modeling

Friday, June 18, 2010

Autotest for Pharo


I've started a new little project. Autotest is a live testing tool (similar to Ruby Autotest, but the Smalltalk way, more dynamic).

Autotest automatically runs tests related to the method you edit. Screencast to see it in action: 





Autotest uses the following heuristics to find the tests to run:
- if the method is a test, runs it
- it the method is a test setUp or tearDown, run all the tests of the TestCase
- else find all senders which are tests in the same package and runs them (it detects different packages that are related, for example ProfStef-Core and ProfStef-Test)

To activate the Autotest dashboard:
- open the settings browser
- go under System
- check "Show Autotest Dashboard" option

To load it:

Gofer new
squeaksource: 'Autotest';
package: 'Autotest';
load

HelpSystem book included.

Saturday, May 15, 2010

GNU/Linux install party des Savoie

Une grande Install Party des Savoie aura lieu le samedi 22 mai et - évènement unique - simultanément sur Chambéry (MJC Résidence Escoffier, 379 fbg Montmélian) et sur Annecy (CDDP, 2 rue des Aravis) de 10h à 17h (les associations seront sur place 1 heure avant).

La distribution retenue pour une installation grand public est Ubuntu 10.04 'Lucid Lynx' LTS, et ses dérivés au cas où matériel le nécessiterai.

Chambéry et Annecy seront reliées en vidéo via EKIGA (sous réserve d'essais préalables concluants).

L'annonce de l'Install-Party est diffusée sur les radio locales (France Bleu Pays de Savoie, ODS Radio, Montagne FM) et est relayée dans la presse par le Dauphiné Libéré. Des affiches sont également diffusées dans les villes.

Tuesday, April 20, 2010

easy_squeakvm on github

I've created my first repository on github. So easy!

easy_squeakvm is used to build the squeak vm from scratch on Linux in one command.
To build the VM, just get the the script and execute

./easy_squeakvm.sh


This will

  • checkout squeakvm sources from svn repository
  • download PharoCore image
  • load VMMaker into PharoCore
  • generate the interpreter
  • build the VM
  • put binaries in out/squeakvm, ready to use


I was tired of typing the same commands over and over :)

http://github.com/lolgzs/easy_squeakvm