<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://95.179.246.60/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nmingott</id>
	<title>Cuis CookBook - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://95.179.246.60/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nmingott"/>
	<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php/Special:Contributions/Nmingott"/>
	<updated>2026-05-08T12:46:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=MetaCookbook&amp;diff=213</id>
		<title>MetaCookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=MetaCookbook&amp;diff=213"/>
		<updated>2025-05-13T08:01:05Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: added stuff and corrections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Things ToDo ===&lt;br /&gt;
&lt;br /&gt;
* add logo on the top left &lt;br /&gt;
* add certificate&lt;br /&gt;
* adjust things in such a way that visiting &#039;&#039;&#039;cuiscookbook.euriscom.it&#039;&#039;&#039; goes straight to the right page. It is important to have a name that always will link to the document. &lt;br /&gt;
* Daily backups exported in my backup systems.&lt;br /&gt;
* write somewhere a page about me&lt;br /&gt;
* Consider moving this server in my own hardware&lt;br /&gt;
&lt;br /&gt;
=== Pages about this book ===&lt;br /&gt;
&lt;br /&gt;
* contributors guidelines &lt;br /&gt;
* style guidelines&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=MetaCookbook&amp;diff=212</id>
		<title>MetaCookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=MetaCookbook&amp;diff=212"/>
		<updated>2025-05-13T07:59:01Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: added page and first content&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Things ToDo ===&lt;br /&gt;
&lt;br /&gt;
* add logo on the top left &lt;br /&gt;
* add certificate&lt;br /&gt;
* adjust things in such a way that visiting cuiscookbook.euriscom.it goes straight to the right page. It is importan to have a name that always will link to the document.&lt;br /&gt;
* Daily backups exported in my backup systems.&lt;br /&gt;
* write somewhere a page about me&lt;br /&gt;
&lt;br /&gt;
=== Pages about this book ===&lt;br /&gt;
&lt;br /&gt;
* contributors guidelines &lt;br /&gt;
* style guidelines&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=211</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=211"/>
		<updated>2025-05-13T07:54:46Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: added link to new pages&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;[https://stackoverflow.com/ StackOverflow]&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check. Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. As a write I see that also important are [[format guidelines]].  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular? Read on, there are very good reasons. STARTED.&lt;br /&gt;
* [[Why Cuis Smalltalk?]] . TODO&lt;br /&gt;
* [[MetaCookbook]]. Collection of things about this document.  &lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level =&amp;gt; more difficult but more flexible.  &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
&lt;br /&gt;
All this chapter requires you to load the sound module.  &amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo. &lt;br /&gt;
* Borghi DataStreamer. &lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=210</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=210"/>
		<updated>2025-05-13T07:43:23Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: added link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;[https://stackoverflow.com/ StackOverflow]&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check. Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. As a write I see that also important are [[format guidelines]].  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular? Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level =&amp;gt; more difficult but more flexible.  &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
&lt;br /&gt;
All this chapter requires you to load the sound module.  &amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo. &lt;br /&gt;
* Borghi DataStreamer. &lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=209</id>
		<title>Why Smalltalk?</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=209"/>
		<updated>2025-05-13T07:41:00Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: rephrase&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NOT COMPLETE -- ACCUMULATING MATERIAL&lt;br /&gt;
&lt;br /&gt;
It would be easy here to fill 10 pages of abstract concepts, I don&#039;t want to do that. We will compare Smalltalk with another language, a popular one, a good one: Python. If you know already Python why should you learn Smalltalk? &lt;br /&gt;
&lt;br /&gt;
Let&#039;s start from a fundamental concept, almost all popular programming languages can solve almost all existing problems. So why to learn more than one? Well, quoting &#039;&#039;Wittgenstein&#039;&#039;  &amp;quot;My language is my world&amp;quot;, this holds true also for programming languages. When you choose a programming language you mostly don&#039;t choose what it is possible to do, but what it will be easy to achieve according to you or your organization taste and preferences. For example, in C you can access directly memory locations, in Python and Smalltalk you can&#039;t easily do it, therefore if you are working very low level, e.g. you are writing a driver, C is just a more fit tool. On the other side, suppose your problem is to find the 10 largest files in your computer opened the last time more than 1 year ago. In C to do this it will take about 1 hour, minimum. In Python and Smalltalk you can do it in a few minutes.  &lt;br /&gt;
&lt;br /&gt;
Factors useful in deciding the programming language for your next task.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;execution speed&#039;&#039;&#039;. How fast can your code run? Here the fastest are C, Fortran, C++, . Python and Smalltalk can&#039;t even compare to them. TODO COMPARE Python and Smalltalk speed.&lt;br /&gt;
* &#039;&#039;&#039;cross OS portability&#039;&#039;&#039;. Can you run your code in a Mac, Windows, Linux, BSD ? Here Python and Smalltalk are very good and C is very bad, your code is going to run on the major OS without changes or with little changes. For example in Windows the root directory is &#039;C:\&#039; in Unix like systems it is &#039;/&#039;. This little things must always be fixed. In C you would need to compile a specific version of the program for every OS.&lt;br /&gt;
* &#039;&#039;&#039;cross architecture portability&#039;&#039;&#039;. Can you run your code in an normal PC as well as in a RPi, in a BeagleBone Black, in a Web browser ? In C this is a problem, Python is quite portable, Smalltalk is the king it can run in very different platform, for example with [https://squeak.js.org/ SqueakJS] you can run you program written for a PC straight into the Web. You can&#039;t do easily this in any other programming language of my knowledge.&lt;br /&gt;
* &#039;&#039;&#039;library availability for your task&#039;&#039;&#039;. Here C is the king, there is a library for everything. Python is still very good the library park is huge, expecially since it got supported from Google. In Smalltalk we are far from their level. If you need a very specialized library either you write it or you call external code.&lt;br /&gt;
* &#039;&#039;&#039;community size and colleagues&#039;&#039;&#039;.  At some moment you will get stuck. It is true, with open source you can read all the code and answer your own question but it can take a large effort and if you are at a beginner-intermediate level this is just not possible. Therefore, a factor to consider well is: can you communicate with somebody how may answer your question, is there enough people using the technology. Not least, can you find programmers who know the language and work with you on a project ? Here C and Python shine, in Smalltalk it is a bit of a issue but we have our communities.&lt;br /&gt;
* &#039;&#039;&#039;development speed&#039;&#039;&#039;. Here C is really bad, writing programs takes time, debugging is hard. Python is really already a lot better I would estimate you can be 5-10 faster writing in Python. Smalltalk is the best, with its powerful tools and Platonic design not only development is fast, debugging is fast and not so tedious. I estimate you can be 2-3 times faster writing in Smalltalk respect to Python.&lt;br /&gt;
* &#039;&#039;&#039;software maintainability&#039;&#039;&#039;. The moment comes software must be changed to adapt to new circumstances. In C these are often hard time, in Python better but still, its imperative nature may require you to understand conceptual workflow of all the application. The change from Python2 to Python3 was an example of this problem, people is still getting payed to convert scripts to Python3. Smalltalk here shines, it is a system made for changes and evolutive software development. There is no difference from the concept of software creation of and software change, you work in the same way and Smalltalk, be default, brings all the development environment with itself, editor and debugger included. In Smalltalk you always work on the running program. There is no concept of switching it off, change the code and run it again. See it this way, for a &amp;quot;Python is better than C&amp;quot; zealot you will hear this argument: &amp;quot;There aren&#039;t boring compile steps&amp;quot;. A Smalltalk zealot laugh at that, he may tell you &amp;quot;There aren&#039;t boring shut down, correct and restart the application steps&amp;quot;, the application is always running. &lt;br /&gt;
* &#039;&#039;&#039;vendor support&#039;&#039;&#039;. Is there a company that sells an implementation of your language ? This can be useful, if you get in real trouble you would know where to ask for help at any level. For C, sure, there are several compiler vendors. Python is a community only language and as far as I know there isn&#039;t a corporate release of the language, there are though thousands of Python software houses so you can consider your self kind of safe. In Smalltalk there are vendors with a private implementation of the system for example [https://www.cincomsmalltalk.com/main/products/visualworks/ VisualWorks]. If you are in a corporate environment consider well the option of using their services. Also, their documentation might be far superior to open source projects. It is an option to keep in mind.&lt;br /&gt;
* &#039;&#039;&#039;self mutability&#039;&#039;&#039;. At times you may want to do something unusual. Maybe you would like to change the language a bit, for example a change in the standard library. Let&#039;s say I want to teach the String class to recognize Italian words, say i want a String to be able to answer the question &#039;isItalian&#039;. In C there is not even the Class concept, in Python there are Classes but you just can&#039;t, the standard library is sealed you are not supposed to change it. In Smalltalk you can change whatever you want, you want to change the meaning of &#039;=&#039; between Floats ? You can. Add a new operator &#039;@=&#039; tell true if two numbers are equals if their distance is less than 0.00000001 ? You can, and it is very easy, there isn&#039;t a an arcane syntax, it is just standard procedure.&lt;br /&gt;
* &#039;&#039;&#039;the fun factor&#039;&#039;&#039;. After the birth of my first son I had to put an hard stop on Smalltalk coding. More urgent things popped into my hands and I had to restrict my coding to the minimum effort tool to get the job done. In my case it turned out to be a &#039;&#039;sh&#039;&#039; script or &#039;&#039;Python&#039;&#039; or &#039;&#039;Ruby&#039;&#039;.  Let&#039;s restrict to &#039;&#039;Python&#039;&#039;, the most generic tool.I can be very productive in Python, I have all libraries for what I need and I can operate from the shell, I don&#039;t need a GUI, which for server people like me it is a major source of problems. But programming in Smalltalk is really another life respect to Python, even using Python as a Lisp, so REPL&#039;ing all the time, testing all functions and objects and methods. There are 2 key points here: &#039;&#039;&#039;(1-observability)&#039;&#039;&#039; in Smalltalk, most of the time, you can see well the data structure going around your code since they are just objects. &#039;&#039;&#039;(2-correct-rerun-running-code)&#039;&#039;&#039; in Smalltalk when the program breaks it doesn&#039;t just tell you, &amp;quot;I found a problem in line 345&amp;quot; and spit at you the dead body of a stack trace. No, in Smalltalk the debugger opens and you are brought in the middle of the things while they are still happening. This is really, really the best experience. Lisp does kind of the same but inspecting live data structures in Lisp is a major source of pain.&lt;br /&gt;
&lt;br /&gt;
There is a first factor which is very important which is &#039;&#039;&#039;execution&#039;&#039;&#039; &#039;&#039;&#039;speed&#039;&#039;&#039;. Some languages are faster than others for example C is faster than Python and Smalltalk, so if speed is your paramount interest, let&#039;s say you are writing a new matrix multiplication algorithm it is better you just do it in C. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Pure v.s. Mixed languages&#039;&#039;&#039;. Python is an imperative programming language which borrow some Object Orientation principles, some functional style and tryies to make everybody happy. Consider this &amp;lt;code&amp;gt;l = [1,2,3]&amp;lt;/code&amp;gt; you made a list, you can&#039;t say &amp;lt;code&amp;gt;l.len()&amp;lt;/code&amp;gt; as it should be if Python was reasonable object oriented, no, no, you must do &amp;lt;code&amp;gt;len(l)&amp;lt;/code&amp;gt;. This is just arbitrary. There is not a global plan in the Python language, it grows to accomodate new fashions. Smalltalk is completely different. In Smalltalk there is a plan, a view of the world and it is unescapeable, everything is an object and the only thing you can do is to send and object a message. Therefore if i tell you that the format to send a message to an object is &amp;lt;code&amp;gt;OBJECT MESSAGE&amp;lt;/code&amp;gt; then you can know already that if &amp;lt;code&amp;gt;L&amp;lt;/code&amp;gt; is some kind of list object and &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; is an available messsage for it, for sure, you just do &amp;lt;code&amp;gt;L size&amp;lt;/code&amp;gt;. Do you want to upcase a string? what if &amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; is a string you just to &amp;lt;code&amp;gt;S upcase&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A prgramming lanuage v.s. an operating system&#039;&#039;&#039;. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Closed languages v.s. Open languages&#039;&#039;&#039;. Suppose you want to teach a Python string how to do something. That is for example you red a CSV file or receiveing data from a web form, you are parsing fields and you have one for phone numbers. You may have prepared a proper PhoneNumber class to deal with this kid of data but when you read the CSV it will arrive you as a String. So you would like to do something like this: &amp;lt;code&amp;gt;&#039;+39425805040&#039;.toPhoneNumber() &amp;lt;/code&amp;gt;  well, you can forget about it, you can&#039;t do it in Python, built in data structures are untouchable. In Smalltalk instead it is a silly business you add the &amp;lt;code&amp;gt;toPhoneNumber&amp;lt;/code&amp;gt; to the String class and that&#039;s it, your program now knows how to transform String into PhoneNumbers. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chained v.s. unchained languages&#039;&#039;&#039;. Suppose you are dealing with a very special problem and you need to redefine a builtin method.... no tail call regression ...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live programming environment v.s. Write-Run-Stop-Write-Run loop&#039;&#039;&#039;. This will seem magic to you, it was for me. The way we are used to program computer is this. We write a program, run it, see what does not work, stop it (it does not dies by itself for a bug) write in a correction, run again. Repeat the loop, this is your programmer day. If you are unlucky there is also the compile step, if you are really unlucky add the reboot step. Well, forget about this horrible situation, the Smalltalk programming environment is always active! Smalltalk never stops, when a strange condition happens a debugger pops up and asks you 99% of the time &amp;quot;This object does not know how to answer to the message you sent him, what do we do?&amp;quot; . It is nothing dramatic, you teach the object how to answer the message and the programs goes on. It seems unreal, but it is just like that. Your programmer day is now building nice objects which are able to undestand messages. It could be that you are a scientific programmer and you need to teach the object &amp;lt;code&amp;gt;Matrix&amp;lt;/code&amp;gt; how to deal with a message &amp;lt;code&amp;gt;eigenvalues&amp;lt;/code&amp;gt;, it could be you are into web programming and your &amp;lt;code&amp;gt;WebServer&amp;lt;/code&amp;gt; object has received a message &amp;lt;code&amp;gt;getPriceItemWithCode:231231231&amp;lt;/code&amp;gt; it does not matter what you need to teach your computer, the scheme is fixed, it is just object and messages. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HackableSystems v.s. LockedSystems&#039;&#039;&#039;. Suppose one day you want to change your control structures, for example, in your application, you would like to define a different kind of for loop, let&#039;s call it the &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt;, that on each loop if forgets to iterate over one element taken at random. That is not going to be easy in Python. In Smalltalk it is trivial, because the for loop is achieved with a message, you want to define &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt; it is just matter of defining a new message.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Maintainability&#039;&#039;&#039;. The order spurs from the object system. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live inspectable and changeable objects&#039;&#039;&#039;. This concept does not exist in python. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The magic of the event system&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming by simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The image&#039;&#039;&#039;. In Smalltalk there is the concept of the image. This does not exist in Python. The image contains all your program and state, always. At some time you can tell Smalltalk to save the image into a file and than, another day, recover to that exact point. You can send the image to a far colleague for him to see what you are seeing right now, no differences. This can be extremely helpful in at least a few circumstances, you found a bug, you would like to make a proper correction but for the moment the program needs to just run, so you save the image into a file, make a quick fix then send yourself the broken image to produce a better quality code patch. Consider another case, you are doing a simulation, there are several random variables, and the simulation took hours or days to complete. You see some incredible results, you need to think about it, show it to your colleagues, so you save the image into a file and when you will be ready you can inspect whatever you with wish. Isn&#039;t it fantastic? A few other languages have images, like &#039;&#039;Common Lisp&#039;&#039; and &#039;&#039;R&#039;&#039;, but in Smalltalk the thing is even more interesting because with its integrated environment looking into variables (which for us are objects) is a pleasant activity compared to digging into data files, core dumps or JSON structures from the command line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ease of code hiding&#039;&#039;&#039;. If you are not running an opensource project soon enough you will hit this problem: &amp;quot;If I leave my code open my software will be copied and I can&#039;t sell it to anybody&amp;quot;. This is an unfortunate truth. So, if you need to hide your code, at this moment in time, Cuis-Smalltalk is not the tool for you. AFAIK the same goes for Pharo and Squeak. You may wish to try some commercial Smalltalk, for example Cincom.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=208</id>
		<title>Why Smalltalk?</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=208"/>
		<updated>2025-05-13T07:36:22Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: rewrite parts&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NOT COMPLETE -- ACCUMULATING MATERIAL&lt;br /&gt;
&lt;br /&gt;
It would be easy here to fill 10 pages of abstract concepts, I don&#039;t want to do that. We will compare Smalltalk with another language, a popular one, a good one: Python. If you know already Python why should you learn Smalltalk? &lt;br /&gt;
&lt;br /&gt;
Let&#039;s start from a fundamental concept, almost all popular programming languages can solve almost all existing problems. So why to learn more than one? Well, quoting &#039;&#039;Wittgenstein&#039;&#039;  &amp;quot;My language is my world&amp;quot;, this holds true also for programming languages. When you choose a programming language you mostly don&#039;t choose what it is possible to do, but what it will be easy to achieve according to you or your organization taste and preferences. For example, in C you can access directly memory locations, in Python and Smalltalk you can&#039;t easily do it, therefore if you are working very low level, e.g. you are writing a driver, C is just a more fit tool. On the other side, suppose your problem is to find the 10 largest files in your computer opened the last time more than 1 year ago. In C to do this it will take about 1 hour, minimum. In Python and Smalltalk you can do it in a few minutes.  &lt;br /&gt;
&lt;br /&gt;
Factors useful in deciding the programming language for your next task.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;execution speed&#039;&#039;&#039;. How fast can your code run? Here the fastest are C, Fortran, C++, . Python and Smalltalk can&#039;t even compare to them. TODO COMPARE Python and Smalltalk speed.&lt;br /&gt;
* &#039;&#039;&#039;cross OS portability&#039;&#039;&#039;. Can you run your code in a Mac, Windows, Linux, BSD ? Here Python and Smalltalk are very good and C is very bad, your code is going to run on the major OS without changes or with little changes. For example in Windows the root directory is &#039;C:\&#039; in Unix like systems it is &#039;/&#039;. This little things must always be fixed. In C you would need to compile a specific version of the program for every OS.&lt;br /&gt;
* &#039;&#039;&#039;cross architecture portability&#039;&#039;&#039;. Can you run your code in an normal PC as well as in a RPi, in a BeagleBone Black, in a Web browser ? In C this is a problem, Python is quite portable, Smalltalk is the king it can run in very different platform, for example with [https://squeak.js.org/ SqueakJS] you can run you program written for a PC straight into the Web. You can&#039;t do easily this in any other programming language of my knowledge.&lt;br /&gt;
* &#039;&#039;&#039;library availability for your task&#039;&#039;&#039;. Here C is the king, there is a library for everything. Python is still very good the library park is huge, expecially since it got supported from Google. In Smalltalk we are far from their level. If you need a very specialized library either you write it or you call external code.&lt;br /&gt;
* &#039;&#039;&#039;community size and colleagues&#039;&#039;&#039;.  At some moment you will get stuck. It is true, with open source you can read all the code and answer your own question but it can take a large effort and if you are at a beginner-intermediate level this is just not possible. Therefore, a factor to consider well is: can you communicate with somebody how may answer your question, is there enough people using the technology. Not least, can you find programmers who know the language and work with you on a project ? Here C and Python shine, in Smalltalk it is a bit of a issue but we have our communities.&lt;br /&gt;
* &#039;&#039;&#039;development speed&#039;&#039;&#039;. Here C is really bad, writing programs takes time, debugging is hard. Python is really already a lot better I would estimate you can be 5-10 faster writing in Python. Smalltalk is the best, with its powerful tools and Platonic design not only development is fast, debugging is fast and not so tedious. I estimate you can be 2-3 times faster writing in Smalltalk respect to Python.&lt;br /&gt;
* &#039;&#039;&#039;software maintainability&#039;&#039;&#039;. The moment comes software must be changed to adapt to new circumstances. In C these are often hard time, in Python better but still, its imperative nature may require you to understand conceptual workflow of all the application. The change from Python2 to Python3 was an example of this problem, people is still getting payed to convert scripts to Python3. Smalltalk here shines, it is a system made for changes and evolutive software development. There is no difference from the concept of software creation of and software change, you work in the same way and Smalltalk, be default, brings all the development environment with itself, editor and debugger included. In Smalltalk you always work on the running program. There is no concept of switching it off, change the code and run it again. See it this way, for a &amp;quot;Python is better than C&amp;quot; zealot you will hear this argument: &amp;quot;There aren&#039;t boring compile steps&amp;quot;. A Smalltalk zealot laugh at that, he may tell you &amp;quot;There aren&#039;t boring shut down, correct and restart the application steps&amp;quot;, the application is always running. &lt;br /&gt;
* &#039;&#039;&#039;vendor support&#039;&#039;&#039;. Is there a company that sells an implementation of your language ? This can be useful, if you get in real trouble you would know where to ask for help at any level. For C, sure, there are several compiler vendors. Python is a community only language and as far as I know there isn&#039;t a corporate release of the language, there are though thousands of Python software houses so you can consider your self kind of safe. In Smalltalk there are vendors with a private implementation of the system for example [https://www.cincomsmalltalk.com/main/products/visualworks/ VisualWorks]. If you are in a corporate environment consider well the option of using their services. Also, their documentation might be far superior to open source projects. It is an option to keep in mind.&lt;br /&gt;
* &#039;&#039;&#039;self mutability&#039;&#039;&#039;. At times you may want to do something unusual. Maybe you would like to change the language a bit, for example a change in the standard library. Let&#039;s say I want to teach the String class to recognize Italian words, say i want a String to be able to answer the question &#039;isItalian&#039;. In C there is not even the Class concept, in Python there are Classes but you just can&#039;t, the standard library is sealed you are not supposed to change it. In Smalltalk you can change whatever you want, you want to change the meaning of &#039;=&#039; between Floats ? You can. Add a new operator &#039;@=&#039; tell true if two numbers are equals if their distance is less than 0.00000001 ? You can, and it is very easy, there isn&#039;t a an arcane syntax, it is just standard procedure.&lt;br /&gt;
* &#039;&#039;&#039;the fun factor&#039;&#039;&#039;. After the birth of my first son I had to put an hard stop on Smalltalk coding. More urgent things popped into my hands and I had to restrict my coding to the minimum effort tool to get the job done. In my case it turned out to be a &#039;sh&#039; script or &#039;Python&#039;. Though, in retrospective, I see how productive I am since, in Python I have all libraries for what I need and I can operate from the shell, I don&#039;t need a GUI, which for server people like me it is a major source of problems. But programming in Smalltalk is really another life respect to Python, even using Python as a Lisp, so REPL&#039;ing all the time, testing all functions and objects and methods. There are 2 key points here: &#039;&#039;&#039;(1-observability)&#039;&#039;&#039; in Smalltalk, most of the time, you can see well the data structure going around your code since they are just objects. &#039;&#039;&#039;(2-correct-rerun-running-code)&#039;&#039;&#039; in Smalltalk when the program breaks it doesn&#039;t just tell you, &amp;quot;I found a problem in line 345&amp;quot; and spit at you the dead body of a stack trace. No, in Smalltalk the debugger opens and you are brought in the middle of the things while they are still happening. This is really, really the best experience. Lisp does kind of the same but inspecting live data structures in Lisp is a major source of pain.&lt;br /&gt;
&lt;br /&gt;
There is a first factor which is very important which is &#039;&#039;&#039;execution&#039;&#039;&#039; &#039;&#039;&#039;speed&#039;&#039;&#039;. Some languages are faster than others for example C is faster than Python and Smalltalk, so if speed is your paramount interest, let&#039;s say you are writing a new matrix multiplication algorithm it is better you just do it in C. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Pure v.s. Mixed languages&#039;&#039;&#039;. Python is an imperative programming language which borrow some Object Orientation principles, some functional style and tryies to make everybody happy. Consider this &amp;lt;code&amp;gt;l = [1,2,3]&amp;lt;/code&amp;gt; you made a list, you can&#039;t say &amp;lt;code&amp;gt;l.len()&amp;lt;/code&amp;gt; as it should be if Python was reasonable object oriented, no, no, you must do &amp;lt;code&amp;gt;len(l)&amp;lt;/code&amp;gt;. This is just arbitrary. There is not a global plan in the Python language, it grows to accomodate new fashions. Smalltalk is completely different. In Smalltalk there is a plan, a view of the world and it is unescapeable, everything is an object and the only thing you can do is to send and object a message. Therefore if i tell you that the format to send a message to an object is &amp;lt;code&amp;gt;OBJECT MESSAGE&amp;lt;/code&amp;gt; then you can know already that if &amp;lt;code&amp;gt;L&amp;lt;/code&amp;gt; is some kind of list object and &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; is an available messsage for it, for sure, you just do &amp;lt;code&amp;gt;L size&amp;lt;/code&amp;gt;. Do you want to upcase a string? what if &amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; is a string you just to &amp;lt;code&amp;gt;S upcase&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A prgramming lanuage v.s. an operating system&#039;&#039;&#039;. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Closed languages v.s. Open languages&#039;&#039;&#039;. Suppose you want to teach a Python string how to do something. That is for example you red a CSV file or receiveing data from a web form, you are parsing fields and you have one for phone numbers. You may have prepared a proper PhoneNumber class to deal with this kid of data but when you read the CSV it will arrive you as a String. So you would like to do something like this: &amp;lt;code&amp;gt;&#039;+39425805040&#039;.toPhoneNumber() &amp;lt;/code&amp;gt;  well, you can forget about it, you can&#039;t do it in Python, built in data structures are untouchable. In Smalltalk instead it is a silly business you add the &amp;lt;code&amp;gt;toPhoneNumber&amp;lt;/code&amp;gt; to the String class and that&#039;s it, your program now knows how to transform String into PhoneNumbers. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chained v.s. unchained languages&#039;&#039;&#039;. Suppose you are dealing with a very special problem and you need to redefine a builtin method.... no tail call regression ...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live programming environment v.s. Write-Run-Stop-Write-Run loop&#039;&#039;&#039;. This will seem magic to you, it was for me. The way we are used to program computer is this. We write a program, run it, see what does not work, stop it (it does not dies by itself for a bug) write in a correction, run again. Repeat the loop, this is your programmer day. If you are unlucky there is also the compile step, if you are really unlucky add the reboot step. Well, forget about this horrible situation, the Smalltalk programming environment is always active! Smalltalk never stops, when a strange condition happens a debugger pops up and asks you 99% of the time &amp;quot;This object does not know how to answer to the message you sent him, what do we do?&amp;quot; . It is nothing dramatic, you teach the object how to answer the message and the programs goes on. It seems unreal, but it is just like that. Your programmer day is now building nice objects which are able to undestand messages. It could be that you are a scientific programmer and you need to teach the object &amp;lt;code&amp;gt;Matrix&amp;lt;/code&amp;gt; how to deal with a message &amp;lt;code&amp;gt;eigenvalues&amp;lt;/code&amp;gt;, it could be you are into web programming and your &amp;lt;code&amp;gt;WebServer&amp;lt;/code&amp;gt; object has received a message &amp;lt;code&amp;gt;getPriceItemWithCode:231231231&amp;lt;/code&amp;gt; it does not matter what you need to teach your computer, the scheme is fixed, it is just object and messages. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HackableSystems v.s. LockedSystems&#039;&#039;&#039;. Suppose one day you want to change your control structures, for example, in your application, you would like to define a different kind of for loop, let&#039;s call it the &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt;, that on each loop if forgets to iterate over one element taken at random. That is not going to be easy in Python. In Smalltalk it is trivial, because the for loop is achieved with a message, you want to define &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt; it is just matter of defining a new message.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Maintainability&#039;&#039;&#039;. The order spurs from the object system. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live inspectable and changeable objects&#039;&#039;&#039;. This concept does not exist in python. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The magic of the event system&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming by simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The image&#039;&#039;&#039;. In Smalltalk there is the concept of the image. This does not exist in Python. The image contains all your program and state, always. At some time you can tell Smalltalk to save the image into a file and than, another day, recover to that exact point. You can send the image to a far colleague for him to see what you are seeing right now, no differences. This can be extremely helpful in at least a few circumstances, you found a bug, you would like to make a proper correction but for the moment the program needs to just run, so you save the image into a file, make a quick fix then send yourself the broken image to produce a better quality code patch. Consider another case, you are doing a simulation, there are several random variables, and the simulation took hours or days to complete. You see some incredible results, you need to think about it, show it to your colleagues, so you save the image into a file and when you will be ready you can inspect whatever you with wish. Isn&#039;t it fantastic? A few other languages have images, like &#039;&#039;Common Lisp&#039;&#039; and &#039;&#039;R&#039;&#039;, but in Smalltalk the thing is even more interesting because with its integrated environment looking into variables (which for us are objects) is a pleasant activity compared to digging into data files, core dumps or JSON structures from the command line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ease of code hiding&#039;&#039;&#039;. If you are not running an opensource project soon enough you will hit this problem: &amp;quot;If I leave my code open my software will be copied and I can&#039;t sell it to anybody&amp;quot;. This is an unfortunate truth. So, if you need to hide your code, at this moment in time, Cuis-Smalltalk is not the tool for you. AFAIK the same goes for Pharo and Squeak. You may wish to try some commercial Smalltalk, for example Cincom.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=207</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=207"/>
		<updated>2025-05-13T07:31:40Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check. Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. As a write I see that also important are [[format guidelines]].  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular? Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level =&amp;gt; more difficult but more flexible.  &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
&lt;br /&gt;
All this chapter requires you to load the sound module.  &amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo. &lt;br /&gt;
* Borghi DataStreamer. &lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Format_guidelines&amp;diff=206</id>
		<title>Format guidelines</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Format_guidelines&amp;diff=206"/>
		<updated>2025-05-13T07:25:39Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: add something to quit the edit stat (strange)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Accumulating material&lt;br /&gt;
* &#039;&#039;&#039;variable assignment syntax&#039;&#039;&#039;. Use &amp;lt;code&amp;gt;&#039;:=&#039;&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;&#039;-&#039;&amp;lt;/code&amp;gt;.  Ratios. I like more &amp;lt;code&amp;gt;&#039;_&#039;&amp;lt;/code&amp;gt;, when it is rendered in Cuis XXX-SHOW-IT-UNICODE-XXX  but there is a problem. (1) If we use the backward directed arrow the new user will be in trouble since he will not know how to type in that thing. (2) In other Smalltalk &amp;lt;code&amp;gt;&#039;:=&#039;&amp;lt;/code&amp;gt; is more used, as far as I know. &lt;br /&gt;
* &#039;&#039;&#039;Syntax highlight  in big code chunks&#039;&#039;&#039; .  It is much easier to read. The automatic highlighter in Mediawiki does a good job.  To insert code you need to do &amp;lt;u&amp;gt;Insert -&amp;gt; More -&amp;gt; Code Block&amp;lt;/u&amp;gt;. &lt;br /&gt;
* &#039;&#039;&#039;Typing in small code chunks (inlined code)&#039;&#039;&#039;. At the moment i haven&#039;t fund a way to hilight iniled code. To type in inlined code for the moment do: &amp;lt;u&amp;gt;(1) select a code chunk (2) Click &#039;&#039;&#039;A&#039;&#039;&#039; -&amp;gt;  Computer Code&amp;lt;/u&amp;gt; . &lt;br /&gt;
* &#039;&#039;&#039;Muse button name by left-right order&#039;&#039;&#039;. Always use the convention first, second, third button. The ordering is left to right. Mouser are supposed to have 3 buttons. If people have strange mice (see Apple) they know already how to simulate the 3 buttons. Don&#039;t use the button color names as it is done in Squeak. As of today naming mouse button by color just adds to the complexity and perplexity of the new user.&lt;br /&gt;
* aaa&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Format_guidelines&amp;diff=205</id>
		<title>Format guidelines</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Format_guidelines&amp;diff=205"/>
		<updated>2025-05-13T07:18:59Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: started new page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Accumulating material&lt;br /&gt;
* &#039;&#039;&#039;variable assignment syntax&#039;&#039;&#039;. Use &amp;lt;code&amp;gt;&#039;:=&#039;&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;&#039;-&#039;&amp;lt;/code&amp;gt;.  Ratios. I like more &amp;lt;code&amp;gt;&#039;_&#039;&amp;lt;/code&amp;gt;, when it is rendered in Cuis XXX-SHOW-IT-UNICODE-XXX  but there is a problem. (1) If we use the backward directed arrow the new user will be in trouble since he will not know how to type in that thing. (2) In other Smalltalk &amp;lt;code&amp;gt;&#039;:=&#039;&amp;lt;/code&amp;gt; is more used, as far as I know. &lt;br /&gt;
* &#039;&#039;&#039;Syntax highlight  in big code chunks&#039;&#039;&#039; .  It is much easier to read. The automatic highlighter in Mediawiki does a good job.  To insert code you need to do &amp;lt;u&amp;gt;Insert -&amp;gt; More -&amp;gt; Code Block&amp;lt;/u&amp;gt;. &lt;br /&gt;
* &#039;&#039;&#039;Typing in small code chunks (inlined code)&#039;&#039;&#039;. At the moment i haven&#039;t fund a way to hilight iniled code. To type in inlined code for the moment do: &amp;lt;u&amp;gt;(1) select a code chunk (2) Click &#039;&#039;&#039;A&#039;&#039;&#039; -&amp;gt;  Computer Code&amp;lt;/u&amp;gt; . &lt;br /&gt;
* &#039;&#039;&#039;Muse button name by left-right order&#039;&#039;&#039;. Always use the convention first, second, third button. The ordering is left to right. Mouser are supposed to have 3 buttons. If people have strange mice (see Apple) they know already how to simulate the 3 buttons. Don&#039;t use the button color names as it is done in Squeak. As of today naming mouse button by color just adds to the complexity and perplexity of the new user.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=204</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=204"/>
		<updated>2025-05-13T06:58:59Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: added link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check. Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. As a write I see that also important are [[format guidelines]].  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular. Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level =&amp;gt; more difficult but more flexible.  &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
&lt;br /&gt;
All this chapter requires you to load the sound module.  &amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo. &lt;br /&gt;
* Borghi DataStreamer. &lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Date_and_time_algebra&amp;diff=203</id>
		<title>Date and time algebra</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Date_and_time_algebra&amp;diff=203"/>
		<updated>2025-05-13T06:55:56Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: syntax hilight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Problem&#039;&#039;&#039;. You want to know what will be the weekday name of the day 1000 day in the future from now.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution&#039;&#039;&#039;. Cuis has a class &#039;&#039;&#039;Duration&#039;&#039;&#039; and is capable of doing dates algebra.&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
((DateAndTime now) + (Duration days: 1000)) dayOfWeekName .      &amp;quot;=&amp;gt;&amp;quot; #Saturday &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Exercise&#039;&#039;&#039;. Explore the classes &#039;&#039;&#039;DateAndTime&#039;&#039;&#039;, &#039;&#039;&#039;Duration&#039;&#039;&#039; and what is nearby in the Browser.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Exercise&#039;&#039;&#039;. Find the distance in hours between your birth date and your mother&#039;s.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=How_do_I_define_a_function%3F&amp;diff=202</id>
		<title>How do I define a function?</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=How_do_I_define_a_function%3F&amp;diff=202"/>
		<updated>2025-05-13T06:53:21Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: changed $_ with &amp;#039;:=&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Most probably, if you asked yourself &#039;&#039;how do I define a function ...&#039;&#039; it is because you are very new to &#039;&#039;Smalltalk&#039;&#039;. You need to know straight now that defining a function as we will do now is very much infrequent in Smalltalk since out credo is: &#039;&#039;&#039;The world is made of objects and actions are carried out sending messages to object&#039;&#039;&#039;. Therefore, every time you think &#039;&#039;I should define a function&#039;&#039; you should instead be thinking &#039;&#039;I should define a proper method !&#039;&#039;&lt;br /&gt;
* Here is how you define and use the simplest function in Smalltalk, we call them &#039;&#039;&#039;BlockClosure&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
f := [ :x | x * 2]. &lt;br /&gt;
f class.           &amp;quot;=&amp;gt;&amp;quot; BlockClosure &lt;br /&gt;
f value: 5.        &amp;quot;=&amp;gt;&amp;quot; 10 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Do you want to get more sophisticated ? Here is a 2 arguments function&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
g := [ :x :y | x + y ]. &lt;br /&gt;
g value: 3 value: 5.     &amp;quot;=&amp;gt;&amp;quot; 8 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* Do you now want to do the right thing ? Then, learn how to define the message &#039;&#039;&#039;double&#039;&#039;&#039; inside the class &#039;&#039;&#039;Number&#039;&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=How_do_I_define_a_function%3F&amp;diff=201</id>
		<title>How do I define a function?</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=How_do_I_define_a_function%3F&amp;diff=201"/>
		<updated>2025-05-13T06:52:34Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: syntax hilight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Most probably, if you asked yourself &#039;&#039;how do I define a function ...&#039;&#039; it is because you are very new to &#039;&#039;Smalltalk&#039;&#039;. You need to know straight now that defining a function as we will do now is very much infrequent in Smalltalk since out credo is: &#039;&#039;&#039;The world is made of objects and actions are carried out sending messages to object&#039;&#039;&#039;. Therefore, every time you think &#039;&#039;I should define a function&#039;&#039; you should instead be thinking &#039;&#039;I should define a proper method !&#039;&#039;&lt;br /&gt;
* Here is how you define and use the simplest function in Smalltalk, we call them &#039;&#039;&#039;BlockClosure&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
f := [ :x | x * 2]. &lt;br /&gt;
f class.           &amp;quot;=&amp;gt;&amp;quot; BlockClosure &lt;br /&gt;
f value: 5.        &amp;quot;=&amp;gt;&amp;quot; 10 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Do you want to get more sophisticated ? Here is a 2 arguments function&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
g _ [ :x :y | x + y ]. &lt;br /&gt;
g value: 3 value: 5.     &amp;quot;=&amp;gt;&amp;quot; 8 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* Do you now want to do the right thing ? Then, learn how to define the message &#039;&#039;&#039;double&#039;&#039;&#039; inside the class &#039;&#039;&#039;Number&#039;&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Run_Cuis_in_a_ARM_platform,_RPi,_BeagleBone_and_similar._(Linux)&amp;diff=200</id>
		<title>Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Run_Cuis_in_a_ARM_platform,_RPi,_BeagleBone_and_similar._(Linux)&amp;diff=200"/>
		<updated>2025-05-13T06:49:26Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: added link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Running Cuis on ARM (BeagleBone, RPi etc.) isn&#039;t any different that on your pc, but there are a few details to know.&lt;br /&gt;
* &#039;&#039;&#039;ATTENTION&#039;&#039;&#039;. This information is valid on 19-Oct-2021. Things should change in better in the next months.&lt;br /&gt;
* The only two things you need to know are:&lt;br /&gt;
&lt;br /&gt;
# You must use a 32 bit image, like this, for example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./sqcogspur32linuxhtRPi/squeak Cuis-Smalltalk-Dev/Cuis5.0-4834-32.image&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# You would rightfully try to use as VM &#039;&#039;&#039;squeak.cog.spur_linux32ARMv6_202003021730.tar.gz&#039;&#039;&#039;, but this is broken unfortunately. I had success using the &#039;&#039;&#039;latest build&#039;&#039;&#039;, [https://github.com/OpenSmalltalk/opensmalltalk-vm/releases/download/latest-build/squeak.cog.spur_linux32ARMv6.tar.gz here].&lt;br /&gt;
&lt;br /&gt;
* Here is a runnability proof:&lt;br /&gt;
[[File:Runnability-prof.png|600x600px]]&lt;br /&gt;
----Dr. Nicola Mingotti wrote this on 19-Oct-2021.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=199</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=199"/>
		<updated>2025-05-13T06:47:29Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: small variation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check. Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular. Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level =&amp;gt; more difficult but more flexible.  &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
&lt;br /&gt;
All this chapter requires you to load the sound module.  &amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo. &lt;br /&gt;
* Borghi DataStreamer. &lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=198</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=198"/>
		<updated>2025-05-12T21:27:11Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: /* Applications built on Cuis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check! Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular. Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level =&amp;gt; more difficult but more flexible.  &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
&lt;br /&gt;
All this chapter requires you to load the sound module.  &amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo. &lt;br /&gt;
* Borghi DataStreamer. &lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=197</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=197"/>
		<updated>2025-05-12T21:25:37Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check! Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular. Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level =&amp;gt; more difficult but more flexible.  &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
&lt;br /&gt;
All this chapter requires you to load the sound module.  &amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=References_to_the_Sound_system&amp;diff=196</id>
		<title>References to the Sound system</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=References_to_the_Sound_system&amp;diff=196"/>
		<updated>2025-05-12T21:24:09Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: Created page with &amp;quot;TODO. Add references i have from the Swiki  TODO. Add Hannes references received via mail&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;TODO. Add references i have from the Swiki&lt;br /&gt;
&lt;br /&gt;
TODO. Add Hannes references received via mail&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=195</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=195"/>
		<updated>2025-05-12T21:23:36Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: /* The Sound system */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check! Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular. Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level. &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
&lt;br /&gt;
All this chapter requires you to load the sound module.  &amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Create_and_play_*.wav_files&amp;diff=194</id>
		<title>Create and play *.wav files</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Create_and_play_*.wav_files&amp;diff=194"/>
		<updated>2025-05-12T21:20:53Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: split content in pages&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;TODO. Say something about *.wav files &lt;br /&gt;
&lt;br /&gt;
===== Create a *.wav file =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
(AbstractSound noteSequenceOn: &lt;br /&gt;
     FMSound flute2 from: &lt;br /&gt;
       #( (e5 0.5 500) (d5 0.5 300) (c5 0.5 350) &lt;br /&gt;
          (d5 0.5 300) (e5 0.5 500) (e5 0.5 300) &lt;br /&gt;
          (e5 1.0 350) (d5 0.5 400) (d5 0.5 300) &lt;br /&gt;
          (d5 1.0 330) (e5 0.5 400) (g5 0.5 300) &lt;br /&gt;
          (g5 1.0 500) )&lt;br /&gt;
) storeWAVOnFileNamed: &#039;maryhadalittlelamb.wav&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===== Play a *.wav file =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
(SampledSound fromWaveFileNamed: &#039;maryhadalittlelamb.wav&#039;) play&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Create_and_play_*.wav_files&amp;diff=193</id>
		<title>Create and play *.wav files</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Create_and_play_*.wav_files&amp;diff=193"/>
		<updated>2025-05-12T21:17:19Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imoprted&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
===== Create a *.wav file =====&lt;br /&gt;
 (AbstractSound noteSequenceOn: FMSound flute2 from: #(&lt;br /&gt;
   (e5 0.5 500) (d5 0.5 300) (c5 0.5 350)&lt;br /&gt;
   (d5 0.5 300) (e5 0.5 500) (e5 0.5 300)&lt;br /&gt;
   (e5 1.0 350) (d5 0.5 400) (d5 0.5 300)&lt;br /&gt;
   (d5 1.0 330) (e5 0.5 400) (g5 0.5 300)&lt;br /&gt;
   (g5 1.0 500)&lt;br /&gt;
 )) storeWAVOnFileNamed: &#039;maryhadalittlelamb.wav&#039;.&lt;br /&gt;
&lt;br /&gt;
===== Play a *.wav file =====&lt;br /&gt;
 (SampledSound fromWaveFileNamed: &#039;maryhadalittlelamb.wav&#039;) play&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Play_a_melody_writing_a_list_of_note_names_and_their_duration&amp;diff=192</id>
		<title>Play a melody writing a list of note names and their duration</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Play_a_melody_writing_a_list_of_note_names_and_their_duration&amp;diff=192"/>
		<updated>2025-05-12T21:16:31Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: split subject into a page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
TODO. Add piano keyboard view &lt;br /&gt;
&lt;br /&gt;
TODO. Add procedure to play a melody with Italian note names: Do, Re, Mi &lt;br /&gt;
&lt;br /&gt;
TODO. Add referece to the interesting history of different note naming scheme&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
(AbstractSound noteSequenceOn: &lt;br /&gt;
    PluckedSound default from: &lt;br /&gt;
      #((c4 1 500) &lt;br /&gt;
        (d4 1 500) &lt;br /&gt;
        (e4 1 500) &lt;br /&gt;
        (g4 1 500) &lt;br /&gt;
        (a4 1 250)&lt;br /&gt;
        (a4 1 250) &lt;br /&gt;
        (c5 1 500)&lt;br /&gt;
       ) &lt;br /&gt;
) play&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Play_a_melody_writing_a_list_of_note_names_and_their_duration&amp;diff=191</id>
		<title>Play a melody writing a list of note names and their duration</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Play_a_melody_writing_a_list_of_note_names_and_their_duration&amp;diff=191"/>
		<updated>2025-05-12T21:14:37Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
xxxx&lt;br /&gt;
 (AbstractSound noteSequenceOn: &lt;br /&gt;
     PluckedSound default from: &lt;br /&gt;
       #((c4 1 500) &lt;br /&gt;
         (d4 1 500) &lt;br /&gt;
         (e4 1 500) &lt;br /&gt;
         (g4 1 500) &lt;br /&gt;
         (a4 1 250)&lt;br /&gt;
         (a4 1 250) &lt;br /&gt;
         (c5 1 500)&lt;br /&gt;
        ) &lt;br /&gt;
 ) play&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=190</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=190"/>
		<updated>2025-05-12T21:13:47Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: /* The Sound system */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check! Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular. Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level. &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
 &lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
* [[Play a melody writing a list of note names and their duration]] . Ok for note in the format C,D,E... TODO for notes with Italian names: Do, Re, Mi...&lt;br /&gt;
* TODO. Realtime sound playing. On event play immediately a sound, simulate and instrument typing on your computer keyboard&lt;br /&gt;
* [[Create and play *.wav files]]. &lt;br /&gt;
* [[References to the Sound system]] . for further study&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=First_experiments_with_sound&amp;diff=189</id>
		<title>First experiments with sound</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=First_experiments_with_sound&amp;diff=189"/>
		<updated>2025-05-12T21:06:55Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: added sections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These notes were started from hhzl observations [https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev/issues/82 here].  &lt;br /&gt;
&lt;br /&gt;
The sound system was exported from Squeak, more information can be found in the Swiki, see [[squeak:152|[1]]] and [[squeak:152|[2]]].&lt;br /&gt;
&lt;br /&gt;
The sound system isn&#039;t loaded in the Cuis base system, but it is included in it, you just need to load it with:&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Play a melody writing note names and duration =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
(AbstractSound noteSequenceOn: &lt;br /&gt;
    PluckedSound default from: &lt;br /&gt;
      #((c4 1 500) &lt;br /&gt;
        (d4 1 500) &lt;br /&gt;
        (e4 1 500) &lt;br /&gt;
        (g4 1 500) &lt;br /&gt;
        (a4 1 250)&lt;br /&gt;
        (a4 1 250) &lt;br /&gt;
        (c5 1 500)&lt;br /&gt;
       ) &lt;br /&gt;
) play&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== TODO. Play a melody with note names in Italian: Do, Re, Mi ... =====&lt;br /&gt;
xxxxx Should be easy.  &lt;br /&gt;
&lt;br /&gt;
xxxxx link to the interesting story of the two different note names  &lt;br /&gt;
&lt;br /&gt;
===== TODO. Realtime sound. on envent play a sound as soon as possible =====&lt;br /&gt;
This is necessary to simulate instruments playing on a computer keyboard or on some other external harware device. It is important that the delay is small otherwise the effect will be not realistic and not fun. At the moment i don&#039;t know how to do it.   &lt;br /&gt;
&lt;br /&gt;
===== Create a *.wav file =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
(AbstractSound noteSequenceOn: FMSound flute2 from: #(&lt;br /&gt;
  (e5 0.5 500) (d5 0.5 300) (c5 0.5 350)&lt;br /&gt;
  (d5 0.5 300) (e5 0.5 500) (e5 0.5 300)&lt;br /&gt;
  (e5 1.0 350) (d5 0.5 400) (d5 0.5 300)&lt;br /&gt;
  (d5 1.0 330) (e5 0.5 400) (g5 0.5 300)&lt;br /&gt;
  (g5 1.0 500)&lt;br /&gt;
)) storeWAVOnFileNamed: &#039;maryhadalittlelamb.wav&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Play a *.wav file =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
(SampledSound fromWaveFileNamed: &#039;maryhadalittlelamb.wav&#039;) play&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Exercise.1&#039;&#039;&#039;. Check that the class &#039;&#039;&#039;Sound&#039;&#039;&#039; isn&#039;t present in Cuis by default.&lt;br /&gt;
&lt;br /&gt;
===== References =====&lt;br /&gt;
&lt;br /&gt;
* xxxx&lt;br /&gt;
* xxxx&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=First_experiments_with_sound&amp;diff=188</id>
		<title>First experiments with sound</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=First_experiments_with_sound&amp;diff=188"/>
		<updated>2025-05-12T21:03:20Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These notes were started from hhzl observations [https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev/issues/82 here].  &lt;br /&gt;
&lt;br /&gt;
The sound system was exported from Squeak, more information can be found in the Swiki, see [[squeak:152|[1]]] and [[squeak:152|[2]]].&lt;br /&gt;
&lt;br /&gt;
The sound system isn&#039;t loaded in the Cuis base system, but it is included in it, you just need to load it with:&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;Sound&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Play a melody writing note names and duration =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
(AbstractSound noteSequenceOn: &lt;br /&gt;
    PluckedSound default from: &lt;br /&gt;
      #((c4 1 500) &lt;br /&gt;
        (d4 1 500) &lt;br /&gt;
        (e4 1 500) &lt;br /&gt;
        (g4 1 500) &lt;br /&gt;
        (a4 1 250)&lt;br /&gt;
        (a4 1 250) &lt;br /&gt;
        (c5 1 500)&lt;br /&gt;
       ) &lt;br /&gt;
) play&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== TODO. Play a melody with note names in Italian: Do, Re, Mi ... =====&lt;br /&gt;
TODO. Link to the interesting story of this topic &lt;br /&gt;
&lt;br /&gt;
TODO. &lt;br /&gt;
&lt;br /&gt;
===== Create a *.wav file =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
(AbstractSound noteSequenceOn: FMSound flute2 from: #(&lt;br /&gt;
  (e5 0.5 500) (d5 0.5 300) (c5 0.5 350)&lt;br /&gt;
  (d5 0.5 300) (e5 0.5 500) (e5 0.5 300)&lt;br /&gt;
  (e5 1.0 350) (d5 0.5 400) (d5 0.5 300)&lt;br /&gt;
  (d5 1.0 330) (e5 0.5 400) (g5 0.5 300)&lt;br /&gt;
  (g5 1.0 500)&lt;br /&gt;
)) storeWAVOnFileNamed: &#039;maryhadalittlelamb.wav&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Play a *.wav file =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
(SampledSound fromWaveFileNamed: &#039;maryhadalittlelamb.wav&#039;) play&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Exercise.1&#039;&#039;&#039;. Check that the class &#039;&#039;&#039;Sound&#039;&#039;&#039; isn&#039;t present in Cuis by default.&lt;br /&gt;
&lt;br /&gt;
===== References =====&lt;br /&gt;
&lt;br /&gt;
* xxxx&lt;br /&gt;
* xxxx&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=187</id>
		<title>Why Smalltalk?</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=187"/>
		<updated>2025-05-12T20:57:44Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NOT COMPLETE -- ACCUMULATING MATERIAL&lt;br /&gt;
&lt;br /&gt;
It would be easy here to fill 10 pages of abstract concepts, I don&#039;t want to do that. We will compare Smalltalk with another language, a popular one, a good one: Python. If you know already Python why should you learn Smalltalk? &lt;br /&gt;
&lt;br /&gt;
Let&#039;s start from a fundamental concept, almost all popular programming languages can solve almost all existing problems. So why to learn more than one? Well, quoting &#039;&#039;Wittgenstein&#039;&#039;  &amp;quot;My language is my world&amp;quot;, this holds true also for programming languages, when you choose a programming language you actually don&#039;t choose what it is possible to do, but what it will be easy to achieve, the computer view of the World, what it will be easy to talk about. For example, in C you can access directly memory locations, in Python and Smalltalk you can&#039;t easily do it, therefore if you are working very low level, e.g. you are writing a driver, C is just a more fit tool. Then, suppose your problem is to take all files in your hard drive and find the 10 largest. Well, in C to do this it will take about 1 hour, minimum. In Python and Smalltalk you can do it in a few minutes. &lt;br /&gt;
&lt;br /&gt;
Factors useful in deciding the programming language for your next task.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;execution speed&#039;&#039;&#039;. How fast can your code run? Here the fastest are C, Fortran, C++, . Python and Smalltalk can&#039;t even compare to them. TODO COMPARE Python and Smalltalk speed.&lt;br /&gt;
* &#039;&#039;&#039;cross OS portability&#039;&#039;&#039;. Can you run your code in a Mac, Windows, Linux, BSD ? Here Python and Smalltalk are very good and C is very bad, your code is going to run on the major OS without changes or with little changes. For example in Windows the root directory is &#039;C:\&#039; in Unix like systems it is &#039;/&#039;. This little things must always be fixed. In C you would need to compile a specific version of the program for every OS.&lt;br /&gt;
* &#039;&#039;&#039;cross architecture portability&#039;&#039;&#039;. Can you run your code in an normal PC as well as in a RPi, in a BeagleBone Black, in a Web browser ? In C this is a problem, Python is quite portable, Smalltalk is the king it can run in very different platform, for example with [https://squeak.js.org/ SqueakJS] you can run you program written for a PC straight into the Web. You can&#039;t do easily this in any other programming language of my knowledge.&lt;br /&gt;
* &#039;&#039;&#039;library availability for your task&#039;&#039;&#039;. Here C is the king, there is a library for everything. Python is still very good the library park is huge, expecially since it got supported from Google. In Smalltalk we are far from their level. If you need a very specialized library either you write it or you call external code.&lt;br /&gt;
* &#039;&#039;&#039;community size and colleagues&#039;&#039;&#039;.  At some moment you will get stuck. It is true, with open source you can read all the code and answer your own question but it can take a large effort and if you are at a beginner-intermediate level this is just not possible. Therefore, a factor to consider well is: can you communicate with somebody how may answer your question, is there enough people using the technology. Not least, can you find programmers who know the language and work with you on a project ? Here C and Python shine, in Smalltalk it is a bit of a issue but we have our communities.&lt;br /&gt;
* &#039;&#039;&#039;development speed&#039;&#039;&#039;. Here C is really bad, writing programs takes time, debugging is hard. Python is really already a lot better I would estimate you can be 5-10 faster writing in Python. Smalltalk is the best, with its powerful tools and Platonic design not only development is fast, debugging is fast and not so tedious. I estimate you can be 2-3 times faster writing in Smalltalk respect to Python.&lt;br /&gt;
* &#039;&#039;&#039;software maintainability&#039;&#039;&#039;. The moment comes software must be changed to adapt to new circumstances. In C these are often hard time, in Python better but still, its imperative nature may require you to understand conceptual workflow of all the application. The change from Python2 to Python3 was an example of this problem, people is still getting payed to convert scripts to Python3. Smalltalk here shines, it is a system made for changes and evolutive software development. There is no difference from the concept of software creation of and software change, you work in the same way and Smalltalk, be default, brings all the development environment with itself, editor and debugger included. In Smalltalk you always work on the running program. There is no concept of switching it off, change the code and run it again. See it this way, for a &amp;quot;Python is better than C&amp;quot; zealot you will hear this argument: &amp;quot;There aren&#039;t boring compile steps&amp;quot;. A Smalltalk zealot laugh at that, he may tell you &amp;quot;There aren&#039;t boring shut down, correct and restart the application steps&amp;quot;, the application is always running. &lt;br /&gt;
* &#039;&#039;&#039;vendor support&#039;&#039;&#039;. Is there a company that sells an implementation of your language ? This can be useful, if you get in real trouble you would know where to ask for help at any level. For C, sure, there are several compiler vendors. Python is a community only language and as far as I know there isn&#039;t a corporate release of the language, there are though thousands of Python software houses so you can consider your self kind of safe. In Smalltalk there are vendors with a private implementation of the system for example [https://www.cincomsmalltalk.com/main/products/visualworks/ VisualWorks]. If you are in a corporate environment consider well the option of using their services. Also, their documentation might be far superior to open source projects. It is an option to keep in mind.&lt;br /&gt;
* &#039;&#039;&#039;self mutability&#039;&#039;&#039;. At times you may want to do something unusual. Maybe you would like to change the language a bit, for example a change in the standard library. Let&#039;s say I want to teach the String class to recognize Italian words, say i want a String to be able to answer the question &#039;isItalian&#039;. In C there is not even the Class concept, in Python there are Classes but you just can&#039;t, the standard library is sealed you are not supposed to change it. In Smalltalk you can change whatever you want, you want to change the meaning of &#039;=&#039; between Floats ? You can. Add a new operator &#039;@=&#039; tell true if two numbers are equals if their distance is less than 0.00000001 ? You can, and it is very easy, there isn&#039;t a an arcane syntax, it is just standard procedure.&lt;br /&gt;
* &#039;&#039;&#039;the fun factor&#039;&#039;&#039;. After the birth of my first son I had to put an hard stop on Smalltalk coding. More urgent things popped into my hands and I had to restrict my coding to the minimum effort tool to get the job done. In my case it turned out to be a &#039;sh&#039; script or &#039;Python&#039;. Though, in retrospective, I see how productive I am since, in Python I have all libraries for what I need and I can operate from the shell, I don&#039;t need a GUI, which for server people like me it is a major source of problems. But programming in Smalltalk is really another life respect to Python, even using Python as a Lisp, so REPL&#039;ing all the time, testing all functions and objects and methods. There are 2 key points here: &#039;&#039;&#039;(1-observability)&#039;&#039;&#039; in Smalltalk, most of the time, you can see well the data structure going around your code since they are just objects. &#039;&#039;&#039;(2-correct-rerun-running-code)&#039;&#039;&#039; in Smalltalk when the program breaks it doesn&#039;t just tell you, &amp;quot;I found a problem in line 345&amp;quot; and spit at you the dead body of a stack trace. No, in Smalltalk the debugger opens and you are brought in the middle of the things while they are still happening. This is really, really the best experience. Lisp does kind of the same but inspecting live data structures in Lisp is a major source of pain.&lt;br /&gt;
&lt;br /&gt;
There is a first factor which is very important which is &#039;&#039;&#039;execution&#039;&#039;&#039; &#039;&#039;&#039;speed&#039;&#039;&#039;. Some languages are faster than others for example C is faster than Python and Smalltalk, so if speed is your paramount interest, let&#039;s say you are writing a new matrix multiplication algorithm it is better you just do it in C. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Pure v.s. Mixed languages&#039;&#039;&#039;. Python is an imperative programming language which borrow some Object Orientation principles, some functional style and tryies to make everybody happy. Consider this &amp;lt;code&amp;gt;l = [1,2,3]&amp;lt;/code&amp;gt; you made a list, you can&#039;t say &amp;lt;code&amp;gt;l.len()&amp;lt;/code&amp;gt; as it should be if Python was reasonable object oriented, no, no, you must do &amp;lt;code&amp;gt;len(l)&amp;lt;/code&amp;gt;. This is just arbitrary. There is not a global plan in the Python language, it grows to accomodate new fashions. Smalltalk is completely different. In Smalltalk there is a plan, a view of the world and it is unescapeable, everything is an object and the only thing you can do is to send and object a message. Therefore if i tell you that the format to send a message to an object is &amp;lt;code&amp;gt;OBJECT MESSAGE&amp;lt;/code&amp;gt; then you can know already that if &amp;lt;code&amp;gt;L&amp;lt;/code&amp;gt; is some kind of list object and &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; is an available messsage for it, for sure, you just do &amp;lt;code&amp;gt;L size&amp;lt;/code&amp;gt;. Do you want to upcase a string? what if &amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; is a string you just to &amp;lt;code&amp;gt;S upcase&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A prgramming lanuage v.s. an operating system&#039;&#039;&#039;. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Closed languages v.s. Open languages&#039;&#039;&#039;. Suppose you want to teach a Python string how to do something. That is for example you red a CSV file or receiveing data from a web form, you are parsing fields and you have one for phone numbers. You may have prepared a proper PhoneNumber class to deal with this kid of data but when you read the CSV it will arrive you as a String. So you would like to do something like this: &amp;lt;code&amp;gt;&#039;+39425805040&#039;.toPhoneNumber() &amp;lt;/code&amp;gt;  well, you can forget about it, you can&#039;t do it in Python, built in data structures are untouchable. In Smalltalk instead it is a silly business you add the &amp;lt;code&amp;gt;toPhoneNumber&amp;lt;/code&amp;gt; to the String class and that&#039;s it, your program now knows how to transform String into PhoneNumbers. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chained v.s. unchained languages&#039;&#039;&#039;. Suppose you are dealing with a very special problem and you need to redefine a builtin method.... no tail call regression ...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live programming environment v.s. Write-Run-Stop-Write-Run loop&#039;&#039;&#039;. This will seem magic to you, it was for me. The way we are used to program computer is this. We write a program, run it, see what does not work, stop it (it does not dies by itself for a bug) write in a correction, run again. Repeat the loop, this is your programmer day. If you are unlucky there is also the compile step, if you are really unlucky add the reboot step. Well, forget about this horrible situation, the Smalltalk programming environment is always active! Smalltalk never stops, when a strange condition happens a debugger pops up and asks you 99% of the time &amp;quot;This object does not know how to answer to the message you sent him, what do we do?&amp;quot; . It is nothing dramatic, you teach the object how to answer the message and the programs goes on. It seems unreal, but it is just like that. Your programmer day is now building nice objects which are able to undestand messages. It could be that you are a scientific programmer and you need to teach the object &amp;lt;code&amp;gt;Matrix&amp;lt;/code&amp;gt; how to deal with a message &amp;lt;code&amp;gt;eigenvalues&amp;lt;/code&amp;gt;, it could be you are into web programming and your &amp;lt;code&amp;gt;WebServer&amp;lt;/code&amp;gt; object has received a message &amp;lt;code&amp;gt;getPriceItemWithCode:231231231&amp;lt;/code&amp;gt; it does not matter what you need to teach your computer, the scheme is fixed, it is just object and messages. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HackableSystems v.s. LockedSystems&#039;&#039;&#039;. Suppose one day you want to change your control structures, for example, in your application, you would like to define a different kind of for loop, let&#039;s call it the &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt;, that on each loop if forgets to iterate over one element taken at random. That is not going to be easy in Python. In Smalltalk it is trivial, because the for loop is achieved with a message, you want to define &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt; it is just matter of defining a new message.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Maintainability&#039;&#039;&#039;. The order spurs from the object system. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live inspectable and changeable objects&#039;&#039;&#039;. This concept does not exist in python. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The magic of the event system&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming by simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The image&#039;&#039;&#039;. In Smalltalk there is the concept of the image. This does not exist in Python. The image contains all your program and state, always. At some time you can tell Smalltalk to save the image into a file and than, another day, recover to that exact point. You can send the image to a far colleague for him to see what you are seeing right now, no differences. This can be extremely helpful in at least a few circumstances, you found a bug, you would like to make a proper correction but for the moment the program needs to just run, so you save the image into a file, make a quick fix then send yourself the broken image to produce a better quality code patch. Consider another case, you are doing a simulation, there are several random variables, and the simulation took hours or days to complete. You see some incredible results, you need to think about it, show it to your colleagues, so you save the image into a file and when you will be ready you can inspect whatever you with wish. Isn&#039;t it fantastic? A few other languages have images, like &#039;&#039;Common Lisp&#039;&#039; and &#039;&#039;R&#039;&#039;, but in Smalltalk the thing is even more interesting because with its integrated environment looking into variables (which for us are objects) is a pleasant activity compared to digging into data files, core dumps or JSON structures from the command line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ease of code hiding&#039;&#039;&#039;. If you are not running an opensource project soon enough you will hit this problem: &amp;quot;If I leave my code open my software will be copied and I can&#039;t sell it to anybody&amp;quot;. This is an unfortunate truth. So, if you need to hide your code, at this moment in time, Cuis-Smalltalk is not the tool for you. AFAIK the same goes for Pharo and Squeak. You may wish to try some commercial Smalltalk, for example Cincom.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=186</id>
		<title>Why Smalltalk?</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=186"/>
		<updated>2025-05-12T20:56:22Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NOT COMPLETE -- ACCUMULATING MATERIAL&lt;br /&gt;
&lt;br /&gt;
It would be easy here to fill 10 pages of abstract concepts, I don&#039;t want to do that. We will compare Smalltalk with another language, a popular one, a good one: Python. If you know already Python why should you learn Smalltalk? &lt;br /&gt;
&lt;br /&gt;
Let&#039;s start from a fundamental concept, almost all popular programming languages can solve almost all existing problems. So why to learn more than one? Well, quoting &#039;&#039;Wittgenstein&#039;&#039;  &amp;quot;My language is my world&amp;quot;, this holds true also for programming languages, when you choose a programming language you actually don&#039;t choose what it is possible to do, but what it will be easy to achieve, the computer view of the World, what it will be easy to talk about. For example, in C you can access directly memory locations, in Python and Smalltalk you can&#039;t easily do it, therefore if you are working very low level, e.g. you are writing a driver, C is just a more fit tool. Then, suppose your problem is to take all files in your hard drive and find the 10 largest. Well, in C to do this it will take about 1 hour, minimum. In Python and Smalltalk you can do it in a few minutes. &lt;br /&gt;
&lt;br /&gt;
Factors useful in deciding the programming language for your next task.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;execution speed&#039;&#039;&#039;. How fast can your code run? Here the fastest are C, Fortran, C++, . Python and Smalltalk can&#039;t even compare to them. TODO COMPARE Python and Smalltalk speed.&lt;br /&gt;
* &#039;&#039;&#039;cross OS portability&#039;&#039;&#039;. Can you run your code in a Mac, Windows, Linux, BSD ? Here Python and Smalltalk are very good and C is very bad, your code is going to run on the major OS without changes or with little changes. For example in Windows the root directory is &#039;C:\&#039; in Unix like systems it is &#039;/&#039;. This little things must always be fixed. In C you would need to compile a specific version of the program for every OS.&lt;br /&gt;
* &#039;&#039;&#039;cross architecture portability&#039;&#039;&#039;. Can you run your code in an normal PC as well as in a RPi, in a BeagleBone Black, in a Web browser ? In C this is a problem, Python is quite portable, Smalltalk is the king it can run in very different platform, for example with [https://squeak.js.org/ SqueakJS] you can run you program written for a PC straight into the Web. You can&#039;t do easily this in any other programming language of my knowledge.&lt;br /&gt;
* &#039;&#039;&#039;library availability for your task&#039;&#039;&#039;. Here C is the king, there is a library for everything. Python is still very good the library park is huge, expecially since it got supported from Google. In Smalltalk we are far from their level. If you need a very specialized library either you write it or you call external code.&lt;br /&gt;
* &#039;&#039;&#039;community size and colleagues&#039;&#039;&#039;.  At some moment you will get stuck. It is true, with open source you can read all the code and answer your own question but it can take a large effort and if you are at a beginner-intermediate level this is just not possible. Therefore, a factor to consider well is: can you communicate with somebody how may answer your question, is there enough people using the technology. Not least, can you find programmers who know the language and work with you on a project ? Here C and Python shine, in Smalltalk it is a bit of a issue but we have our communities.&lt;br /&gt;
* &#039;&#039;&#039;development speed&#039;&#039;&#039;. Here C is really bad, writing programs takes time, debugging is hard. Python is really already a lot better I would estimate you can be 5-10 faster writing in Python. Smalltalk is the best, with its powerful tools and Platonic design not only development is fast, debugging is fast and not so tedious. I estimate you can be 2-3 times faster writing in Smalltalk respect to Python.&lt;br /&gt;
* &#039;&#039;&#039;software maintainability&#039;&#039;&#039;. The moment comes software must be changed to adapt to new circumstances. In C these are often hard time, in Python better but still, its imperative nature may require you to understand conceptual workflow of all the application. The change from Python2 to Python3 was an example of this problem, people is still getting payed to convert scripts to Python3. Smalltalk here shines, it is a system made for changes and evolutive software development. There is no difference from the concept of software creation of and software change, you work in the same way and Smalltalk, be default, brings all the development environment with itself, editor and debugger included. In Smalltalk you always work on the running program. There is no concept of switching it off, change the code and run it again. See it this way, for a &amp;quot;Python is better than C&amp;quot; zealot you will hear this argument: &amp;quot;There aren&#039;t boring compile steps&amp;quot;. A Smalltalk zealot laugh at that, he may tell you &amp;quot;There aren&#039;t boring shut down, correct and restart the application steps&amp;quot;, the application is always running. &lt;br /&gt;
* &#039;&#039;&#039;vendor support&#039;&#039;&#039;. Is there a company that sells an implementation of your language ? This can be useful, if you get in real trouble you would know where to ask for help at any level. For C, sure, there are several compiler vendors. Python is a community only language and as far as I know there isn&#039;t a corporate release of the language, there are though thousands of Python software houses so you can consider your self kind of safe. In Smalltalk there are vendors with a private implementation of the system for example [https://www.cincomsmalltalk.com/main/products/visualworks/ VisualWorks]. If you are in a corporate environment consider well the option of using their services. Also, their documentation might be far superior to open source projects. It is an option to keep in mind.&lt;br /&gt;
* &#039;&#039;&#039;self mutability&#039;&#039;&#039;. At times you may want to do something unusual. Maybe you would like to change the language a bit, for example a change in the standard library. Let&#039;s say I want to teach the String class to recognize Italian words, say i want a String to be able to answer the question &#039;isItalian&#039;. In C there is not even the Class concept, in Python there are Classes but you just can&#039;t, the standard library is sealed you are not supposed to change it. In Smalltalk you can change whatever you want, you want to change the meaning of &#039;=&#039; between Floats ? You can. Add a new operator &#039;@=&#039; tell true if two numbers are equals if their distance is less than 0.00000001 ? You can, and it is very easy, there isn&#039;t a an arcane syntax, it is just standard procedure.&lt;br /&gt;
* &#039;&#039;&#039;the fun factor&#039;&#039;&#039;. After the birth of my first son I had to put an hard stop on Smalltalk coding. More urgent things popped into my hands and I had to restrict my coding to the minimum effort tool to get the job done. In my case it turned out to be a &#039;sh&#039; script or &#039;Python&#039;. Though, in retrospective, I see how productive I am since, in Python I have all libraries for what I need and I can operate from the shell, I don&#039;t need a GUI, which for server people like me it is a major source of problems. But programming in Smalltalk is really another life respect to Python, even using Python as a Lisp, so REPL&#039;ing all the time, testing all functions and objects and methods. There are 2 key points here: &#039;&#039;&#039;(1-observability)&#039;&#039;&#039; in Smalltalk, most of the time, you can see well the data structure going around your code since they are just objects. &#039;&#039;&#039;(2-correct-rerun-running-code)&#039;&#039;&#039; in Smalltalk when the program breaks it doesn&#039;t just tell you, &amp;quot;I found a problem in line 345&amp;quot; and spit at you the dead body of a stack trace. No, in Smalltalk the debugger opens and you are brought in the middle of the things while they are still happening. This is really, really the best experience. Lisp does kind of the same but inspecting data structures in Lisp is a major source of pain.&lt;br /&gt;
&lt;br /&gt;
There is a first factor which is very important which is &#039;&#039;&#039;execution&#039;&#039;&#039; &#039;&#039;&#039;speed&#039;&#039;&#039;. Some languages are faster than others for example C is faster than Python and Smalltalk, so if speed is your paramount interest, let&#039;s say you are writing a new matrix multiplication algorithm it is better you just do it in C. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Pure v.s. Mixed languages&#039;&#039;&#039;. Python is an imperative programming language which borrow some Object Orientation principles, some functional style and tryies to make everybody happy. Consider this &amp;lt;code&amp;gt;l = [1,2,3]&amp;lt;/code&amp;gt; you made a list, you can&#039;t say &amp;lt;code&amp;gt;l.len()&amp;lt;/code&amp;gt; as it should be if Python was reasonable object oriented, no, no, you must do &amp;lt;code&amp;gt;len(l)&amp;lt;/code&amp;gt;. This is just arbitrary. There is not a global plan in the Python language, it grows to accomodate new fashions. Smalltalk is completely different. In Smalltalk there is a plan, a view of the world and it is unescapeable, everything is an object and the only thing you can do is to send and object a message. Therefore if i tell you that the format to send a message to an object is &amp;lt;code&amp;gt;OBJECT MESSAGE&amp;lt;/code&amp;gt; then you can know already that if &amp;lt;code&amp;gt;L&amp;lt;/code&amp;gt; is some kind of list object and &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; is an available messsage for it, for sure, you just do &amp;lt;code&amp;gt;L size&amp;lt;/code&amp;gt;. Do you want to upcase a string? what if &amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; is a string you just to &amp;lt;code&amp;gt;S upcase&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A prgramming lanuage v.s. an operating system&#039;&#039;&#039;. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Closed languages v.s. Open languages&#039;&#039;&#039;. Suppose you want to teach a Python string how to do something. That is for example you red a CSV file or receiveing data from a web form, you are parsing fields and you have one for phone numbers. You may have prepared a proper PhoneNumber class to deal with this kid of data but when you read the CSV it will arrive you as a String. So you would like to do something like this: &amp;lt;code&amp;gt;&#039;+39425805040&#039;.toPhoneNumber() &amp;lt;/code&amp;gt;  well, you can forget about it, you can&#039;t do it in Python, built in data structures are untouchable. In Smalltalk instead it is a silly business you add the &amp;lt;code&amp;gt;toPhoneNumber&amp;lt;/code&amp;gt; to the String class and that&#039;s it, your program now knows how to transform String into PhoneNumbers. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chained v.s. unchained languages&#039;&#039;&#039;. Suppose you are dealing with a very special problem and you need to redefine a builtin method.... no tail call regression ...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live programming environment v.s. Write-Run-Stop-Write-Run loop&#039;&#039;&#039;. This will seem magic to you, it was for me. The way we are used to program computer is this. We write a program, run it, see what does not work, stop it (it does not dies by itself for a bug) write in a correction, run again. Repeat the loop, this is your programmer day. If you are unlucky there is also the compile step, if you are really unlucky add the reboot step. Well, forget about this horrible situation, the Smalltalk programming environment is always active! Smalltalk never stops, when a strange condition happens a debugger pops up and asks you 99% of the time &amp;quot;This object does not know how to answer to the message you sent him, what do we do?&amp;quot; . It is nothing dramatic, you teach the object how to answer the message and the programs goes on. It seems unreal, but it is just like that. Your programmer day is now building nice objects which are able to undestand messages. It could be that you are a scientific programmer and you need to teach the object &amp;lt;code&amp;gt;Matrix&amp;lt;/code&amp;gt; how to deal with a message &amp;lt;code&amp;gt;eigenvalues&amp;lt;/code&amp;gt;, it could be you are into web programming and your &amp;lt;code&amp;gt;WebServer&amp;lt;/code&amp;gt; object has received a message &amp;lt;code&amp;gt;getPriceItemWithCode:231231231&amp;lt;/code&amp;gt; it does not matter what you need to teach your computer, the scheme is fixed, it is just object and messages. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HackableSystems v.s. LockedSystems&#039;&#039;&#039;. Suppose one day you want to change your control structures, for example, in your application, you would like to define a different kind of for loop, let&#039;s call it the &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt;, that on each loop if forgets to iterate over one element taken at random. That is not going to be easy in Python. In Smalltalk it is trivial, because the for loop is achieved with a message, you want to define &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt; it is just matter of defining a new message.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Maintainability&#039;&#039;&#039;. The order spurs from the object system. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live inspectable and changeable objects&#039;&#039;&#039;. This concept does not exist in python. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The magic of the event system&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming by simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The image&#039;&#039;&#039;. In Smalltalk there is the concept of the image. This does not exist in Python. The image contains all your program and state, always. At some time you can tell Smalltalk to save the image into a file and than, another day, recover to that exact point. You can send the image to a far colleague for him to see what you are seeing right now, no differences. This can be extremely helpful in at least a few circumstances, you found a bug, you would like to make a proper correction but for the moment the program needs to just run, so you save the image into a file, make a quick fix then send yourself the broken image to produce a better quality code patch. Consider another case, you are doing a simulation, there are several random variables, and the simulation took hours or days to complete. You see some incredible results, you need to think about it, show it to your colleagues, so you save the image into a file and when you will be ready you can inspect whatever you with wish. Isn&#039;t it fantastic? A few other languages have images, like &#039;&#039;Common Lisp&#039;&#039; and &#039;&#039;R&#039;&#039;, but in Smalltalk the thing is even more interesting because with its integrated environment looking into variables (which for us are objects) is a pleasant activity compared to digging into data files, core dumps or JSON structures from the command line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ease of code hiding&#039;&#039;&#039;. If you are not running an opensource project soon enough you will hit this problem: &amp;quot;If I leave my code open my software will be copied and I can&#039;t sell it to anybody&amp;quot;. This is an unfortunate truth. So, if you need to hide your code, at this moment in time, Cuis-Smalltalk is not the tool for you. AFAIK the same goes for Pharo and Squeak. You may wish to try some commercial Smalltalk, for example Cincom.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=185</id>
		<title>Why Smalltalk?</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Why_Smalltalk%3F&amp;diff=185"/>
		<updated>2025-05-12T20:53:18Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NOT COMPLETE -- ACCUMULATING MATERIAL&lt;br /&gt;
&lt;br /&gt;
It would be easy here to fill 10 pages of abstract concepts, I don&#039;t want to do that. We will compare Smalltalk with another language, a popular one, a good one: Python. If you know already Python why should you learn Smalltalk? &lt;br /&gt;
&lt;br /&gt;
Let&#039;s start from a fundamental concept, almost all popular programming languages can solve almost all existing problems. So why to learn more than one? Well, quoting &#039;&#039;Wittgenstein&#039;&#039;  &amp;quot;My language is my world&amp;quot;, this holds true also for programming languages, when you choose a programming language you actually don&#039;t choose what it is possible to do, but what it will be easy to achieve, the computer view of the World, what it will be easy to talk about. For example, in C you can access directly memory locations, in Python and Smalltalk you can&#039;t easily do it, therefore if you are working very low level, e.g. you are writing a driver, C is just a more fit tool. Then, suppose your problem is to take all files in your hard drive and find the 10 largest. Well, in C to do this it will take about 1 hour, minimum. In Python and Smalltalk you can do it in a few minutes. &lt;br /&gt;
&lt;br /&gt;
Factors useful in deciding the programming language for your next task.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;execution speed&#039;&#039;&#039;. How fast can your code run? Here the fastest are C, Fortran, C++, . Python and Smalltalk can&#039;t even compare to them. TODO COMPARE Python and Smalltalk speed.&lt;br /&gt;
* &#039;&#039;&#039;cross OS portability&#039;&#039;&#039;. Can you run your code in a Mac, Windows, Linux, BSD ? Here Python and Smalltalk are very good and C is very bad, your code is going to run on the major OS without changes or with little changes. For example in Windows the root directory is &#039;C:\&#039; in Unix like systems it is &#039;/&#039;. This little things must always be fixed. In C you would need to compile a specific version of the program for every OS.&lt;br /&gt;
* &#039;&#039;&#039;cross architecture portability&#039;&#039;&#039;. Can you run your code in an normal PC as well as in a RPi, in a BeagleBone Black, in a Web browser ? In C this is a problem, Python is quite portable, Smalltalk is the king it can run in very different platform, for example with [https://squeak.js.org/ SqueakJS] you can run you program written for a PC straight into the Web. You can&#039;t do easily this in any other programming language of my knowledge.&lt;br /&gt;
* &#039;&#039;&#039;library availability for your task&#039;&#039;&#039;. Here C is the king, there is a library for everything. Python is still very good the library park is huge, expecially since it got supported from Google. In Smalltalk we are far from their level. If you need a very specialized library either you write it or you call external code.&lt;br /&gt;
* &#039;&#039;&#039;community size and colleagues&#039;&#039;&#039;.  At some moment you will get stuck. It is true, with open source you can read all the code and answer your own question but it can take a large effort and if you are at a beginner-intermediate level this is just not possible. Therefore, a factor to consider well is: can you communicate with somebody how may answer your question, is there enough people using the technology. Not least, can you find programmers who know the language and work with you on a project ? Here C and Python shine, in Smalltalk it is a bit of a issue but we have our communities.&lt;br /&gt;
* &#039;&#039;&#039;development speed&#039;&#039;&#039;. Here C is really bad, writing programs takes time, debugging is hard. Python is really already a lot better I would estimate you can be 5-10 faster writing in Python. Smalltalk is the best, with its powerful tools and Platonic design not only development is fast, debugging is fast and not so tedious. I estimate you can be 2-3 times faster writing in Smalltalk respect to Python.&lt;br /&gt;
* &#039;&#039;&#039;software maintainability&#039;&#039;&#039;. The moment comes software must be changed to adapt to new circumstances. In C these are often hard time, in Python better but still, its imperative nature may require you to understand conceptual workflow of all the application. The change from Python2 to Python3 was an example of this problem, people is still getting payed to convert scripts to Python3. Smalltalk here shines, it is a system made for changes and evolutive software development. There is no difference from the concept of software creation of and software change, you work in the same way and Smalltalk, be default, brings all the development environment with itself, editor and debugger included. In Smalltalk you always work on the running program. There is no concept of switching it off, change the code and run it again. See it this way, for a &amp;quot;Python is better than C&amp;quot; zealot you will hear this argument: &amp;quot;There aren&#039;t boring compile steps&amp;quot;. A Smalltalk zealot laugh at that, he may tell you &amp;quot;There aren&#039;t boring shut down, correct and restart the application steps&amp;quot;, the application is always running. &lt;br /&gt;
* &#039;&#039;&#039;vendor support&#039;&#039;&#039;. Is there a company that sells an implementation of your language ? This can be useful, if you get in real trouble you would know where to ask for help at any level. For C, sure, there are several compiler vendors. Python is a community only language and as far as I know there isn&#039;t a corporate release of the language, there are though thousands of Python software houses so you can consider your self kind of safe. In Smalltalk there are vendors with a private implementation of the system for example [https://www.cincomsmalltalk.com/main/products/visualworks/ VisualWorks]. If you are in a corporate environment consider well the option of using their services. Also, their documentation might be far superior to open source projects. It is an option to keep in mind.&lt;br /&gt;
* &#039;&#039;&#039;self mutability&#039;&#039;&#039;. At times you may want to do something unusual. Maybe you would like to change the language a bit, for example a change in the standard library. Let&#039;s say I want to teach the String class to recognize Italian words, say i want a String to be able to answer the question &#039;isItalian&#039;. In C there is not even the Class concept, in Python there are Classes but you just can&#039;t, the standard library is sealed you are not supposed to change it. In Smalltalk you can change whatever you want, you want to change the meaning of &#039;=&#039; between Floats ? You can. Add a new operator &#039;@=&#039; tell true if two numbers are equals if their distance is less than 0.00000001 ? You can, and it is very easy, there isn&#039;t a an arcane syntax, it is just standard procedure.&lt;br /&gt;
* &#039;&#039;&#039;the fun factor&#039;&#039;&#039;. After the birth of my first son I had to put an hard stop on Smalltalk coding. More urgent things popped into my hands and I had to restrict my coding to the minimum effort tool to get the job done. In my case it turned out to be a &#039;sh&#039; script or &#039;Python&#039;. Though, in retrospective, I see how productive I am since, in Python I have all libraries for what I need and I can operate from the shell, I don&#039;t need a GUI, which for server people like me it is a major source of problems. But programming in Smalltalk is really another life respect to Python, even using Python as a Lisp, so REPL&#039;ing all the time, testing all functions and objects and methogs. There are 2 key points here: (1) in Smalltalk, most of the time, you can see well the data structure going around your code since they are just objects. (2) in Smalltalk when the program breaks it doesn&#039;t just tell you, &amp;quot;I found a problem in line 345&amp;quot; and spit at you the dead body of a stack trace. No, in Smalltalk the debugger opens and you are brought in the middle of the things while they are still happening. This is really, really the best experience. Lisp does kind of the same but inspecting data structures in Lisp is a major source of pain.&lt;br /&gt;
&lt;br /&gt;
There is a first factor which is very important which is &#039;&#039;&#039;execution&#039;&#039;&#039; &#039;&#039;&#039;speed&#039;&#039;&#039;. Some languages are faster than others for example C is faster than Python and Smalltalk, so if speed is your paramount interest, let&#039;s say you are writing a new matrix multiplication algorithm it is better you just do it in C. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Pure v.s. Mixed languages&#039;&#039;&#039;. Python is an imperative programming language which borrow some Object Orientation principles, some functional style and tryies to make everybody happy. Consider this &amp;lt;code&amp;gt;l = [1,2,3]&amp;lt;/code&amp;gt; you made a list, you can&#039;t say &amp;lt;code&amp;gt;l.len()&amp;lt;/code&amp;gt; as it should be if Python was reasonable object oriented, no, no, you must do &amp;lt;code&amp;gt;len(l)&amp;lt;/code&amp;gt;. This is just arbitrary. There is not a global plan in the Python language, it grows to accomodate new fashions. Smalltalk is completely different. In Smalltalk there is a plan, a view of the world and it is unescapeable, everything is an object and the only thing you can do is to send and object a message. Therefore if i tell you that the format to send a message to an object is &amp;lt;code&amp;gt;OBJECT MESSAGE&amp;lt;/code&amp;gt; then you can know already that if &amp;lt;code&amp;gt;L&amp;lt;/code&amp;gt; is some kind of list object and &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; is an available messsage for it, for sure, you just do &amp;lt;code&amp;gt;L size&amp;lt;/code&amp;gt;. Do you want to upcase a string? what if &amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; is a string you just to &amp;lt;code&amp;gt;S upcase&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A prgramming lanuage v.s. an operating system&#039;&#039;&#039;. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Closed languages v.s. Open languages&#039;&#039;&#039;. Suppose you want to teach a Python string how to do something. That is for example you red a CSV file or receiveing data from a web form, you are parsing fields and you have one for phone numbers. You may have prepared a proper PhoneNumber class to deal with this kid of data but when you read the CSV it will arrive you as a String. So you would like to do something like this: &amp;lt;code&amp;gt;&#039;+39425805040&#039;.toPhoneNumber() &amp;lt;/code&amp;gt;  well, you can forget about it, you can&#039;t do it in Python, built in data structures are untouchable. In Smalltalk instead it is a silly business you add the &amp;lt;code&amp;gt;toPhoneNumber&amp;lt;/code&amp;gt; to the String class and that&#039;s it, your program now knows how to transform String into PhoneNumbers. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chained v.s. unchained languages&#039;&#039;&#039;. Suppose you are dealing with a very special problem and you need to redefine a builtin method.... no tail call regression ...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live programming environment v.s. Write-Run-Stop-Write-Run loop&#039;&#039;&#039;. This will seem magic to you, it was for me. The way we are used to program computer is this. We write a program, run it, see what does not work, stop it (it does not dies by itself for a bug) write in a correction, run again. Repeat the loop, this is your programmer day. If you are unlucky there is also the compile step, if you are really unlucky add the reboot step. Well, forget about this horrible situation, the Smalltalk programming environment is always active! Smalltalk never stops, when a strange condition happens a debugger pops up and asks you 99% of the time &amp;quot;This object does not know how to answer to the message you sent him, what do we do?&amp;quot; . It is nothing dramatic, you teach the object how to answer the message and the programs goes on. It seems unreal, but it is just like that. Your programmer day is now building nice objects which are able to undestand messages. It could be that you are a scientific programmer and you need to teach the object &amp;lt;code&amp;gt;Matrix&amp;lt;/code&amp;gt; how to deal with a message &amp;lt;code&amp;gt;eigenvalues&amp;lt;/code&amp;gt;, it could be you are into web programming and your &amp;lt;code&amp;gt;WebServer&amp;lt;/code&amp;gt; object has received a message &amp;lt;code&amp;gt;getPriceItemWithCode:231231231&amp;lt;/code&amp;gt; it does not matter what you need to teach your computer, the scheme is fixed, it is just object and messages. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HackableSystems v.s. LockedSystems&#039;&#039;&#039;. Suppose one day you want to change your control structures, for example, in your application, you would like to define a different kind of for loop, let&#039;s call it the &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt;, that on each loop if forgets to iterate over one element taken at random. That is not going to be easy in Python. In Smalltalk it is trivial, because the for loop is achieved with a message, you want to define &amp;lt;code&amp;gt;forgettyFor&amp;lt;/code&amp;gt; it is just matter of defining a new message.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Maintainability&#039;&#039;&#039;. The order spurs from the object system. ... &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Live inspectable and changeable objects&#039;&#039;&#039;. This concept does not exist in python. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The magic of the event system&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming by simulation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The image&#039;&#039;&#039;. In Smalltalk there is the concept of the image. This does not exist in Python. The image contains all your program and state, always. At some time you can tell Smalltalk to save the image into a file and than, another day, recover to that exact point. You can send the image to a far colleague for him to see what you are seeing right now, no differences. This can be extremely helpful in at least a few circumstances, you found a bug, you would like to make a proper correction but for the moment the program needs to just run, so you save the image into a file, make a quick fix then send yourself the broken image to produce a better quality code patch. Consider another case, you are doing a simulation, there are several random variables, and the simulation took hours or days to complete. You see some incredible results, you need to think about it, show it to your colleagues, so you save the image into a file and when you will be ready you can inspect whatever you with wish. Isn&#039;t it fantastic? A few other languages have images, like &#039;&#039;Common Lisp&#039;&#039; and &#039;&#039;R&#039;&#039;, but in Smalltalk the thing is even more interesting because with its integrated environment looking into variables (which for us are objects) is a pleasant activity compared to digging into data files, core dumps or JSON structures from the command line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ease of code hiding&#039;&#039;&#039;. If you are not running an opensource project soon enough you will hit this problem: &amp;quot;If I leave my code open my software will be copied and I can&#039;t sell it to anybody&amp;quot;. This is an unfortunate truth. So, if you need to hide your code, at this moment in time, Cuis-Smalltalk is not the tool for you. AFAIK the same goes for Pharo and Squeak. You may wish to try some commercial Smalltalk, for example Cincom.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Dependency_Mechanism_-_part_3&amp;diff=184</id>
		<title>The Dependency Mechanism - part 3</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Dependency_Mechanism_-_part_3&amp;diff=184"/>
		<updated>2025-05-12T20:42:52Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* In Cuis the dependency is handled with the  Observer pattern&lt;br /&gt;
* In the observer pattern an object called &#039;&#039;&#039;subject&#039;&#039;&#039; maintains a list of &#039;&#039;&#039;observers&#039;&#039;&#039;. The &#039;&#039;&#039;subject&#039;&#039;&#039; notifies its &#039;&#039;&#039;observers&#039;&#039;&#039; when it changes.&lt;br /&gt;
* In Cuis the Parent-Dependent pattern is implemented with the Subject-Observer this way&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|&#039;&#039;&#039;Parent-Dependent&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Subject-Observer&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|connection making. &#039;&#039;&#039;objB&#039;&#039;&#039; wants to be informed of changes in &#039;&#039;&#039;objA&#039;&#039;&#039;.&lt;br /&gt;
|&amp;lt;code&amp;gt;objA addDependent: objB&amp;lt;/code&amp;gt;&lt;br /&gt;
|&amp;lt;code&amp;gt;objA when: #changed send: #update to: objB&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;objA&#039;&#039;&#039; tells the objects who are watching it that it changed state.&lt;br /&gt;
|&amp;lt;code&amp;gt;objA changed: #param&amp;lt;/code&amp;gt;&lt;br /&gt;
|&amp;lt;code&amp;gt;objA triggerEvent: #changed with: #param&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|when  &#039;&#039;&#039;objA&#039;&#039;&#039; state changes the message &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; is sent to &#039;&#039;&#039;objB&#039;&#039;&#039; with a parameter.&lt;br /&gt;
|&amp;lt;code&amp;gt;objB update: #param&amp;lt;/code&amp;gt;&lt;br /&gt;
|&amp;lt;code&amp;gt;objB update: #param&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|we want &#039;&#039;&#039;objB&#039;&#039;&#039; to stop watching &#039;&#039;&#039;objA&#039;&#039;&#039;&lt;br /&gt;
|&amp;lt;code&amp;gt;objA removeDependent: objB&amp;lt;/code&amp;gt;&lt;br /&gt;
|&amp;lt;code&amp;gt;objA removeActionWithReceiver: objB forEvent: #changed&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Observe that the parameter &amp;lt;code&amp;gt;#changed&amp;lt;/code&amp;gt; is used explicitly in Cuis to build Parent-Dependent pattern, but that is actually a free parameter in the Observer model.&lt;br /&gt;
* In Cuis6 &#039;&#039;&#039;Model&#039;&#039;&#039; is substituted by &#039;&#039;&#039;ActiveModel&#039;&#039;&#039;, if you look into the implementation of the Parent-Dependent pattern you will see that dependencies between objects go by default stored in class variable &#039;&#039;&#039;ActionMaps&#039;&#039;&#039; of &#039;&#039;&#039;ActiveModel&#039;&#039;&#039; . This instead of using class variable &#039;&#039;&#039;DependentsFields&#039;&#039;&#039; of class &#039;&#039;&#039;Object&#039;&#039;&#039;, as done in the classic implementation, for example in VisualWorks and Squeak.&lt;br /&gt;
* &#039;&#039;&#039;Exercise&#039;&#039;&#039;. Use &amp;lt;code&amp;gt;ActiveModel actionMaps&amp;lt;/code&amp;gt; to explore the &#039;&#039;&#039;ActionMaps&#039;&#039;&#039; class variable content.&lt;br /&gt;
* Mirroring our previous example in the Parent-Dependent model, we impolement of two simple classes (in the Subject-Observer model) &#039;&#039;&#039;MyActiveNumber&#039;&#039;&#039; and &#039;&#039;&#039;MyObserverNumber&#039;&#039;&#039; for objects &#039;&#039;&#039;objA&#039;&#039;&#039; and &#039;&#039;&#039;objB&#039;&#039;&#039;, where &#039;&#039;&#039;objB&#039;&#039;&#039; is observer for &#039;&#039;&#039;objA&#039;&#039;&#039;. We want to keep the dependency mechanism localized so &#039;&#039;&#039;MyActiveNumber&#039;&#039;&#039; will be subclass of &#039;&#039;&#039;ActiveModel&#039;&#039;&#039; (instead of &#039;&#039;&#039;Object&#039;&#039;&#039;). When &#039;&#039;&#039;objA&#039;&#039;&#039; changes we want &#039;&#039;&#039;objB&#039;&#039;&#039; to receive the message &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt;, we don&#039;t want to pass any parameter, &#039;&#039;&#039;objB&#039;&#039;&#039; will ask what it need to &#039;&#039;&#039;objA&#039;&#039;&#039;. You can get the fileout here: MyActiveNumber.st and MyObserverNumber.st .&lt;br /&gt;
&lt;br /&gt;
 ActiveModel subclass: #MyActiveNumber&lt;br /&gt;
     instanceVariableNames: &#039;value&#039;&lt;br /&gt;
 &lt;br /&gt;
 MyActiveNumber &amp;gt;&amp;gt; initialize&lt;br /&gt;
     value := 0. &lt;br /&gt;
     ^ self &lt;br /&gt;
 &lt;br /&gt;
 MyActiveNumber &amp;gt;&amp;gt; value &lt;br /&gt;
         ^ value &lt;br /&gt;
 &lt;br /&gt;
 MyActiveNumber &amp;gt;&amp;gt; value: aNumber        &lt;br /&gt;
         value := aNumber&lt;br /&gt;
         self triggerEvent: #iChanged &lt;br /&gt;
 &lt;br /&gt;
 Object subclass: #MyObserverNumber&lt;br /&gt;
     instanceVariableNames: &#039;value model&#039;  &lt;br /&gt;
 &lt;br /&gt;
 MyObserverNumber class &amp;gt;&amp;gt; newWithModel: anObject&lt;br /&gt;
     ^ super new initializeWithModel: anObject&lt;br /&gt;
 &lt;br /&gt;
 MyObserverNumber &amp;gt;&amp;gt; initializeWithModel: anObject&lt;br /&gt;
     value := 0.&lt;br /&gt;
     model := anObject . &lt;br /&gt;
     model when: #iChanged send: #update  to: self .  &lt;br /&gt;
     ^ self     &lt;br /&gt;
 &lt;br /&gt;
 MyObserverNumber update&lt;br /&gt;
     |vPar vMe |&lt;br /&gt;
      vPar := model value. &lt;br /&gt;
      vMe := vPar * 2.&lt;br /&gt;
      value := vMe.&lt;br /&gt;
      Transcript show: (&#039;my MODEL value is:{1} and mine is value:{2}&#039; format: {vPar. vMe} ). &lt;br /&gt;
 &lt;br /&gt;
 MyObserverNumber value&lt;br /&gt;
          ^ value                                            &lt;br /&gt;
&lt;br /&gt;
* Then try everything works with a little interaction from the Workspace&lt;br /&gt;
&lt;br /&gt;
 objA := MyActiveNumber new. &lt;br /&gt;
 objB := MyObserverNumber newWithModel: objA. &lt;br /&gt;
 &lt;br /&gt;
 objA value .  &amp;quot;=&amp;gt; 0&amp;quot;&lt;br /&gt;
 objB value.   &amp;quot;=&amp;gt; 0&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 objA value: 10.  &lt;br /&gt;
 &lt;br /&gt;
 objB value. &amp;quot;=&amp;gt; 20&amp;quot; &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Exercise&#039;&#039;&#039;. explore &#039;&#039;&#039;objA&#039;&#039;&#039; and convince your self it contains the map toward object &#039;&#039;&#039;objB&#039;&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Dependency_Mechanism_-_part_2&amp;diff=183</id>
		<title>The Dependency Mechanism - part 2</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Dependency_Mechanism_-_part_2&amp;diff=183"/>
		<updated>2025-05-12T20:42:13Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* In &#039;&#039;&#039;Cuis-6&#039;&#039;&#039; there isn&#039;t anymore a &#039;&#039;&#039;Model&#039;&#039;&#039;, there instead an &#039;&#039;&#039;ActiveModel&#039;&#039;&#039; class, but the name &#039;model&#039; a very frequent in the code. You can still find &#039;&#039;&#039;Model&#039;&#039;&#039; in &#039;&#039;&#039;Squeak-5.3&#039;&#039;&#039; and &#039;&#039;&#039;VisualWorks-8.3&#039;&#039;&#039; if you wish to check out some implementation.&lt;br /&gt;
* We have seen (here) how to manage Dependency with the Parent / Dependent strategy. But where do all the relations involving objects are stored ?&lt;br /&gt;
* There relations are stored by default in the class variable &#039;&#039;&#039;DependentsFields&#039;&#039;&#039; of the class &#039;&#039;&#039;Object&#039;&#039;&#039; which is a specialized dictionary, where at every key corresponds an object who is Parent and its values are a list of Dependents objects.&lt;br /&gt;
* You can well understand that if there are a lot of dependencies the dictionary in DependentsFields becomes very large and also, there is another problem. If a dependent lost all references in the VM except for a forgotten relationship link in DependentsFields it will stay there and will not be garbage collected.&lt;br /&gt;
* To avoid these two problems, and for performance reasons, it was introduced the class &#039;&#039;&#039;Model&#039;&#039;&#039; which is a subclass of &#039;&#039;&#039;Object&#039;&#039;&#039; and a has an instance variable field called &amp;lt;code&amp;gt;dependents&amp;lt;/code&amp;gt; where all the dependents are stored.&lt;br /&gt;
* In this way, if &#039;&#039;&#039;objA&#039;&#039;&#039; is a intended to be a Parent and you make it as a &#039;&#039;&#039;Model&#039;&#039;&#039; subclass instance,  all its depency relationships will be localized into &#039;&#039;&#039;objA&#039;&#039;&#039; itself avoiding a large centralized permanent dictionary and also, once you delete &#039;&#039;&#039;objA&#039;&#039;&#039;, you are sure all its dependents will be free to be garbage collected, when necessary.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Dependency_Mechanism_-_part_1&amp;diff=182</id>
		<title>The Dependency Mechanism - part 1</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Dependency_Mechanism_-_part_1&amp;diff=182"/>
		<updated>2025-05-12T20:41:42Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Smalltalk has a way to keep a relation between objects in the sense that, if &#039;&#039;&#039;objA&#039;&#039;&#039; changes then &#039;&#039;&#039;objB&#039;&#039;&#039; gets immediately informed about it.&lt;br /&gt;
* The classic way for an object to keep updated about another object state is &#039;&#039;&#039;polling&#039;&#039;&#039;, that is &#039;&#039;&#039;objB&#039;&#039;&#039; checks every X milliseconds the state of &#039;&#039;&#039;objA&#039;&#039;&#039;. But this is very much resource consuming and, if possible, it should be avoided. Smalltalk has more sophisticated ways to solve this problem.&lt;br /&gt;
* The first thing you need to know is that there is a &#039;&#039;&#039;classic mechanism&#039;&#039;&#039; to do it but in &#039;&#039;&#039;Cuis&#039;&#039;&#039; it has been &#039;&#039;&#039;obsoleted&#039;&#039;&#039;. We will look at it in any case, because you can find it in books.&lt;br /&gt;
&lt;br /&gt;
=== The Classic Mechanism of Parent and Dependent ===&lt;br /&gt;
&lt;br /&gt;
* I red about this mechanism in the two books; the content there has to be adapted to run in Cuis but there is still some good interesting contents.&lt;br /&gt;
** &amp;quot;Smalltalk by Example&amp;quot; by Alec Sharp, see Chapter 19. pg.149.&lt;br /&gt;
** &amp;quot;Smalltalk an introduction to application development with VisualWorks&amp;quot; by Hopkins &amp;amp; Horan, see Chapter 27, pg.287.&lt;br /&gt;
* We will explain this mechanism with the simplest example possible&lt;br /&gt;
* There are two objects, &#039;&#039;&#039;objA&#039;&#039;&#039; and &#039;&#039;&#039;objB&#039;&#039;&#039; which actually contains only just a number in the instance variable &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;.&lt;br /&gt;
* We want that when &#039;&#039;&#039;objA&#039;&#039;&#039; changes its &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; to, say, 10, then &#039;&#039;&#039;objB&#039;&#039;&#039; value must become automatically 20, that is, it must double &#039;&#039;&#039;objA&#039;&#039;&#039; value.&lt;br /&gt;
* So let&#039;s define 2 classes and a few methods, very simple stuff:&lt;br /&gt;
&lt;br /&gt;
 Object subclass: MyParentNumber&lt;br /&gt;
     instanceVariableNames: &#039;value&#039;&lt;br /&gt;
 &lt;br /&gt;
 MyParentNumber &amp;gt;&amp;gt; initialize&lt;br /&gt;
     value := 0 &lt;br /&gt;
     ^ self &lt;br /&gt;
 &lt;br /&gt;
 Object subclass: MyDependentNumber&lt;br /&gt;
     instanceVariableNames: &#039;value&#039;&lt;br /&gt;
 &lt;br /&gt;
 MyDependentNumber &amp;gt;&amp;gt; initialize&lt;br /&gt;
     value := 0 &lt;br /&gt;
     ^ self&lt;br /&gt;
 &lt;br /&gt;
 MyDependentNumber &amp;gt;&amp;gt; update: aParameter&lt;br /&gt;
     |outStr|&lt;br /&gt;
     outStr := &#039;One of my parent changed and toldme &amp;quot;{1}&amp;quot; ! I may do something !&#039; format: {aParam. }. &lt;br /&gt;
     Transcript show: outStr .          &lt;br /&gt;
&lt;br /&gt;
* It is all classic except for the &amp;lt;code&amp;gt;update: aParameter&amp;lt;/code&amp;gt;. That is the method that will be called automatically when &#039;&#039;&#039;objA&#039;&#039;&#039; will get updated.&lt;br /&gt;
* So let&#039;s now create &#039;&#039;&#039;objA&#039;&#039;&#039; ,  &#039;&#039;&#039;objB&#039;&#039;&#039; and make &#039;&#039;&#039;objB&#039;&#039;&#039; dependent on &#039;&#039;&#039;objA&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 objA _ MyParentNumber new.&lt;br /&gt;
 objB _ MyDependentNumber new.  &lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. this makes the connection, the dependency relation &amp;quot;&lt;br /&gt;
 objA addDependent: objB. &lt;br /&gt;
&lt;br /&gt;
* Now, open your Transcript and run this&lt;br /&gt;
&lt;br /&gt;
 objA changed: #foobar.&lt;br /&gt;
&lt;br /&gt;
* You will notice that in the transcript there is written &amp;quot;One of my parent changed and told me &amp;quot;foobar&amp;quot; ! I may do something !&amp;quot;&lt;br /&gt;
* Aha ! It works. You sent a message &amp;lt;code&amp;gt;changed:#aParameter&amp;lt;/code&amp;gt; to &#039;&#039;&#039;objA&#039;&#039;&#039; and the message &amp;lt;code&amp;gt;update:aParameter&amp;lt;/code&amp;gt; was sent to &#039;&#039;&#039;objB&#039;&#039;&#039;.&lt;br /&gt;
* Now we have all the pieces to complete our objective, we just need to glue them together.&lt;br /&gt;
* Before that, let&#039;s &#039;&#039;&#039;break the connection&#039;&#039;&#039; between &#039;&#039;&#039;objA&#039;&#039;&#039; and &#039;&#039;&#039;objB&#039;&#039;&#039; and show that nothing happens anymore.&lt;br /&gt;
&lt;br /&gt;
 objA removeDependent: objB.&lt;br /&gt;
 objA changed: #foobar. &lt;br /&gt;
 objA changed: #foobar. &lt;br /&gt;
 objA changed: #foobar. &lt;br /&gt;
 &amp;quot; ... nothing intereseting appears into the Transcript now&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* So, here is the new version of the code, the code for the new classes MyParentNumber.st and MyDependentNumber.st is available for download and file-in. &lt;br /&gt;
&lt;br /&gt;
 Object subclass: MyParentNumber&lt;br /&gt;
     instanceVariableNames: &#039;value&#039;&lt;br /&gt;
 &lt;br /&gt;
 MyParentNumber &amp;gt;&amp;gt; initialize&lt;br /&gt;
     value := 0 &lt;br /&gt;
     ^ self &lt;br /&gt;
 &lt;br /&gt;
 MyParentNumber &amp;gt;&amp;gt; value&lt;br /&gt;
     ^ value &lt;br /&gt;
 &lt;br /&gt;
 MyParentNumber &amp;gt;&amp;gt; value: aNumber&lt;br /&gt;
      value := aNumber.&lt;br /&gt;
      &amp;quot;when i change, i inform my dependents that i did, they will check what changed.&lt;br /&gt;
       the value of the parameter #iChanged is insignificant. &amp;quot;&lt;br /&gt;
      self changed: #iChanged. &lt;br /&gt;
 &lt;br /&gt;
 Object subclass: MyDependentNumber&lt;br /&gt;
     instanceVariableNames: &#039;value parent&#039;&lt;br /&gt;
 &lt;br /&gt;
 MyDependentNumber Class &amp;gt;&amp;gt; newWithParent: anObject&lt;br /&gt;
     ^ super new initializeWithParent: anObject&lt;br /&gt;
 &lt;br /&gt;
 MyDependentNumber &amp;gt;&amp;gt; initializeWithParent: anObject&lt;br /&gt;
     value := 0.&lt;br /&gt;
     parent := anObject . &lt;br /&gt;
     parent addDependent: self.&lt;br /&gt;
     ^ self &lt;br /&gt;
 &lt;br /&gt;
 MyDependentNumber &amp;gt;&amp;gt; value&lt;br /&gt;
    ^ value &lt;br /&gt;
 &lt;br /&gt;
 MyDependentNumber &amp;gt;&amp;gt; update: aParameter&lt;br /&gt;
     |vPar vMe |&lt;br /&gt;
     &amp;quot;. i don&#039;t check the parameter, since I know that i am bound to only one Parent and i know &lt;br /&gt;
        i can read its state when he tells me that he changed. &amp;quot;&lt;br /&gt;
     vPar := parent value.  &lt;br /&gt;
     vMe := vPar * 2.&lt;br /&gt;
     value := vMe.&lt;br /&gt;
     Transcript show: (&#039;my parent value is:{1} and mine is value:{2}&#039; format: {vPar. vMe} ).  &lt;br /&gt;
&lt;br /&gt;
* Let&#039;s try it out&lt;br /&gt;
&lt;br /&gt;
 objA _ MyParentNumber new.&lt;br /&gt;
 objB _ MyDependentNumber newWithParent: objA. &lt;br /&gt;
 &lt;br /&gt;
 objA value.   &amp;quot;=&amp;gt; 0&amp;quot;&lt;br /&gt;
 objB value .  &amp;quot;=&amp;gt; 0&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 objA value: 10.  &lt;br /&gt;
 objB value.        &amp;quot; =&amp;gt; 20&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We see it works and we are very happy with that.&lt;br /&gt;
* Now the sour part, this mechanism is &#039;&#039;&#039;deprecated&#039;&#039;&#039; in &#039;&#039;&#039;Cuis&#039;&#039;&#039;. The methods &amp;lt;code&amp;gt;addDependent:&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;changed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;update:&amp;lt;/code&amp;gt; ... are defined in &#039;&#039;&#039;Object&#039;&#039;&#039;. And if you look at their implementation you will see the mechanism with is used now, called &#039;&#039;&#039;Observer pattern&#039;&#039;&#039;, which we will see in another page.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Where_to_get_information_about_the_hardware&amp;diff=181</id>
		<title>Where to get information about the hardware</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Where_to_get_information_about_the_hardware&amp;diff=181"/>
		<updated>2025-05-12T20:41:16Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* You can find you &#039;&#039;&#039;screen dimensions&#039;&#039;&#039; with &lt;br /&gt;
&lt;br /&gt;
 DisplayScreen actualScreenSize.     &amp;quot;=&amp;gt; 1920@1080&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* a &lt;br /&gt;
* b&lt;br /&gt;
* c&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Adapt_newline_characters_to_Cuis_standard&amp;diff=180</id>
		<title>Adapt newline characters to Cuis standard</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Adapt_newline_characters_to_Cuis_standard&amp;diff=180"/>
		<updated>2025-05-12T20:40:49Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;TODO&#039;&#039;&#039;. Give a brief intro to the problem.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem&#039;&#039;&#039;. You are loading some code from another Smalltalk, in my case, Squeak, you try to load it into file list and you see funny ending chapters.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution-1&#039;&#039;&#039;. From the FileList: &amp;lt;code&amp;gt;click on the file, move to editor (bottom half), do cmd/alr-a (select all), cmd/alt-shift-u (convert to LF), cmd/alt-s (save)&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=How_to_invoke_the_garbage_collector&amp;diff=179</id>
		<title>How to invoke the garbage collector</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=How_to_invoke_the_garbage_collector&amp;diff=179"/>
		<updated>2025-05-12T20:40:20Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Sometimes you just want to do it. Get rid of stuff that was disseminated into memory and lost contact with your project.&lt;br /&gt;
&lt;br /&gt;
 Smalltalk garbageCollect .&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=About_Random&amp;diff=178</id>
		<title>About Random</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=About_Random&amp;diff=178"/>
		<updated>2025-05-12T20:39:51Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Here I list several useful procedure related to randomness&lt;br /&gt;
&lt;br /&gt;
=== Naive approach ===&lt;br /&gt;
&lt;br /&gt;
* Being &#039;&#039;naive&#039;&#039; here means we are not making any questions about how the random number are generated, what distribution they have, and if the sequence will be repeatable at next &#039;&#039;Cuis&#039;&#039; boot.&lt;br /&gt;
* Get a random number between &#039;&#039;&#039;1&#039;&#039;&#039; and &#039;&#039;&#039;10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;10 atRandom                                 &amp;quot;=&amp;gt; 8 &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Get a random number chosen from the sequence of integer (10, 11, 12, ..., 19, 20).&lt;br /&gt;
&lt;br /&gt;
 (Interval from: 10 to: 20) atRandom .       &amp;quot;=&amp;gt; 11 &amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Get a random float between &#039;&#039;&#039;[0,1[&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 Random next.                                &amp;quot;=&amp;gt; 0.3395170491838441 &amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Choose a random element from a list&lt;br /&gt;
&lt;br /&gt;
 #(123 &#039;a&#039; &#039;hello&#039; 51) atRandom .         &amp;quot;=&amp;gt; &#039;hello&#039; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Shuffle a list of elements&lt;br /&gt;
&lt;br /&gt;
 #(123 &#039;a&#039; &#039;hello&#039; 51) shuffled .         &amp;quot;=&amp;gt; #(&#039;hello&#039; &#039;a&#039; 51 123) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Let&#039;s get a bit more sophisticated ===&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Deal_with_XML_files&amp;diff=177</id>
		<title>Deal with XML files</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Deal_with_XML_files&amp;diff=177"/>
		<updated>2025-05-12T20:39:19Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: importe material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&#039;&#039;&#039;TODO&#039;&#039;&#039;. Complete the task and upload an example data file with (prices made up).&lt;br /&gt;
&lt;br /&gt;
Many files today are encoded as XML. Some of them have a quite complex data structure and are hard to read for human eyes. But good news! In &#039;&#039;Cuis&#039;&#039; we have a package to deal with XML and &#039;&#039;Smalltalk&#039;&#039; makes exploring XML a lot more enjoyable than in any other programming language.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem&#039;&#039;&#039;. I have a company price list in several &#039;&#039;LibreOffice&#039;&#039; &#039;&#039;&#039;.odt&#039;&#039;&#039; files. I want to update all those prices adding 1.5%.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution&#039;&#039;&#039;. Say you have a file &#039;&#039;priceList1.odt&#039;&#039; then:&lt;br /&gt;
&lt;br /&gt;
* Make a directory &#039;&#039;printList1Dir&#039;&#039; and copy &#039;&#039;princeList1.odt&#039;&#039; in there.&lt;br /&gt;
&lt;br /&gt;
 $&amp;gt; mkdir princeList1Dir&lt;br /&gt;
 $&amp;gt; cp priceList1.odt  priceList1Dir&lt;br /&gt;
 $&amp;gt; cd priceListdir&lt;br /&gt;
&lt;br /&gt;
* Unzip the file (yes, .odt file as just zipped document, isn&#039;t it great?)&lt;br /&gt;
* Remove the zipped file from the new directory (you will see why later on)&lt;br /&gt;
&lt;br /&gt;
 $&amp;gt; unzip princeList1.odt &lt;br /&gt;
 $&amp;gt; rm princeList1.odt&lt;br /&gt;
&lt;br /&gt;
* Observe there is a file called &#039;&#039;&#039;content.xml&#039;&#039;&#039;, tadaaaa, we are going to work on that !&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TO FINISH&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Just started to collect the necessary commands for reading&lt;br /&gt;
* I miss commands for writing&lt;br /&gt;
* I need to work with true files to make this of any use&lt;br /&gt;
&lt;br /&gt;
 Feature require: &#039;YAXO&#039;. &lt;br /&gt;
 &lt;br /&gt;
 f1 _ &#039;/home/p/download/test1-odt/content.xml&#039; asFileEntry readStream . &lt;br /&gt;
 xdoc _ XMLDOMParser parseDocumentFrom: f1. &lt;br /&gt;
 f1 close. &lt;br /&gt;
 xdoc class. &amp;quot; XMLDocument &amp;quot;&lt;br /&gt;
 xdoc elements.   &amp;quot; show all elements &amp;quot;&lt;br /&gt;
 xdoc explore. &lt;br /&gt;
 &lt;br /&gt;
 t1 _ xdoc firstTagNamed: #&#039;table:table&#039;. &lt;br /&gt;
 t1 class. &amp;quot; XMLElement &amp;quot;&lt;br /&gt;
 t1 elements . &lt;br /&gt;
 &lt;br /&gt;
 t1 firstTagNamed: #&#039;text:p&#039;. &lt;br /&gt;
 &amp;quot; &amp;lt;text:p text:style-name=&amp;quot;P2&amp;quot;&amp;gt;1A&amp;lt;/text:p&amp;gt; &amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 t1 tagsNamed: #&#039;text:p&#039; do: [ :el | &lt;br /&gt;
 	Transcript log: (&#039;	{1}&#039; format: {el. }).  &lt;br /&gt;
 	Transcript log: (&#039;- contents 	{1}&#039; format: {el contents. }).  &lt;br /&gt;
 	].&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Convert_a_file_to/from_Base64&amp;diff=176</id>
		<title>Convert a file to/from Base64</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Convert_a_file_to/from_Base64&amp;diff=176"/>
		<updated>2025-05-12T20:38:49Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: importing material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* One of the use of base64 file is to convert binary files into text files and, for example, send them via mail.&lt;br /&gt;
* This is an example of what you get if you watch inside a base64 file&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;UEsDBAoAAAAAAEZcOFMAAAAAAAAAAAAAAAAIABwAdGVzdERpci9VVAkAA5ObTWHPn01hdXgLAAEE&lt;br /&gt;
 6AMAAAToAwAAUEsDBAoAAAAAAERcOFMgMDo2BgAAAAYAAAARABwAdGVzdERpci90ZXN0MS50eHRV&lt;br /&gt;
 VAkAA4+bTWGIm01hdXgLAAEE6AMAAAToAwAAaGVsbG8KUEsDBAoAAAAAAElcOFOQoBAeBwAAAAcA&lt;br /&gt;
 AAARABwAdGVzdERpci90ZXN0Mi50eHRVVAkAA5qbTWGTm01hdXgLAAEE6AMAAAToAwAAaGVsbG8y&lt;br /&gt;
 ClBLAQIeAwoAAAAAAEZcOFMAAAAAAAAAAAAAAAAIABgAAAAAAAAAEADtQQAAAAB0ZXN0RGlyL1VU&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Encode a file into new file Base64 ===&lt;br /&gt;
&lt;br /&gt;
* The Linux/MacOSX way of doing such conversion is:&lt;br /&gt;
&lt;br /&gt;
 $&amp;gt; base64 foo.dat &amp;gt; foo.dat.b64&lt;br /&gt;
&lt;br /&gt;
* In Cuis you do:&lt;br /&gt;
&lt;br /&gt;
 inFile _ &#039;/home/p/foo.dat&#039;.&lt;br /&gt;
 file64 _ &#039;/home/p/foo.dat.b64&#039;. &lt;br /&gt;
 rs1 _ inFile asFileEntry readStream useBytes.&lt;br /&gt;
 rs2 _ file64 asFileEntry forceWriteStream .&lt;br /&gt;
 Base64MimeConverter mimeEncode: rs1 to: rs2.  &lt;br /&gt;
 rs1 close. rs2 close.&lt;br /&gt;
&lt;br /&gt;
=== Decode a Base64 file into a new file ===&lt;br /&gt;
&lt;br /&gt;
* You can do this in Linux/MacOSX with&lt;br /&gt;
&lt;br /&gt;
 $&amp;gt; base64 -d foo.dat.b64 &amp;gt; foo.dat &lt;br /&gt;
&lt;br /&gt;
* In Cuis you do:&lt;br /&gt;
&lt;br /&gt;
 file64 _ &#039;/home/p/foo.dat.b64&#039;. &lt;br /&gt;
 outFile _ &#039;/home/p/foo.dat&#039;.&lt;br /&gt;
 rs1 _ file64 asFileEntry readStream.&lt;br /&gt;
 rs2 _ outFile asFileEntry forceWriteStream useBytes.&lt;br /&gt;
 Base64MimeConverter mimeDecode: rs1 to: rs2.  &lt;br /&gt;
 rs1 close. rs2 close.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Run_a_program_with_CommandShell&amp;diff=175</id>
		<title>Run a program with CommandShell</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Run_a_program_with_CommandShell&amp;diff=175"/>
		<updated>2025-05-12T20:37:00Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: importing material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* &#039;&#039;&#039;SUPER GOTCHA&#039;&#039;&#039;. &#039;&#039;&#039;PipeableOSProcess&#039;&#039;&#039; is extremely handy, but also, extremely dangerous. Remember to &#039;&#039;&#039;close the pipes&#039;&#039;&#039; after using it, as shown in the examples below, or sooner or later your program will crash. Keep checked your open pipes with &amp;lt;code&amp;gt;$&amp;gt; sudo lsof | grep squeak | grep pipe&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;SUPER GOTCHA&#039;&#039;&#039;. I have very bad surprises running PipeableOSProcess in a &#039;&#039;&#039;secondary process&#039;&#039;&#039;. If you kill the process and a PipeableOSProcess is running you may loose control of the image. If found OSProcess to be more resilient so I recommend you use that, even if it is more wordy to control.&lt;br /&gt;
&lt;br /&gt;
 Feature require: &#039;CommandShell&#039;.&lt;br /&gt;
&#039;&#039;&#039;Problem&#039;&#039;&#039;. I want to know how much free space I still have in my disks. This is half done&lt;br /&gt;
&lt;br /&gt;
if I know that in Linux I can get that info with &amp;lt;code&amp;gt;df -h&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Solution-1&#039;&#039;&#039;. This is the easiest solution.&lt;br /&gt;
** +] Quite short to type in&lt;br /&gt;
** +/-] It is &#039;&#039;&#039;synchronous&#039;&#039;&#039; with your code. This can be good and bad. When this commands end, the commands after it get executed. For the bad part read on.&lt;br /&gt;
** -] It your program to run takes a long time your Cuis is going to &#039;&#039;&#039;lock&#039;&#039;&#039; untill it has finished.&lt;br /&gt;
** NOTE. This example uses a new interface functions introduced in 2021.&lt;br /&gt;
&lt;br /&gt;
 p _ PipeableOSProcess waitForCommand: &#039;uname -a &#039; .&lt;br /&gt;
 p exitCode .         &amp;quot;=&amp;gt;  0 &amp;quot;&lt;br /&gt;
 p outputAndError .   &amp;quot;=&amp;gt; #(&#039;Linux deb4 5.10.0-9-amd64 #1 SMP Debian 5.10.70-1 (2021-09-30) x86_64 GNU/Linux&lt;br /&gt;
 &#039; &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;) &amp;quot;&lt;br /&gt;
 p closePipes.&lt;br /&gt;
 p close. &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Solution-2&#039;&#039;&#039;. As before but async&lt;br /&gt;
** +] This way does &#039;&#039;&#039;not lock&#039;&#039;&#039; you system&lt;br /&gt;
** -] You must check when execution ends yourself&lt;br /&gt;
&lt;br /&gt;
 p _ PipeableOSProcess command: &#039;df -h&#039;.&lt;br /&gt;
 out _ p output . &amp;quot; store the output somewhere, you can do it only once. &amp;quot;&lt;br /&gt;
 p processProxy pid. &amp;quot;=&amp;gt; 112011 &amp;quot;&lt;br /&gt;
 p processProxy exitCode. &amp;quot;=&amp;gt; 0 &amp;quot;&lt;br /&gt;
 p closePipes.&lt;br /&gt;
 p close.&lt;br /&gt;
 out. &amp;quot;Ctrl+p, see the output&amp;quot;&lt;br /&gt;
 &amp;quot;=&amp;gt;&lt;br /&gt;
 &#039;Filesystem Size Used Avail Use% Mounted on&lt;br /&gt;
 udev 5.1G 0 5.1G 0% /dev&lt;br /&gt;
 tmpfs 1.1G 18M 1.1G 2% /run&lt;br /&gt;
 /dev/sda2 93G 80G 8.1G 91% /&lt;br /&gt;
 tmpfs 5.2G 745M 4.4G 15% /dev/shm&lt;br /&gt;
 tmpfs 5.0M 4.0K 5.0M 1% /run/lock&lt;br /&gt;
 tmpfs 5.2G 0 5.2G 0% /sys/fs/cgroup&lt;br /&gt;
 /dev/sda1 511M 3.3M 508M 1% /boot/efi&lt;br /&gt;
 //nas.borghi.lan/sambaDisk/DiscoS/ 5.5T 3.8T 1.7T 70% /mnt/discoR&lt;br /&gt;
 //backup.borghi.lan/backupDisk/ 22T 7.1T 15T 34% /mnt/discoBackup&lt;br /&gt;
 tmpfs 1.1G 28K 1.1G 1% /run/user/1000&lt;br /&gt;
 vmhgfs-fuse 1.9T 588G 1.3T 32% /mnt/macos&lt;br /&gt;
 vmhgfs-fuse 1.9T 588G 1.3T 32% /mnt/dropbox&lt;br /&gt;
 &#039; &amp;quot;&lt;br /&gt;
&#039;&#039;&#039;Exercise-1&#039;&#039;&#039;. Get your Linux kernel version. Google around to discover the appropriate shell command.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Exercise-2&#039;&#039;&#039;. Inspect the content of variable &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;, you will see other interesting stuff there.&lt;br /&gt;
----NM 06-Sep-2021. Cuis version...&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Run_a_program_with_OSProcess&amp;diff=174</id>
		<title>Run a program with OSProcess</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Run_a_program_with_OSProcess&amp;diff=174"/>
		<updated>2025-05-12T20:36:23Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: importing material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
All the sinppets in this page require you to run&lt;br /&gt;
 Feature require: &#039;OSProcess&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Simple. Run a command and wait, only for the output ===&lt;br /&gt;
&lt;br /&gt;
* sync&lt;br /&gt;
* Main issue. &#039;&#039;&#039;no exit code&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;. ---- NO - move it out from here, requires CommandShell &lt;br /&gt;
 out _ OSProcess outputOf: &#039;pwd&#039;. &lt;br /&gt;
 out class.                       &amp;quot;=&amp;gt; String &amp;quot;&lt;br /&gt;
 out withBlanksTrimmed.           &amp;quot;=&amp;gt; &#039;/home/p/prog/cuis-project&#039; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Simple. Run a command and wait, only to get the exit code ===&lt;br /&gt;
&lt;br /&gt;
* sync&lt;br /&gt;
* Main issue. &#039;&#039;&#039;not frequently useful&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
 out _ OSProcess waitForCommand: &#039; sh -c &amp;quot;exit 33&amp;quot; &#039;. &lt;br /&gt;
 out class.                        &amp;quot;=&amp;gt; ExternalUnixOSProcess &amp;quot;&lt;br /&gt;
 out exitCode .                    &amp;quot;=&amp;gt; 33 .   NOTE. exitCode was added on 16-oct-2021.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Run a command to get the output, no input, sync ===&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;. Get the current date using Linux &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt; command.&lt;br /&gt;
 d _ Delay forMilliseconds: 50.&lt;br /&gt;
 in _ nil.&lt;br /&gt;
 out _ &#039;/tmp/test.out&#039; asFileEntry forceWriteStream .&lt;br /&gt;
 err _  &#039;/tmp/test.err&#039; asFileEntry forceWriteStream .&lt;br /&gt;
 proc _ UnixProcess forkJob: &#039;/usr/bin/date&#039; &lt;br /&gt;
                               arguments: nil environment: nil &lt;br /&gt;
                    descriptors: {in. out. err.}.&lt;br /&gt;
 [proc runState == #complete] whileFalse: [d wait].                &lt;br /&gt;
 proc pid.&lt;br /&gt;
 oExit _ proc     exitCode .         &lt;br /&gt;
 oOut _ out contents. &lt;br /&gt;
 oErr _ err contents.             &lt;br /&gt;
 {in. out. err} do: [ :f | f ifNotNil: [ f close ] ].&lt;br /&gt;
 &#039;exitCode: {1}, output: {2}&#039; format: {oExit. oOut withBlanksTrimmed .}&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;=&amp;gt; &#039;exitCode: 0, output: Tue 14 Sep 16:23:10 CEST 2021&#039; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Run a command through the shell to get the output, no input, sync ===&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;. Get the first 3 lines of output of &amp;lt;code&amp;gt;ls&amp;lt;/code&amp;gt; in the current directory. That is run in &amp;lt;code&amp;gt;bash&amp;lt;/code&amp;gt; the&lt;br /&gt;
&lt;br /&gt;
command &amp;lt;code&amp;gt;ls -l | head -n 3&amp;lt;/code&amp;gt;.&lt;br /&gt;
 d _ Delay forMilliseconds: 50.&lt;br /&gt;
 in _ nil.&lt;br /&gt;
 out _ &#039;/tmp/test.out&#039; asFileEntry forceWriteStream .&lt;br /&gt;
 err _  &#039;/tmp/test.err&#039; asFileEntry forceWriteStream .&lt;br /&gt;
 proc _ UnixProcess forkJob: &#039;/usr/bin/bash&#039; &lt;br /&gt;
                               arguments: {&#039;-c&#039;. &#039;ls -l | head -n 3&#039;} &lt;br /&gt;
                           environment: nil &lt;br /&gt;
                    descriptors: {in. out. err.}.&lt;br /&gt;
 [proc runState == #complete] whileFalse: [d wait].                &lt;br /&gt;
 proc pid.&lt;br /&gt;
 oExit _ proc     exitCode .         &lt;br /&gt;
 oOut _ out contents. &lt;br /&gt;
 oErr _ err contents.             &lt;br /&gt;
 {in. out. err} do: [ :f | f ifNotNil: [ f close ] ].&lt;br /&gt;
 &#039;exitCode: %d\noutput: %s&#039; printf: {oExit. oOut withBlanksTrimmed } .  &lt;br /&gt;
 &amp;quot;=&amp;gt; &#039;exitCode: 0&lt;br /&gt;
 output: total 3808&lt;br /&gt;
 drwxrwx---  3 p p    4096 Aug 18 12:54 AMQP&lt;br /&gt;
 drwxrwx---  3 p p    4096 Aug 18 12:54 Cairo&#039; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== As before, but pass input through &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;. We are going to count the number of charaters of what is sent through &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt; via &amp;lt;code&amp;gt;wc -c&amp;lt;/code&amp;gt;.&lt;br /&gt;
 d _ Delay forMilliseconds: 50.&lt;br /&gt;
 &#039;/tmp/test.in&#039; asFileEntry fileContents: &#039;Hello World!&#039;.&lt;br /&gt;
 in _ &#039;/tmp/test.in&#039; asFileEntry readStream .&lt;br /&gt;
 out _ &#039;/tmp/test.out&#039; asFileEntry forceWriteStream .&lt;br /&gt;
 err _  &#039;/tmp/test.err&#039; asFileEntry forceWriteStream .&lt;br /&gt;
 proc _ UnixProcess forkJob: &#039;/usr/bin/bash&#039; &lt;br /&gt;
                               arguments: {&#039;-c&#039;. &#039;wc -c&#039;} &lt;br /&gt;
                           environment: nil &lt;br /&gt;
                    descriptors: {in. out. err.}.&lt;br /&gt;
 [proc runState == #complete] whileFalse: [d wait].                &lt;br /&gt;
 proc pid.&lt;br /&gt;
 oExit _ proc     exitCode .         &lt;br /&gt;
 oOut _ out contents. &lt;br /&gt;
 oErr _ err contents.             &lt;br /&gt;
 {in. out. err} do: [ :f | f ifNotNil: [ f close ] ].&lt;br /&gt;
 &#039;exitCode: %d\noutput: %s&#039; printf: {oExit. oOut withBlanksTrimmed } .  &lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;=&amp;gt; &#039;exitCode: 0&lt;br /&gt;
 output: 12&#039; &amp;quot;&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_basics_of_interacting_with_Unix&amp;diff=173</id>
		<title>The basics of interacting with Unix</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_basics_of_interacting_with_Unix&amp;diff=173"/>
		<updated>2025-05-12T20:35:35Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: import  + hilight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* You absolutely need the package &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt;&lt;br /&gt;
* To get a reference to the process which is running your Cuis image do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
UnixProcess thisOSProcess . &amp;quot;=&amp;gt; a UnixProcess with pid 14751 &amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
* Then watch these interactions it should be all clear to you&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;. get the current working directory of the shell when it run Cuis &amp;quot; &lt;br /&gt;
UnixProcess thisOSProcess getCwd. &amp;quot;=&amp;gt; &#039;/home/p/prog/cuis-project&#039; &amp;quot; &lt;br /&gt;
&lt;br /&gt;
&amp;quot;. get the pid of the Cuis process and his father pid &amp;quot; &lt;br /&gt;
UnixProcess thisOSProcess pid.    &amp;quot;=&amp;gt; 14751 &amp;quot; &lt;br /&gt;
UnixProcess thisOSProcess ppid.   &amp;quot;=&amp;gt; 14750 &amp;quot; &lt;br /&gt;
&lt;br /&gt;
&amp;quot; ------------ &lt;br /&gt;
from here on there are class method shortcuts that let you type less but the idea is alwys the same you are asking &#039;UnixProcess thisOSProcess&#039; to give you info. &lt;br /&gt;
------------ &amp;quot; &lt;br /&gt;
&lt;br /&gt;
&amp;quot;. get the environment variables of the shell who run Cuis &amp;quot; &lt;br /&gt;
UnixProcess env.          &amp;quot;=&amp;gt; a Dictionary(#CLUTTER_IM_MODULE-&amp;gt;&#039;ibus&#039; #COLORFGBG-&amp;gt;&#039;0;15&#039; #COLORTERM-&amp;gt;&#039;truecolor&#039; #DBUS_SESSION_BUS_ADDRESS-&amp;gt;&#039;unix:path=/run/user/1000/bus&#039; .... #DESKTOP_SESSION-&amp;gt;&#039;plasma&#039; #DISPLAY-&amp;gt;&#039;:0.0&#039; ) &amp;quot; &lt;br /&gt;
&lt;br /&gt;
&amp;quot;. the program name corresponding to Cuis, which is the name of the OpenSmalltalkVM&amp;quot; &lt;br /&gt;
UnixProcess programName . &amp;quot;=&amp;gt; &#039;./sqcogspur64linuxht/lib/squeak/5.0-202003021730/squeak&#039; &amp;quot; &lt;br /&gt;
&lt;br /&gt;
&amp;quot; . the VM arguments, where there is Cuis image file and some extra parameters &amp;quot; &lt;br /&gt;
UnixProcess arguments .   &amp;quot;=&amp;gt; #(&#039;Cuis-Smalltalk-Dev/Cuis5.0-4975.image&#039; &#039;-d&#039; &#039;Preferences veryBigFonts.&#039;) &amp;quot; &lt;br /&gt;
&lt;br /&gt;
&amp;quot;. get stdin, stdout, stderr &amp;quot; &lt;br /&gt;
&amp;quot;. observe that by default, as of now, stdout and stderr are both copied to Transcript but only stderr will go printed into the shell which runs Cuis. &amp;quot; &lt;br /&gt;
UnixProcess stdOut nextPutAll: &#039;Hello world ! &#039;. &lt;br /&gt;
UnixProcess stdErr nextPutAll: &#039;Hello world ! &#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_basics_of_interacting_with_Unix&amp;diff=172</id>
		<title>The basics of interacting with Unix</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_basics_of_interacting_with_Unix&amp;diff=172"/>
		<updated>2025-05-12T20:30:12Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: imported material&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* You absolutely need the package &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt;&lt;br /&gt;
* To get a reference to the process which is running your Cuis image do:&lt;br /&gt;
&lt;br /&gt;
 UnixProcess thisOSProcess .     &amp;quot;=&amp;gt;  a UnixProcess with pid 14751 &amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Then watch these interactions it should be all clear to you&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;. get the current working directory of the shell when it run Cuis &amp;quot;&lt;br /&gt;
 UnixProcess thisOSProcess getCwd.     &amp;quot;=&amp;gt; &#039;/home/p/prog/cuis-project&#039; &amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. get the pid of the Cuis process and his father pid &amp;quot;&lt;br /&gt;
 UnixProcess thisOSProcess pid.        &amp;quot;=&amp;gt; 14751 &amp;quot;&lt;br /&gt;
 UnixProcess thisOSProcess ppid.       &amp;quot;=&amp;gt; 14750 &amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot; ------------&lt;br /&gt;
 from here on there are class method shortcuts that let you type less &lt;br /&gt;
 but the idea is alwys the same you are asking &#039;UnixProcess thisOSProcess&#039; to &lt;br /&gt;
 give you info. &lt;br /&gt;
  ------------ &amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. get the environment variables of the shell who run Cuis &amp;quot;&lt;br /&gt;
 UnixProcess env.  &amp;quot; =&amp;gt; a Dictionary(#CLUTTER_IM_MODULE-&amp;gt;&#039;ibus&#039; #COLORFGBG-&amp;gt;&#039;0;15&#039; &lt;br /&gt;
 #COLORTERM-&amp;gt;&#039;truecolor&#039; #DBUS_SESSION_BUS_ADDRESS-&amp;gt;&#039;unix:path=/run/user/1000/bus&#039; .... &lt;br /&gt;
 #DESKTOP_SESSION-&amp;gt;&#039;plasma&#039; #DISPLAY-&amp;gt;&#039;:0.0&#039; ) &amp;quot; &lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. the program name corresponding to Cuis, which is the name of the OpenSmalltalkVM&amp;quot;&lt;br /&gt;
 UnixProcess programName . &lt;br /&gt;
 &amp;quot;=&amp;gt; &#039;./sqcogspur64linuxht/lib/squeak/5.0-202003021730/squeak&#039; &amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot; . the VM arguments, where there is Cuis image file and some extra parameters &amp;quot;&lt;br /&gt;
 UnixProcess arguments . &lt;br /&gt;
 &amp;quot;=&amp;gt;  #(&#039;Cuis-Smalltalk-Dev/Cuis5.0-4975.image&#039; &#039;-d&#039; &#039;Preferences veryBigFonts.&#039;) &amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. get stdin, stdout, stderr &amp;quot;&lt;br /&gt;
 &amp;quot;. observe that by default, as of now, stdout and stdrr are both copied to Transcript &lt;br /&gt;
    but only stderr will go printed into the shell which runs Cuis. &amp;quot;&lt;br /&gt;
 UnixProcess stdOut nextPutAll: &#039;Hello world ! &#039;. &lt;br /&gt;
 UnixProcess stdErr nextPutAll: &#039;Hello world ! &#039;.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Traps_and_pitfalls_specific_to_running_external_programs&amp;diff=171</id>
		<title>Traps and pitfalls specific to running external programs</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Traps_and_pitfalls_specific_to_running_external_programs&amp;diff=171"/>
		<updated>2025-05-12T20:29:25Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: Created page with &amp;quot;* I run most of my external commands in &amp;#039;&amp;#039;&amp;#039;Linux&amp;#039;&amp;#039;&amp;#039;, sometimes in &amp;#039;&amp;#039;&amp;#039;BSD&amp;#039;&amp;#039;&amp;#039;. These procedures may work in the Mac, since it is, in some way, a descendant of BSD, but they will not work in Windows. * In different Unix-like systems the same command can be in different positions in the filesystem. For example in Linux Debian &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt; is in &amp;lt;code&amp;gt;/usr/bin/date&amp;lt;/code&amp;gt;. In the Mac it is in &amp;lt;code&amp;gt;/bin/date/&amp;lt;/code&amp;gt;. * If you run your external command &amp;#039;&amp;#039;&amp;#039;synchronously&amp;#039;&amp;#039;&amp;#039;...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* I run most of my external commands in &#039;&#039;&#039;Linux&#039;&#039;&#039;, sometimes in &#039;&#039;&#039;BSD&#039;&#039;&#039;. These procedures may work in the Mac, since it is, in some way, a descendant of BSD, but they will not work in Windows.&lt;br /&gt;
* In different Unix-like systems the same command can be in different positions in the filesystem. For example in Linux Debian &amp;lt;code&amp;gt;date&amp;lt;/code&amp;gt; is in &amp;lt;code&amp;gt;/usr/bin/date&amp;lt;/code&amp;gt;. In the Mac it is in &amp;lt;code&amp;gt;/bin/date/&amp;lt;/code&amp;gt;.&lt;br /&gt;
* If you run your external command &#039;&#039;&#039;synchronously&#039;&#039;&#039; your code will be easier to read but &#039;&#039;&#039;Cuis UI will&#039;&#039;&#039; &#039;&#039;&#039;hang&#039;&#039;&#039; until the command is done. This might be very unpleasant so if you want to go that way make sure your external command can complete its task quickly, independently of the input. &lt;br /&gt;
* If you run commands through the &amp;lt;code&amp;gt;bash&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sh&amp;lt;/code&amp;gt; and pass pathnames to it, they should be quoted or even a white space can bring you unexpected results.&lt;br /&gt;
* In Smalltalk we write strings with &amp;lt;code&amp;gt;&#039;...&#039;&amp;lt;/code&amp;gt; and in the &#039;&#039;Bash&#039;&#039; shell the same character is used for quoting without interpolation, you will soon discover escaping your command can be not trivial. This fact is worsened by the escape character in Smalltalk being again &amp;lt;code&amp;gt;$&#039;&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Given the previous points I recommend you never to run &amp;lt;code&amp;gt;rm&amp;lt;/code&amp;gt; or any destructive command. Mistakes and the unexpected do happen.&lt;br /&gt;
* If part of your shell command is taken from user input (e.g. a &#039;&#039;&#039;web page form&#039;&#039;&#039;) keep in mind that &#039;&#039;&#039;bad guys exist&#039;&#039;&#039; and they try to inject executable code in the forms. Imagine this scenario, you asked the user to give you a mail address and you would like to give that string to the &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; command. But the user instead wrote &amp;lt;code&amp;gt;$(cd ; rm -rf *)&amp;lt;/code&amp;gt;, say farewell to your home directory.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=170</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=170"/>
		<updated>2025-05-12T20:25:21Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: /* Run external programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check! Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular. Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level. &lt;br /&gt;
&lt;br /&gt;
* [[Traps and pitfalls specific to running external programs]]&lt;br /&gt;
* [[The basics of interacting with Unix]] . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* [[Run a program with OSProcess]]&lt;br /&gt;
* [[Run a program with CommandShell]]&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=169</id>
		<title>The Cuis Cookbook</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=The_Cuis_Cookbook&amp;diff=169"/>
		<updated>2025-05-12T20:22:43Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: /* Run external programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
A programming language cookbook is something like &#039;&#039;StackOverflow&#039;&#039;, without the digging part and the try&amp;amp;pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the &#039;&#039;&#039;The Cuis Book&#039;&#039;&#039; and &#039;&#039;&#039;Learning-Cuis&#039;&#039;&#039; more about this on the [[CuisCoookBook-References|References]]. This is intended to be a &amp;lt;u&amp;gt;resource for programmers&amp;lt;/u&amp;gt;, in the sense that it answers questions that will naturally come up to programmers while exploring Smalltalk. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Reliability&#039;&#039;&#039;. I am writing these notes while learning Cuis. Some of what I write may not be the best way to solve the problem, it may not even be correct. Be patient, double check! Since I use these recipes myself I am going to improve them in time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Sorting principles&#039;&#039;&#039;. Topic order is intended to go from easy to difficult. From frequently necessary to rarely used. From needed at the beginning of the programming experience to needed by black belts. These three forces, as the 3 laws of robotics, regulate what chapter goes toward the top of the document. They hold also for sub-chapters and articles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Contributions&#039;&#039;&#039;. I am trying to figure out ways to make contributions possible and fruitful, see [[contributions motivated guidelines]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Copyright&#039;&#039;&#039;. You have the right to read, print for your own use and contribute to the document. You can make external links to this document. You can not copy the document and make it available somewhere else on the Internet. You can&#039;t claim ownership. You can&#039;t bring the document to an editor and publish it. I, as the author of more than 99% of the words here displayed retain all rights as well as the right to change these rules.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]. What you should expect from this book and the reason why I am writing it. STARTED.&lt;br /&gt;
* [[Why Smalltalk?]]. For what reason should you learn another programming language which is also not so popular. Read on, there are very good reasons. STARTED.&lt;br /&gt;
&lt;br /&gt;
== Installation and start up ==&lt;br /&gt;
&lt;br /&gt;
* Install and run Cuis in Windows&lt;br /&gt;
* Install and run Cuis in the Mac&lt;br /&gt;
* [[Install and run Cuis in Linux]]&lt;br /&gt;
* [[Run Cuis in the Web Browser. (SqueakJS)]]&lt;br /&gt;
* [[Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)]]&lt;br /&gt;
* Run Cuis in a remote server. (Linux)&lt;br /&gt;
* Run Cuis on the metal: without Operating System&lt;br /&gt;
* How to keep Cuis updated&lt;br /&gt;
* [[How to load the most recent changes Juan made to Cuis-Smalltalk-Dev]]&lt;br /&gt;
&lt;br /&gt;
== Cuis in its environment ==&lt;br /&gt;
&lt;br /&gt;
* What is a .image file?&lt;br /&gt;
* What is a .changes file?&lt;br /&gt;
* [[What is a .user.changes file?]]&lt;br /&gt;
* [[What is a .log file?]]&lt;br /&gt;
* [[What is release of the image and VM I am running?]]&lt;br /&gt;
&lt;br /&gt;
== Things unique to Cuis and/or Smalltalk ==&lt;br /&gt;
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.&lt;br /&gt;
&lt;br /&gt;
* [[How can I make X? Learn to fish in Smalltalk|How can I make X ? Learn to fish in Smalltalk]]&lt;br /&gt;
* [[First things first: 1+1 and &amp;quot;Hello World&amp;quot;]]&lt;br /&gt;
* How can I type in a basic object ? [[Know the literals]] !&lt;br /&gt;
* [[You want something to get done? Ask an object to do it!]]&lt;br /&gt;
* [[How do I define a function?]]&lt;br /&gt;
* [[How do I create my own Class with some methods inside it?]]&lt;br /&gt;
* [[What is a package? How do I create, load and unload one?]]&lt;br /&gt;
* [[My project needs to add a method to somebody else Class, how do I do it?|My project needs to add a method to somebody else Class, how do I do it ?]]&lt;br /&gt;
* [[How to use Class variables]]. STARTED&lt;br /&gt;
* [[Learn how to use the Transcript]] . This is really important, better you take a peek.&lt;br /&gt;
* [[Tips &amp;amp; tricks]] . Those little keyboard/mouse shortcuts or little code snippets that may improve your programmer life.&lt;br /&gt;
* [[Traps and pitfalls for polyglot developers]] . If you know more programming languages this page is for you.&lt;br /&gt;
* [[&amp;quot;It didn&#039;t understand&amp;quot; can&#039;t happen]]. The end of most of your programmer anxiety. You can understand it all.&lt;br /&gt;
&lt;br /&gt;
== About a general Class and Object ==&lt;br /&gt;
&lt;br /&gt;
* [[Create automatically all accessors for a  Class instance variables]]&lt;br /&gt;
* [[Change the way an Object is printed]]&lt;br /&gt;
* [[Find all objects referencing anObject]]&lt;br /&gt;
* [[Make your own object initialization]]. All you need to know about &amp;lt;code&amp;gt;new&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;basicNew&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;initialize&amp;lt;/code&amp;gt; etc. STARTED&lt;br /&gt;
* [[How to dump and restore an Object]] -- STARTED&lt;br /&gt;
* [[How to manage a Class who should have only one instance]]&lt;br /&gt;
* [[Discover in what package a Class lives]]&lt;br /&gt;
* [[Follow step bye how a method call gets resolved. Example-1]]&lt;br /&gt;
&lt;br /&gt;
== Data Structures ==&lt;br /&gt;
&lt;br /&gt;
* Fundamentals: numbers, strings and symbols&lt;br /&gt;
&lt;br /&gt;
=== Strings (before default UTF) ===&lt;br /&gt;
&lt;br /&gt;
* [[Cuis-What Strings are made of and how|What Strings are made of and how]]&lt;br /&gt;
* [[Cuis-String escape|String escape]]&lt;br /&gt;
* [[Cuis-Automatically escape a complex string|Automatically escape a complex string]]&lt;br /&gt;
* [[String formatting with format:]]&lt;br /&gt;
* [[String formatting with printf:]]&lt;br /&gt;
* [[A thousand ways to say new line]] . Newline, to text find it fast&lt;br /&gt;
* [[Trim white chars]]&lt;br /&gt;
* [[String joining]]&lt;br /&gt;
* [[String splitting]]&lt;br /&gt;
* [[String search]]&lt;br /&gt;
* [[String replace]]&lt;br /&gt;
* [[Show me the string, but max N. characters]]&lt;br /&gt;
* [[Dump and restore JSON data strings]]&lt;br /&gt;
* [[How to hash a string]]&lt;br /&gt;
* [[Convert to Base64]]&lt;br /&gt;
* [[Convert strings from/to Utf8]]&lt;br /&gt;
* Remove accents with, &amp;lt;code&amp;gt;&#039;sarà&#039; asUnaccented .    =&amp;gt; &amp;quot; &#039;sara&#039; &amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Convert UTF16 to Latin1]]. This is quite useful, in Windows-10 UTF16 is called Unicode.&lt;br /&gt;
* Jump to the next level of power, [[use Regex]] . Last in the list for complexity, but should be first for power, don&#039;t overlook this.&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
&lt;br /&gt;
* [[The things you may call a List]] -- STARTED&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Dictionary a.k.a. Hash Table]]&lt;br /&gt;
&lt;br /&gt;
== Streams ==&lt;br /&gt;
&lt;br /&gt;
* [[Make a stream from a string, for reading]].&lt;br /&gt;
* [[Write a long String with a Stream]]&lt;br /&gt;
* [[Write to stdout in any system]]. Not only Unix like. Useful for shell programs.&lt;br /&gt;
&lt;br /&gt;
== Date and time ==&lt;br /&gt;
&lt;br /&gt;
* [[Get the current date and time]]&lt;br /&gt;
* [[Format date and time as you like most]]&lt;br /&gt;
* [[Date and time algebra]]&lt;br /&gt;
* [[Get the current time with the highest precision]]&lt;br /&gt;
* [[Get date and time as Unix epoch]]&lt;br /&gt;
* [[Get date and time in a different country]]&lt;br /&gt;
* [[Measure how much time it takes to run a code block]]&lt;br /&gt;
&lt;br /&gt;
== Files and directories ==&lt;br /&gt;
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here&lt;br /&gt;
&lt;br /&gt;
part of a &#039;&#039;Juan&#039;&#039; mail to mailing list: &amp;quot;... The essential idea you need to be aware of when learning about all this is that Smalltalk uses files, but it is not file-based. What this means is that all the tools in the Smalltalk image (with the only exception of FileList and FileContentsBrowser) are NOT showing files, but &#039;&#039;&#039;live objects&#039;&#039;&#039;. The way them relate to files is usually not really important ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* [[How to Read or Write a text file]] . without Streams, only Strings.&lt;br /&gt;
* [[How to Read or Write a text file with a Stream]]&lt;br /&gt;
* [[Read a file line by line]] . Or any general delimiter.&lt;br /&gt;
* [[Find the current directory, list it and move in the directory tree]]&lt;br /&gt;
* [[Filename extensions]]: .txt, .csv, .json ...&lt;br /&gt;
* [[Check things on a pathname. Is there anything? Is it a file? Is it writable?]] ...&lt;br /&gt;
* [[Delete files and directories]]&lt;br /&gt;
* [[Read/Write a binary file]]&lt;br /&gt;
* [[Create a new non-existing file name]]&lt;br /&gt;
* [[Using file locks]] -- TODO&lt;br /&gt;
* [[Get the list of open files]]&lt;br /&gt;
* [[Get the directory where a Class (its Package) is stored]]&lt;br /&gt;
* [[Where is the image file? Where is the VM?]]&lt;br /&gt;
&lt;br /&gt;
== Error Handling and the Debugger ==&lt;br /&gt;
&lt;br /&gt;
* [[Call the debugger from a code location]]&lt;br /&gt;
* [[Quick exception handling]], equivalent of Python &amp;lt;code&amp;gt;try ... except&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Assertions]]&lt;br /&gt;
* [[Errors, raise and catch signals]]&lt;br /&gt;
* Case-study-1. &#039;&#039;&#039;TODO&#039;&#039;&#039;. When the debugger pops up send me an email&lt;br /&gt;
* b&lt;br /&gt;
&lt;br /&gt;
== Processes ==&lt;br /&gt;
&lt;br /&gt;
* [[Smalltalk processes are not Unix processes]]&lt;br /&gt;
* [[See the list of running processes]]&lt;br /&gt;
* [[Processes 101]]. Shows how to create a process, name it, start it, stop it and destroy it.&lt;br /&gt;
* [[Run a new process]]&lt;br /&gt;
* [[Kill a process]]&lt;br /&gt;
&lt;br /&gt;
== Uncategorized useful features ==&lt;br /&gt;
&lt;br /&gt;
* [[Run a method every 2 hours or every day at 15:00]], equivalent to Unix cron&lt;br /&gt;
* [[Zip and unZip files and directories]] --- TODO, miss zipping&lt;br /&gt;
* [[Convert a file to/from Base64]]&lt;br /&gt;
* [[Deal with XML files]] -- STARTED&lt;br /&gt;
* [[About Random]]&lt;br /&gt;
* [[How to invoke the garbage collector]]&lt;br /&gt;
* [[Adapt newline characters to Cuis standard]]&lt;br /&gt;
* [[Where to get information about the hardware]] . Screen size, free memory, cpu speed ...&lt;br /&gt;
* [[The Dependency Mechanism - part 1]]. Here we talk about the Smalltalk classic &#039;&#039;&#039;Parent&#039;&#039;&#039; - &#039;&#039;&#039;Dependent&#039;&#039;&#039; model.&lt;br /&gt;
* [[The Dependency Mechanism - part 2]]. Here we explain the why of a &#039;&#039;&#039;Model&#039;&#039;&#039; class.&lt;br /&gt;
* [[The Dependency Mechanism - part 3]]. Here we talk about the &#039;&#039;&#039;Observer Pattern&#039;&#039;&#039;. (preferred current method in Cuis)&lt;br /&gt;
* How to use the &#039;&#039;&#039;serial port&#039;&#039;&#039;. See [https://github.com/nmingotti/Cuis-Smalltalk-SerialPort SerialPort] package, it has documentation.&lt;br /&gt;
&lt;br /&gt;
== Run external programs ==&lt;br /&gt;
If you run Cuis in Linux/Unix, and to some extent also in the Mac, you can use thousands of already written shell programs that solve the most diverse issues. Examples:&lt;br /&gt;
&lt;br /&gt;
* Do you want to know how much free space is available on the disk?&lt;br /&gt;
* How many wireless networks your computer can see? &lt;br /&gt;
* Run an R script to make a fantastic plot?&lt;br /&gt;
* ...  these and thousands of other things are possible once you are able to leverage the power of Unix from Cuis.&lt;br /&gt;
&lt;br /&gt;
You can perform these kind of operations with the module &amp;lt;code&amp;gt;OSProcess&amp;lt;/code&amp;gt; included in Cuis or with the external package &amp;lt;code&amp;gt;CommandShell&amp;lt;/code&amp;gt;. The second is easier, the first is lower level. &lt;br /&gt;
&lt;br /&gt;
* Traps and pitfalls specific to running external programs&lt;br /&gt;
* The ABCs of interacting with Unix . Find this process &amp;lt;code&amp;gt;pid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ARGV&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ENV&amp;lt;/code&amp;gt; , &amp;lt;code&amp;gt;stdin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stderr&amp;lt;/code&amp;gt; ... and all those fundamental things.&lt;br /&gt;
* Run a program with OSProcess&lt;br /&gt;
* Run a program with CommandShell&lt;br /&gt;
&lt;br /&gt;
== Networking and the Web ==&lt;br /&gt;
&lt;br /&gt;
* How to ping a computer&lt;br /&gt;
* How to discover the IP of a given host name&lt;br /&gt;
* How to get a webpage&#039;s content&lt;br /&gt;
&lt;br /&gt;
== Databases ==&lt;br /&gt;
&lt;br /&gt;
* Talk to &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;. See the PostgreSQL package, it has documentation.&lt;br /&gt;
* Talk to MongoDB&lt;br /&gt;
* Talk to SQlite&lt;br /&gt;
&lt;br /&gt;
== Scripting Cuis ==&lt;br /&gt;
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.&lt;br /&gt;
&lt;br /&gt;
* Author name and initials programmatically&lt;br /&gt;
* Set your preferred font size&lt;br /&gt;
* Set your user name&lt;br /&gt;
* Stop the system from asking to save the image on pressing Cuis World-&amp;gt;Quit&lt;br /&gt;
* An example of customized Cuis startup Requires only one executable script file !&lt;br /&gt;
* Do ENV variables affect Cuis ?&lt;br /&gt;
* How do I pass a string to be executed by Cuis when it boots ?&lt;br /&gt;
* How do I pass a file to be executed by Cuis when it boots ?&lt;br /&gt;
* How to quit Cuis immediately. No questions asked.&lt;br /&gt;
&lt;br /&gt;
== Scripting with Cuis ==&lt;br /&gt;
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subjects.&lt;br /&gt;
&lt;br /&gt;
* Initial considerations. here&lt;br /&gt;
&lt;br /&gt;
= Delivering an application written in Cuis =&lt;br /&gt;
This section explores ways in which you can have other people, non programmers, use your coolest applications. To run the application it may be necessary to: [1] Run VM and an Image [2] Run VM + Image + some code snippet passed as a String [3] Run VM + Image + a script file.&lt;br /&gt;
&lt;br /&gt;
* Deploy a Cuis application in Linux&lt;br /&gt;
* Deploy a Cuis application in Windows-10&lt;br /&gt;
* Deploy a Cuis application in MacOS&lt;br /&gt;
&lt;br /&gt;
= Morphic Cookbook =&lt;br /&gt;
&lt;br /&gt;
* Basic operations with Morphs&lt;br /&gt;
* Kill a Morph . A few ways to destroy a Morph.&lt;br /&gt;
* Place Morphs in World as you wish, automatically&lt;br /&gt;
* Drawing and pictures with the ImageMorph&lt;br /&gt;
* Application. Convert a color image to black and white&lt;br /&gt;
* Application. Show contours in an image&lt;br /&gt;
* How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.&lt;br /&gt;
* Fonts - 1. First interactions with Fonts&lt;br /&gt;
* Basic event handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.&lt;br /&gt;
&lt;br /&gt;
= The Sound system =&lt;br /&gt;
To some people doing programming is manipulating sounds. As for some other people it is building a nice graphical user interface or some one else does networks services. For this reason the sound system chapter is placed after Morphic. &lt;br /&gt;
* [[First experiments with sound]] . Collecting knowledge here, when ready will be split into topics&lt;br /&gt;
&lt;br /&gt;
= Introspection and The compiler =&lt;br /&gt;
These notes are taken reading the wonderful document &amp;quot;The HitchHiker&#039;s guide to the Smalltalk Compiler&amp;quot; by Vassili Bykov, here .&lt;br /&gt;
&lt;br /&gt;
* get the current World object.&lt;br /&gt;
* what happens when Cuis start up.&lt;br /&gt;
* the main loop.&lt;br /&gt;
* The Cuis scanner.&lt;br /&gt;
* The Cuis parser.&lt;br /&gt;
* See the compiled code.&lt;br /&gt;
&lt;br /&gt;
= The Virtual Machine =&lt;br /&gt;
&lt;br /&gt;
* Building the Virtual Machine&lt;br /&gt;
* Building the VectorGraphics plugin&lt;br /&gt;
* Choosing between FFI and plugin&lt;br /&gt;
* Run a script with a proper window title&lt;br /&gt;
&lt;br /&gt;
= Applications built on Cuis =&lt;br /&gt;
&lt;br /&gt;
* DrGeo&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
These are reminders for me about things to do in the Cookbook or in Cuis&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;DEV&#039;&#039;&#039;. SpellChecker, for text panes in Cuis. It would be useful to be able to spellcheck comments in code. I like to put comments, without spell checker they are so full of bugs they appear really untrustworthy.&lt;br /&gt;
* Video about class variables.&lt;br /&gt;
* Page about &#039;;&#039; -- &#039;::&#039; -- &#039;yourself&#039;.&lt;br /&gt;
* Video about installation of Cuis, not so easy the first time&lt;br /&gt;
* Video about updating Cuis, not obvious&lt;br /&gt;
* Video about using the Transcript efficiently&lt;br /&gt;
* Video about creation of a minimal GUI&lt;br /&gt;
* Video about creation of a minimal application, runnable from Linux command line&lt;br /&gt;
* Video about creation of a minimal application, runnable from Windows GUI&lt;br /&gt;
* Video about making Tests, and discovering how to use existing classes with them&lt;br /&gt;
* Video-or-page about variables, especially class variables&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Convert_UTF16_to_Latin1&amp;diff=168</id>
		<title>Convert UTF16 to Latin1</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Convert_UTF16_to_Latin1&amp;diff=168"/>
		<updated>2025-05-12T20:16:17Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: syntax hilight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&#039;&#039;&#039;Problem&#039;&#039;&#039;. We got a data file in XML, but it is encoded in UTF16. Cuis is based on Latin1 characters, so, if possible we should convert to this character set before doing any operation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution&#039;&#039;&#039;. Provided by Juan on the mailing list on date 11-Jun-2022.&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
utf16 := &#039;expo-test-IT-UTF16.xml&#039; asFileEntry binaryContents. &lt;br /&gt;
possibleBOM := utf16 copyFrom: 1 to: 2. &lt;br /&gt;
isLittleEndian := true. &amp;quot;use your best guess&amp;quot; &lt;br /&gt;
possibleBOM = #[255 254] ifTrue: [ &lt;br /&gt;
       isLittleEndian := true. &lt;br /&gt;
       utf16 := utf16 copyFrom: 3 to: utf16 size ]. &lt;br /&gt;
possibleBOM = #[254 255] ifTrue: [ &lt;br /&gt;
       isLittleEndian := false. &lt;br /&gt;
       utf16 := utf16 copyFrom: 3 to: utf16 size ]. &lt;br /&gt;
String streamContents: [ :out | &lt;br /&gt;
     index := 1. &lt;br /&gt;
     [index &amp;lt; utf16 size] whileTrue: [ &lt;br /&gt;
       codePoint := utf16 unsignedShortAt: index bigEndian: isLittleEndian not. &lt;br /&gt;
       out nextPut: (Character codePoint: codePoint). &lt;br /&gt;
       index _ index + 2 ]].&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Convert_to_Base64&amp;diff=167</id>
		<title>Convert to Base64</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Convert_to_Base64&amp;diff=167"/>
		<updated>2025-05-12T20:10:50Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: syntax hilight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Problem ===&lt;br /&gt;
Encode a String to Base64.&lt;br /&gt;
&lt;br /&gt;
=== Solution ===&lt;br /&gt;
Convert to ByteArray and then encode using #base64Encoded:&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
&#039;Hello World&#039; asByteArray base64Encoded.   &amp;quot;=&amp;gt;&amp;quot; &#039;SGVsbG8gV29ybGQ=&#039; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=How_to_hash_a_string&amp;diff=166</id>
		<title>How to hash a string</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=How_to_hash_a_string&amp;diff=166"/>
		<updated>2025-05-12T20:09:35Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: syntax hilight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Example 1. ==&lt;br /&gt;
Sometimes it is useful to make a number that represents string. This is usually called an &#039;&#039;hash&#039;&#039;, one of its properties is that if you change the string a tiny bit the hash number becomes quite different.&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
&#039;Hello world&#039; hash.     &amp;quot;=&amp;gt; 136137888 &amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
== Example 2. MD5 ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
WebUtils md5Digest: &#039;foobar&#039;.     &amp;quot;=&amp;gt;&amp;quot;   &#039;3858F62230AC3C915F300C664312C63F&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&#039;&#039;&#039;Exercise&#039;&#039;&#039;. Try to hash &#039;Hello World&#039; and see how much different it is.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Exercise&#039;&#039;&#039;. Explore the &#039;&#039;Cryptography-DigitalSignatures&#039;&#039; package for another implementation of the hashing function.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Dump_and_restore_JSON_data_strings&amp;diff=165</id>
		<title>Dump and restore JSON data strings</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Dump_and_restore_JSON_data_strings&amp;diff=165"/>
		<updated>2025-05-12T20:08:10Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: syntax hilight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since Javascript is the only language running inside Web browsers it has become extremely popular to dump and exchange data in JSON format. How do I read a JSON dump made from others? How do I make my own?&lt;br /&gt;
&lt;br /&gt;
First of all, to work with JSON you must load this package.&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Feature require: &#039;JSON&#039;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Problem&#039;&#039;&#039;. I want to convert a Cuis data structure in JSON, how do i do it?&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution&#039;&#039;&#039;. By example.&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
js1 := Json render: { &lt;br /&gt;
  Dictionary newFromPairs: {&#039;codice&#039;. &#039;111.653.735&#039;. &#039;quantita&#039;. &#039;1&#039;}. &lt;br /&gt;
  Dictionary newFromPairs: {&#039;codice&#039;. &#039;111.653.735&#039;. &#039;quantita&#039;. &#039;2&#039;} &lt;br /&gt;
}. &lt;br /&gt;
&lt;br /&gt;
js1 print. &amp;quot;=&amp;gt;&amp;quot;&lt;br /&gt;
&#039;[{&amp;quot;quantita&amp;quot;: &amp;quot;1&amp;quot;, &amp;quot;codice&amp;quot;: &amp;quot;111.653.735&amp;quot;}, &lt;br /&gt;
  {&amp;quot;quantita&amp;quot;: &amp;quot;2&amp;quot;, &amp;quot;codice&amp;quot;: &amp;quot;111.653.735&amp;quot;}]&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Problem&#039;&#039;&#039;. I want to read some JSON string and use it as a data structure in Cuis, how do I do ?&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution&#039;&#039;&#039;. By example. Using the output of previous problem.&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
jo1 := Json readFrom: (ReadStream on: js1). &lt;br /&gt;
&lt;br /&gt;
jo1 class.         &amp;quot;=&amp;gt; Array &amp;quot; &lt;br /&gt;
&lt;br /&gt;
(jo1 at: 1) class. &amp;quot;=&amp;gt; JsonObject &amp;quot; &lt;br /&gt;
&lt;br /&gt;
jo1 at: 1.         &amp;quot;=&amp;gt; a JsonObject(&#039;quantita&#039;-&amp;gt;&#039;1&#039; &#039;codice&#039;-&amp;gt;&#039;111.653.735&#039; ) &amp;quot; &lt;br /&gt;
&lt;br /&gt;
(jo1 at: 1) at: &#039;codice&#039;. &amp;quot;=&amp;gt; &#039;111.653.735&#039; &amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
----Dr. Nicola Mingotti. Last updated 03-Sep-2021. Tested in Cuis-5.0-4815.image .&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Show_me_the_string,_but_max_N._characters&amp;diff=164</id>
		<title>Show me the string, but max N. characters</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Show_me_the_string,_but_max_N._characters&amp;diff=164"/>
		<updated>2025-05-12T20:01:59Z</updated>

		<summary type="html">&lt;p&gt;Nmingott: syntax hilight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In another programming language this may not be such an interesting function but in Smalltalk it is. Why? Because we have inspectors and we are used to see our data interactively. Now image the case you have an ordered collection of Strings, those strings might be email messages bodies or even book texts so, large stuff.  If you open the Explorer it tries by default to show you all the string length, which in many cases it is not what you want and might slow you down.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem&#039;&#039;&#039;. We are dealing with long strings. When we print them we don&#039;t want by defaut to see the whole story, just the beginning and the end snippets are fine. How to do it ?&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution&#039;&#039;&#039;. There is a builtin &amp;lt;code&amp;gt;String&amp;gt;&amp;gt;contractTo:&amp;lt;/code&amp;gt; that perform this simple operation for us, we don&#039;t need to re-define it ourselves.&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;A foobar long string. &amp;quot;&lt;br /&gt;
s := &#039;sdf asdf asdfqwer qwe asd asdf asdf asdf asdf asdf asdf 123 123 1 &#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;let&#039;s have an idea of what is inside it ...&amp;quot;&lt;br /&gt;
s contractTo: 20.   &amp;quot;=&amp;gt; &#039;sdf asdf ...3 123 1 &#039;&amp;quot; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
----Dr. Nicola Mingotti last updated on 06-Sep-2021. Tested in Cuis5.0-4834.image.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
</feed>