-
Notifications
You must be signed in to change notification settings - Fork 1
Home
A programming language cookbook is something like StackOverflow, without the digging part and the try&pray experience. For a gentle and structured introduction to Cuis-Smalltalk, you should start with the The Cuis Book and Learning-Cuis more about this on the References.
Reliability. I am writing this 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.
Sorting principles. Topics 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.
Contribution. If you wish to contribute send me a pull request.
Copyright. 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't claim ownership. You can'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.
- Introduction. What you should expect from this book and the reason why I am writing it. STARTED.
- 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.
- Install and run Cuis in Windows
- Install and run Cuis in the Mac
- Install and run Cuis in Linux
- Run Cuis in the Web Browser. (SqueakJS)
- Run Cuis in a ARM platform, RPi, BeagleBone and similar. (Linux)
- Run Cuis in a remote server. (Linux)
- Run Cuis on the metal: without Operating System
- How to keep Cuis updated
- How to load the most recent changes Juan made to Cuis-Smalltalk-Dev
- What is a .image file?
- What is a .changes file?
- What is a .user.changes file?
- What is a .log file?
- What is release of the image and VM I am running?
- Do ENV variables affects cuis ?
- How do I pass a string to be executed by Cuis when it boots ?
- How do I pass a file to be executed by Cuis when it boots ?
Here are all the things that are totally unknown for anybody who never programmed in any Smalltalk.
- How can I make X ? Learn to fish in Smalltalk
- First things first: 1+1 and "Hello World"
- How can I type in a basic object ? Know the literals !
- You want something to get done? Ask an object to do it!
- How do I define a function?
- How do I create my own Class with some methods inside it?
- What is a package? How do I create, load and unload one?
- My project needs to add a method to somebody else Class, how do I do it ?
- How to use Class variables. STARTED
- Learn how to use the Transcript . This is really important, better you take a peek.
- Interaction tricks . Those little keyboard/mouse shortcut you may find useful.
- Traps and pitfalls for polyglot developers . If you know more programming languages this page is for you.
- "It didn't understand" can't happen. The end of most your uncertainty.
- Create automatically all accessor for your new Class
- Change the way an Object is printed
- Find all objects referencing anObject
-
Make your own object initialization. All you need to know about
new
,basicNew
,initialize
etc. STARTED - How to dump and restore an Object -- STARTED
- How to manage a Class who should have only one instance
- Discover in what package a Class lives
- Follow step bye how a method call gets resolved. Example-1
- Fundamentals: numbers, strings and symbols
- What Strings are made of and how
- String escape
- Automatically escape a complex string
- String formatting with format:
- String formatting with printf:
- A thousand ways to say new line . Newline, to text find it fast
- Trim white chars
- String joining
- String splitting
- String search
- String replace
- Show me the string, but max N. characters
- Dump and restore JSON data strings
- How to hash a string
- Convert to Base64
- Convert strings from/to Utf8
- Jump to the next level of power, use Regex . Last in the list for complexity, but should be first for power, don't overlook this.
- Make a stream from a string, for reading.
- Write a long String with a Stream
- Get the current date and time
- Format date and time as you like most
- Date and time algebra
- Get the current time with the highest precision
- Get date and time as Unix epoch
- Get date and time in a different country
- Measure how much time it takes to run a code block
You should keep in mind that Smalltalk uses files but it is not based on files. I copy here
part of a Juan mail to mailing list: "... 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 live objects. The way them relate to files is usually not really important ...".
- How to Read or Write a text file . without Streams, only Strings.
- How to Read or Write a text file with a Stream
- Read a file line by line . Or any general delimiter.
- Find the current directory, list it and move in the directory tree
- Filename extensions: .txt, .csv, .json ...
- Check things on a pathname. Is there anything? Is it a file? Is it writable? ...
- Delete files and directories
- Read/Write a binary file
- Create a new non-existing file name
- Using file locks -- TODO
- Get the list of open files
- Get the directory where a Class (its Package) is stored
- Where is the image file? Where is the VM?
- Smalltalk processes are not Unix processes
- See the list of running processes
- Processes 101. Shows how to create a process, name it, start it, stop it and destroy it.
- Run a new process
- Kill a process
- Call the debugger from a code location
-
Quick exception handling, equivalent of Python
try ... except
- Assertions
- Errors, raise and catch signals
- Run a method every 2 hours or every day at 15:00, equivalent to Unix cron
- Zip and unZip files and directories --- TODO, miss zipping
- Convert a file to/from Base64
- Deal with XML files -- STARTED
- About Random
- How to invoke the garbage collector
- Adapt newline characters to Cuis standard
- Where to get information about the hardware . Screen size, free memory, cpu speed ...
- The Dependency Mechanism - part 1. Here we talk about the Smalltalk classic Parent - Dependent model.
- The Dependency Mechanism - part 2. Here we explain the why of a Model class.
- The Dependency Mechanism - part 3. Here we talk about the Observer Pattern. (preferred current method in Cuis)
If you run Cuis in Linux/Unix, at to some extent also in the Mac, you can use thousands of already written shell
programs that solve the most diverse issues. Do you want to know how much free space is available on the disk?
How many wireless networks your computer can see? Run a R script to make a fantastic plot? These and thousands
other things are possible once you are able to leverage the power of Unix from Cuis.
You can perform this kind of operations with the module OSProcess
included in Cuis or with the external package CommandShell
. The second is easier the first is more lower level.
- Traps and pitfalls specific to running external programs
-
The ABC of interacting with Unix . Find this process
pid
,ARGV
,ENV
,stdin
,stdout
,stderr
... and all those fundamental things. - Run a program with OSProcess
- Run a program with CommandShell
This section is about setting Cuis to start up in the way you like it, on any image you may want to boot.
- Author name and initial programmatically
- Set your preferred font size
- Stop the system from asking to save the image on pressing Cuis World->Quit
- An example of customized Cuis startup Requires only one executable script file !
Is it possible to make Unix scripts with Cuis? Does it make any sense? This section explores these subject.
- Initial considerations. here
This sections explores ways in which you can have other people, non programmers, use the your coolest applications.
- Basic operations with Morphs
- Kill a Morph . A few ways to do destroy a Morph.
- Place Morphs in World as you wish, automatically
- Drawing and pictures with the ImageMorph
- Application. Convert a color image to black and white
- Application. Show contours in an image
- How to layout the Morphs . This is the basic step to know prodromic to make your own GUI in Cuis.
- Fonts - 1. First interactions with Fonts
- Basic events handling in Morphic . Here we see how to do something when a mouse button or a key on the keyboard get pressed.
This notes are taken reading the wonderful document "The HitcHiker's guide to the Smalltalk Compiler" by Vassili Bykov, here .
- Building the Virtual Machine
- Building the VectorGraphcis plugin
- Choosing between FFI and plugin
- Run a script with a proper window title
These are reminders for me about things to do in the Cookbook or in Cuis
- DEV. 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.
- Video about class variables.
- Page about ';' -- '::' -- 'yourself'.
- Video about installation of Cuis, not so easy the first time
- Video about updating Cuis, not obvious
- Video about using the Transcript efficiently
- Video about creation of a minimal GUI
- Video about creation of a minimal application, runnable from Linux command line
- Video about creation of a minimal application, runnable from Windows GUI
- Video about making Tests, and discovering how to use existing classes with them
- Video-or-page about variables, especially class variables