📜 ⬆️ ⬇️

How to taste smalltalk

Smalltalk Logo With access to the large arena of Ruby and the advent of the Seaside framework, Smalltalk is increasingly mentioned. However, among the younger generation (developers up to 30 years old) there is a perception that this is a dead language, developed at the dawn of the appearance of the PC and then buried. The mention of Smalltalk in lectures on PL, not far from COBOL, makes it even more archaic.

However, this is not true! All this time, Smalltalk lived, sometimes even near us, developed, used to solve serious problems, and sometimes for frivolous. here is just a phrase somehow strangely built. But there was almost no influx of fresh blood into the developer community. Reasons to list now meaningless.

But what happens when a programmer wants to try something new? He is trying to do it. And how much it is easy or difficult, what problems it will face, depends on its attitude to the tool in the future.

What to choose for dating?


For Smalltalk for many years there was a high entry threshold, despite the fact that the language itself is quite simple and intuitive. First of all, this was due to the availability of the toolkit. But time passes and the situation changes. Now there are several implementations of Smalltalk available:

How to choose the right dialect, so as not to lose? At first it may seem that the non-commercial version of the paid product will be the best option, but is it?
')
Dolphin Smalltalk is a very good product, but it is no longer supported and does not develop (despite the refutation). Finding libraries under it is not the easiest task, although they already exist. Plus, add to this the dependency on the OS and a fairly specific implementation of the base classes. But despite this, he has a complete set of tools for developing applications for Windows right out of the box.

VisualWorks Smalltalk is a serious product focused on developing complex and serious applications. It works on almost all popular platforms. But the installation disk weighs 650 MB !!! And I would like to warn you that after installation, it is not the most convenient development environment. Of course, everything is installed and configured, but it takes time, effort and knowledge, but we do not have that yet.

GNU Smalltalk - Open Source implementation of the GNU Smalltalk. Ascetic as all "bent". The interpreter is run from the command line and accepts source code as input. Very good for writing various scripts (well, maybe a little worse than python, due to the smaller number of libraries). Application development and familiarity with the language - not the fad of this dialect.

Squeak is an Open Source implementation of Smalltalk, authored by the authors of the language itself: Alan Kay, Dan Ingols and Adel Goldberg. The special features include what works on all popular platforms, allows you to develop code for a virtual machine and plug-ins directly “inside yourself”, using the simplified Smalltalk dialect. It takes quite a bit of space and contains all the necessary tools for development, including on Seaside. But when a person launches Squeak for the first time, he immediately asks the question: “How can I program this?” Traditionally, this launch is all limited.

So what to choose a programmer unfamiliar with Smalltalk? I insist on Squeak and then I will show how to avoid the contemplation of all these ryushechek and focus on the development, as well as solving typical problems.

Installation


In order to run Squeak, we need a virtual machine. Download it for your platform at http://squeak.org/Download/ . For Windows and MacOS X there are no difficulties - download and unpack. But Linux users have a small problem, they need to install a VM in the system (since the script has already been fixed). I do not advise you to install from the package: there is a rather old version. Therefore we go we swing for GNU / Linux . Unpack the archive. And run sudo ./INSTALL .

Image selection


Smalltalk is an image-based language. That is, everything happens inside the image that is loaded into the virtual machine. You can compare with the OS that is running in VMWare. After you click Save & Quit and then re-open the image, the execution will continue exactly from the moment of saving. The functionality of an image is determined by the set of objects contained in it, including class objects. Actually, this is the main difference of one image from another.

What images are available? Most Squeak developers have their own image, and some spread it in public access. Therefore, with a deep study of the issue, it may be discovered a huge number of options. I will tell you about the most popular image in the world of Squeak.

Squeak basic is the default image provided. Contains all coarseness and other garbage. Historically, during the development of Squeak under the motto “Multimedia & Education”, various projects were intertwined in the base image and then intertwined: EToys, MVC, Morphic etc. And now it is extremely difficult to exclude them from the image. Also, the base image does not contain heaps of pleasant packages for development. It can be recommended only for acquaintance with EToys or for the education of children.

Development images by Damien Cassou - an active member of the community once a month makes an assembly of images, which include the latest versions of tools for the developer. Assemblies are based on the Squeak basic image, but all the "toys" are removed away from the eyes. Damien makes two images: dev and web-dev. The second is different from the first in that it contains tools for web development: Seaside, Pier, AIDA and others. Images are highly stable and good quality tools. Highly recommend. There are also two similar images based on Pharo.

Pharo is a whole project. The goal of the project is to create an open, high-quality platform for developing on Smalltalk. The basis lay Squeak. One of the main features is the heavy use of traits. The standard implementation of threads has been replaced by Nile - trait-based. Also, on the approach of Rio - a framework for working with the file system. Community step by step removes from the image of the remnants of the past, leaving only the development tools. The quality of the image is very high - the number of red and yellow tests gradually decreases. Very good image for direct development - lightweight and does not contain too much.

At the moment - these are the three most popular images for Squeak. All three are working hard to improve. If you want to start with any tutorial, then I would advise you to take the developer image of Damien. Also this image is perfect if you want to start with Seaside or Pier. I'm still dating Pharo.

Run


To begin, download the archive with the selected image, on the appropriate link, and unpack it. Then download the file with the source code of image 3.9 and unpack it in the same directory. After that, double-click on the file with the .image extension and look for squeak [.exe] (for Linux users it will be in /usr/local/bin ). Voila Smalltalk is running. But you most likely do not like what you see at the first moment ... But we can fix it.

Customize and fix


Fonts


First of all - it's fonts. The standard raster font is terrible compared to those we are used to. To fix this, we need to do a few simple modifications.

Only for Squeak basic, squeak-dev and squeak-webdev:
  1. Left click on an unoccupied window of space (desktop), if the entire space is occupied, then close the Preference Browser window;
  2. In the menu that appears, click on the item open... and in the submenu select the Universe browser (enchanced) ;
  3. In the window, click on Update list from network after the update is completed, select the category Fonts , and in it the package FreeType Plus . In the list of versions, click the middle button on the most recent version and select Select this version in the context menu;
  4. After clicking on the Install selection button, the installation process will begin, and when it is completed, your image will be able to make calls to C libraries and work with FreeType;
  5. Then again, open the World menu (click on the desktop) and select Open...->workspace and copy the following code into the window that appears (you can change the font names and sizes, I use Liberation fonts from liberation-ttf, Ubuntu 8.10):
    |font codeFont tooltipFont |
    font := LogicalFont familyName: 'Liberation Sans' pointSize: 9 emphasis: TextEmphasis normal emphasisCode.
    tooltipFont := LogicalFont familyName: 'Liberation Sans' pointSize: 7 emphasis: TextEmphasis normal emphasisCode.
    codeFont := LogicalFont familyName: 'Liberation Mono' pointSize: 9 emphasis: TextEmphasis normal emphasisCode.
    Preferences setListFontTo: font.
    Preferences setMenuFontTo: font.
    Preferences setCodeFontTo: codeFont.
    Preferences setButtonFontTo: font.
    Preferences setSystemFontTo: font.
    Preferences setBalloonHelpFontTo: tooltipFont.
    font := LogicalFont familyName: 'Liberation Sans' pointSize: 11 emphasis: TextEmphasis bold emphasisCode.
    Preferences setWindowTitleFontTo: font.

    , then press Ctrl+A,Ctrl+D (executed). All the same can be done through the menu, but it will take more time, because this menu is not convenient: (;
  6. Now open the Preference Browser ( World->Open...->preference Browser ) and in the FreeType category, select the display options to your taste;
  7. Then go to the Windows category and set the UI Theme to your favorite (my choice of Watery 2 );
  8. PROFIT!

For Pharo-based images:
  1. Left-click on the desktop and in the World menu, select Workspace . Then paste the following code into the window that appears:
    |font codeFont tooltipFont|
    font := LogicalFont familyName: 'Liberation Sans' pointSize: 9.
    tooltipFont := LogicalFont familyName: 'Liberation Sans' pointSize: 7.
    codeFont := LogicalFont familyName: 'Liberation Mono' pointSize: 9.
    Preferences setListFontTo: font.
    Preferences setMenuFontTo: font.
    Preferences setCodeFontTo: codeFont.
    Preferences setButtonFontTo: font.
    Preferences setSystemFontTo: font.
    Preferences setBalloonHelpFontTo: tooltipFont.
    font := LogicalFont familyName: 'Liberation Sans' pointSize: 11.
    Preferences setWindowTitleFontTo: font.

    , then press Ctrl+A,Ctrl+D (executed);
  2. Open the Preference Browser ( World->System...->Preferences...->Preference Browser ) and customize FreeType and the theme as above;
  3. PROFIT!



UTF-8


It seems that now Squeak looks decent, but if you try to type text in Russian, it is unlikely that you will see something other than questions. We need to correct this regrettable behavior:
  1. Download the file (so easy the fastest);
  2. Open the File Browser (Pharo: World- World->Tools...->File Browser Squeak: World->Open...->File list );
  3. We find the downloaded file, select it and click on the Install button;
  4. It is necessary to close and re-open the image (I do not know why, but the input is not picked up). World->Save and Quit ;
  5. PROFIT!


What's next?


Smalltalk is installed and waiting for your instructions. What to do to understand the beauty of the language? There are some interesting resources to start with:


On this, allow me to bow out and retire. If there are a lot of positive reviews on this Khabratopik, then I will most likely continue.

Source: https://habr.com/ru/post/55797/


All Articles