Wednesday, August 31, 2011

 

Heretic Smalltalk selectors

Smalltalk is different - and even after years I get rembered by discusssions from time to time how different it really is!
Smalltalk is a real dynamic object system (with the language just built in) and unique in the world of computing.

While a function/method name in a class has to be unique so it could be called - it usually is a Symbol. You know all these #foo, #bar, #negated, ...

In Java you may call it foo() or bar() or negated().

But in Smalltalk this selector could be ANY object. Yes, yes - this is not a typo.
It could be any object, just try it. For instance with the integer 1:

|selectorThatCouldBeAnObject existingMethod|
selectorThatCouldBeAnObject := 1.
existingMethod := EllipseMorph methodDict at: #heading.
EllipseMorph methodDict at: selectorThatCouldBeAnObject put: existingMethod.
EllipseMorph new perform: selectorThatCouldBeAnObject

So the message could even be the object that is receiving the message/itself as message:

| existingMethod receiver|
existingMethod := EllipseMorph methodDict at: #heading.
receiver := EllipseMorph new.
EllipseMorph methodDict at: receiver put: existingMethod.
receiver perform: receiver

Cool !!!

Alan Kay once said that "Smalltalk is object-oriented, but it should have been message oriented."
And as we now know a message is an object and an object could be a message. Mhhh - have to think more on this...


Tuesday, August 30, 2011

 

ROSScratch

You want to control your home robot using Scratch? Then look at ROSScratch project.

Tuesday, August 16, 2011

 

Dynatree for Seaside

I've wrapped the MIT licensed dynatree widget as part of the JQueryWidgetBox project. So if you need a tree in your web app just try it.

 

TSUG meeting

If you want to know more why Bombardier is using Pharo and Seaside then visit the next TSUG meeting in Toronto on Sep. 12th.

Friday, August 12, 2011

 

Pharo/Seaside experience

Francois Stephany reports on his experience with using Pharo and Seaside to develop a web application.

Tuesday, August 09, 2011

 

Small seaside image

Pavel created a small seaside image based on the small Pharo kernel image. So you could have a running seaside app in 4.3MB.

 

Java and late file dialog instantiation

Interesting: Java provides a JFileChooser to provide a file dialog for the
Swing UI framework. Typically I create objects when I need them - so
it was clear to me that I instantiate the class in this example only when
a button is clicked (most other examples on the web instantiate the dialog with the main window):



package foo;

import java.awt.BorderLayout;

public class TestWindow extends JFrame {

private JPanel contentPane;

public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TestWindow frame = new TestWindow();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public TestWindow() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);

JButton btnOpenFileDialog = new JButton("Open file dialog");
btnOpenFileDialog.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
onClickedButton();
}
});
contentPane.add(btnOpenFileDialog, BorderLayout.CENTER);
}

protected void onClickedButton() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.showOpenDialog(this); // open modal on main window
}
}



When you run this simple application within Eclipse, click the "Open" button and
close the file dialog via "Cancel" you will notice that an
exception will appear on stdout as soon as you close the main window:



Exception while removing reference: java.lang.InterruptedExceptionjava.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.java2d.Disposer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


So the app is not closed correctly and error free.

And I found a workaround, the exception will not appear if you
create an instance of JFileDialog as early as possible in your app:



public static void main(String[] args) {
new JFileChooser();
...



Since it is not referenced this instance becomes directly a victim of
the next GC - but anyway creating an instance of JFileChooser right at the beginning seem
to trigger an initialization that is required to prevent the above problem.

Thought I would share this if others run into the same problem. Another possibility is to use a better system.

 

Airflowing goes live

Airflowing, a new seaside application isn’t invite-only anymore - so anyone is able to use their commercial service. Read more or try it out.

Monday, August 08, 2011

 

FSGit updated

FSGit got an update to the new Filesystem implementation. Read more.

 

Squeak in Jail

If you want to limit your seaside app (chrooted seaside instance) for security reason this may be
an old but interesting blog post to read.

Thursday, August 04, 2011

 

Smalltalk on JVM 2

An update: watch the video called "A Renaissance VM: One Platform, Many Languages" on this site from Oracle. Highly recommended if you are interested on Smalltalk and (J)VM's.

 

Smalltalk on JVM

Found Smalltalk mentioned in a Java 7 presentation from Oracle citing Mark Roos from Roos Instruments, Inc:

"“We were able to implement all of the Smalltalk constructs... using invokedynamic to execute Smalltalk code on the JVM. ...The ease of putting a true dynamic language on the JVM was a wonder in itself.”

Note that with JSR292 there is more support for dynamic languages on JVM.
Found a presentation about the "RTalk" project to run Smalltalk on JVM and there is work going on as this message from the open jdk mailinglist proves.

Even when it runs on JVM - I still expect it to be limited compared to a Smalltalk running on a Smalltalk VM. The future will show if I'm right.

Wednesday, August 03, 2011

 

Pharo by Example in Spanish

The book Pharo by Example is now translated into Spanish too.

 

OCR and Pharo

Gary Chambers (creator of the Polymorph UI framework for Pharo) is currently building an image capture, OCR and data processing system using Smalltalk and he provides a first screenshot.
His company Pinesoft is using Smalltalk a lot as you can read here. Nice!

Monday, August 01, 2011

 

ESUG Seaside sprint

VMware (formerly GemStone) is sponsoring the Seaside sprint after ESUG. Thanks!

 

Two new chapters for Pharo book

Stef shares two new chapters for the Pharo book. You can also find them here.
This time on floats and little numbers. Feel free to review and send comments to him.

This page is powered by Blogger. Isn't yours?