Author Topic: Languages and thinking part #2  (Read 55 times)

Peter Gibbons

  • Guest
Languages and thinking part #2
« on: September 24, 2011, 08:35:35 pm »
Since Smalltalk was mentioned in the previous thread I wanted to show how fundamentally different Smalltalk is compared to languages such as Java and C++. Both code snippets will show window on the screen with the title "Hello, World!". However in one case we are dealing with rigid system where every change we make to the source code will require compilation and then restart. The Smalltalk window is live - we could send it messages and it will respond immediately.

It will take a lot of time to explain what every line in this basic hello world type program does in Java.
The Smalltalk program is understandable without much explanation.

This doesn't mean Smalltalk is not challenging - it is. However the challenge comes from learning how program with live image.

In terms of commercial use - C++ and Java destroyed Smalltalk. However as research platform Smalltalk is still extremely interesting.

The current open source favorite is Pharo - fork of Squeak:

http://www.pharo-project.org/home



Code: [Select]
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class Example extends JFrame {

    public Example() {
       setTitle("Hello, World!");
       setSize(500, 300);
       setLocation(200, 200);
       setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                Example example = new Example();
                example.setVisible(true);
            }
        });
    }
}

javac Example.java
java Example



Code: [Select]
window := SystemWindow new.
window openInWorld.

The window will show up and we can start sending other messages to it.
The window will respond immediately. You are working with live system.

window setLabel: 'Hello, World!'.
window position: 200@200.
window width: 700.
window height: 500.

I have written only one small program in Smalltalk, so I am not an expert by any means.
I just played with Squeak long enough to see that it's based on some extremely powerful ideas.

People that pay attention will know that the brains that created the Java JVM and JIT compiler all came from the Smalltalk world.

So in a way Java is supposed to be a successor of Smalltalk however since it tried also to look like C++ - it lost some of the big advantages of Smalltalk - simplicity for example.


Quote
Java and C++ make you think that the new ideas are like the old ones.
Java is the most distressing thing to hit computing since MS-DOS.

-- Alan Kay --


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf