ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Deep Scratch # 1

Tue Oct 02, 2012 12:10 am

This is a brief introduction for anyone wanting to get deeper into Scratch for customising, debugging or simply to try your hand at Smalltalk. First though, it's going to be a lot less painful if you are in the right frame of mind before we move on to specifics. So here's my, possible lame, attempt to prepare you...

Scratch is an application written in one particular Smalltalk environment known as Squeak. Smalltalk and Squeak have been around many years. If you are younger than 30-ish then it's older than you and not only that, it's probably had less down-time than you. That's because the fully object-oriented environment that is Smalltalk was first boot-strapped all those years ago and has rarely been re-booted again except in it's early years. It's old but it's age does not mean it's obsolete. Quite the opposite. It's mature, runs on many systems and has got significantly faster in recent years. If you think it's a fringe phenomenon then think again. Smalltalk concepts that are decades old have found their way into nearly every mainstream language and continue to do so. So what exactly is it...

Until relatively recently the Smalltalk environment was an alien concept to most people. That's mainly because the likes of Squeak live in what's known as an "image" which require this scarey thing called the "VM" (Virtual Machine) to breathe life into it. Today, even if you have never heard of Smalltalk or Squeak and even if you are not a programmer, it's still very likely that you are already familiar with the concept of a virtual system living in an "image". That's what virtualizers such as VMWare, VirtualBox, QEMU, etc, do for you, they create a virtual computer onto which you can install an operating system. The "image" there is typically a simulated disk drive (a file!) whose contents are more-or-less exactly what you may find on your actual computer, ie, a file-system on which you store and organise programs, libraries and a large variety of data files. But what about the "virtual" computer, where's that? That is simulated for you by WMWare, etc, and you hardly give it a thought. At some point though the virtual has to become real(-ish), you want a desktop to interact with (using real physical devices like the kb & mouse), music coming out of speakers, web pages from the 'net, etc, etc. So the virtualizer has to connect it's virtual devices, including the virtual CPU, to real devices to do real work.

Now what if you wanted a different type of virtual computer, e.g. one that processed objects instead of bits & bytes? That's what Squeak's VM does. Fundamentally it's an "object engine" and also provides the interconnect between the object-world of Squeak and the real computer on which the VM runs. It has it's own virtual devices, the more obvious ones being for display and sound. These devices along with other services are implemented as "plug-in's" which are libraries of executable code just like many others on your computer. They are special only in as much as they present a pre-defined interface to the VM. Inside of Squeak there are only objects, some of which have "primitive" methods. These "primitives" are where virtual becomes real, they are the interface to the VM from the object-world side of things. You rarely deal directly with primitives because there will be objects that more closely resemble real devices, such as the cunningly named "Display" object, or the equally cunningly named "SoundPlayer" object. Instead of a hierarchy of various kinds of files, there's a hierarchy of objects, some that make immediate sense like those just mentioned, some more abstract. The "glue" between objects are messages passed between them. Some people, especially Smalltalk's creator Alan Kay, consider messages the essence of Smalltalk. You will too once things click.

In case I'm painting a too-rosey picture, which wouldn't be good preparation for you, it has to be said that the VM *is* complicated. It's been adapted and improved over many years to cater for a large variety of platforms. The object environment *is* complicated. It has a surprisingly large number of objects to do a variety of tasks befitting that of a typical operating system, which of course it is (ok, not "typical"). That said, real bugs in the VM are rarely discovered and it is used in large, sometimes critical, commercial operations without major problems. Smalltalk as a language has only about one-side of an A4 sheet of syntax and once you have picked up a few essential skills you will have everything you need to explore the whole of the object-world. It still may feel a little alien but it'll be beautifully alien and you will want to keep on exploring and experimenting.

Tomorrow, how to get everything you need for digging deeper.

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Deep Scratch # 1

Tue Oct 02, 2012 3:35 pm

reserved

User avatar
RaTTuS
Posts: 10493
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Deep Scratch # 1

Tue Oct 02, 2012 3:43 pm

reserving won't help - you have 30 mins
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Deep Scratch # 1

Tue Oct 02, 2012 7:18 pm

Looks like its time to buckle up for a big ride! :)
Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Deep Scratch # 1

Wed Oct 03, 2012 9:54 pm

There will be a delay while I await some info and a possible update.

Simon/Tom: do you want to be guinea pig's before I post anything else up?

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Deep Scratch # 1

Wed Oct 03, 2012 10:04 pm

I just want Scratch fixing NOW!!!! so people stop saying its unusable on the RPi :) so willing to do anything to make it so :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

proxima
Posts: 30
Joined: Tue Sep 18, 2012 3:16 pm

Re: Deep Scratch # 1

Thu Oct 04, 2012 6:32 am

ked wrote:There will be a delay while I await some info and a possible update.

Simon/Tom: do you want to be guinea pig's before I post anything else up?
Yes please! Like Simon, I'm really keen to get Scratch working as well as possible on the Pi, as soon as possible. It's my Son's birthday tomorrow, and guess what he's getting?! We'll be using Scratch quite a bit over the next few days and weeks I think, and the sticky-keys bug in particular is going to be a pain. So if there's any way I can help get it fixed - whether it being trying out new updates or learning how to fix it myself - than count me in.

I'll keep a close eye on the forums here.

Cheers,
Tom

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Deep Scratch # 1

Thu Oct 04, 2012 6:33 pm

PM'd

antiloquax
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
Contact: Website

Re: Deep Scratch # 1

Thu Oct 04, 2012 7:47 pm

Great to see this thread. I will read it properly when I have a little more time!
Scratch On!

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Deep Scratch # 1

Sun Oct 07, 2012 1:20 am

Link to full article, excuse formatting, will be fixed next week: Deep Scratch
Please see the end of the article for links if you have any questions about Scratch, Squeak or the VM.

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Deep Scratch # 1

Sun Oct 07, 2012 10:09 am

Wow :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
mister_wavey
Posts: 98
Joined: Sun Sep 02, 2012 8:23 am
Location: Abergavenny, Wales, UK
Contact: Website

Re: Deep Scratch # 1

Sun Oct 07, 2012 10:36 am

fantastic guide!

proxima
Posts: 30
Joined: Tue Sep 18, 2012 3:16 pm

Re: Deep Scratch # 1

Mon Oct 08, 2012 9:23 am

Thanks ked, that's great.

drmcw
Posts: 18
Joined: Fri Sep 14, 2012 9:23 am

Re: Deep Scratch # 1

Mon Oct 08, 2012 9:52 pm

Great article thanks. Do have one question and apologies if not the correct place for the question;
I wanted to approach this from a slightly different angle by running on x86 Debian to see what if any differences the ARM side of things was making. So followed instructions up to $ scratch . So all I then needed to do was install scratch. Can't find it in the software packages so downloaded the deb file from the Scratch web site. Won't install without errors (no squeakvm)! Have followed the squeakvm.org instructions and added them to the apt sources.list and so have a squeakvm via apt-get. Have then installed the Scratch deb file and scratch runs but errors if you try and use the file open menu. apt-get install -f is required which then uninstalls scratch as its not in a fit state dependency wise. Any ideas for installing scratch on debian?

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Deep Scratch # 1

Mon Oct 08, 2012 10:47 pm

Hi all and thanks for the comments! I will be finalising it later this week so any/all feedback welcome.

@drmcw: are you wanting a regular Scratch install or trying to reproduce my instructions? I think from what you describe that you have ended up mixing the two and also added in files from the Scratch site meant for Windows and also a VM from squeakvm.org. That's a bit of a mix :o The only thing I can suggest is to start again, first with a regular install to check everything works ok and then again with the instructions. For regular install there definitely are Debian packages for the VM and Scratch, that's where Raspbian, Ubuntu, etc, get them from. They should be easy to locate via Synaptic or in a terminal using "apt-cache search <keyword>" (try "squeak-vm", "scratch" for keywords). For the instructions be sure to use Debian not Raspbian repo's, especially for VM build dependencies. There *is* a Debian "source" package for the VM so you don't need to pull anything from squeakvm.org. However, there is not a Debian "source" package for Scratch so just use the instructions in section 2.2 as written (already using Debian repo ***). HTH.

*** To clarify: In case that last sentence seems a contradiction, normal deb's get their files from somewhere, in the case of Scratch that's the big archive file with "orig" in it's name. This is not a "source" package as such but contains most of we need. So it's from the Debian repo, it has Scratch "source" in it but it's not a Debian "source" package. Clear as mud? :P

drmcw
Posts: 18
Joined: Fri Sep 14, 2012 9:23 am

Re: Deep Scratch # 1

Tue Oct 09, 2012 10:05 am

Thanks for the reply ked. I was following your instructions but on x86 based debian on a laptop rather than on a pi. As your instructions then require running of scratch then I thought I'd do a regular install so I could follow your instructions i.e. a slight diversion as regular debian doesn't have scratch pre-installed like the pi.
They should be easy to locate via Synaptic or in a terminal using "apt-cache search <keyword>" (try "squeak-vm", "scratch" for keywords).
They should be you would think but they aren't :!: Only reference I can get for scratch says "Package scratch has no available version, but exist in the database. This typically means that the package was mentioned in a dependency and never uploaded, has been obsoleted or is not available with the contents of sources.list" which is why I then went to scratch.mit.edu and downloaded their linux (Not Windows!) install which is a deb file. The deb file doesn't install properly though.

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Deep Scratch # 1

Tue Oct 09, 2012 10:41 am

It's in Wheezy-testing. You won't see it if you are only pulling packages from a "stable" repo. If you know what you are doing (and the implications) then add the repo, reload and it should appear in Synaptic. If not then it may be safer to just download the deb. See here for further info and deb links:

http://packages.debian.org/wheezy/all/scratch/download

drmcw
Posts: 18
Joined: Fri Sep 14, 2012 9:23 am

Re: Deep Scratch # 1

Tue Oct 09, 2012 1:37 pm

As Bob Fleming would say "That got it!"
Yes was on stable, but now have it from wheezy.
Thanks.

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Deep Scratch # 1

Fri Oct 12, 2012 12:40 pm

Thanks to lightin, Scratch-source repo now on github: https://github.com/lightnin/Scratch_1.4

ked
Posts: 42
Joined: Thu Aug 04, 2011 9:18 am

Re: Deep Scratch # 1

Tue Aug 13, 2013 4:18 pm

Apologies to anyone trying to find the github repo, now located here: https://github.com/LLK/Scratch_1.4

Return to “Scratch”