I'm (trying) to learn Smalltalk, and I have a few questions:

1. What's the difference between using := and _ to assign to variables?
2. What's the best Smalltalk implementation? (I have Squeak installed as of now.)
3. Would it be possible to implement a Smalltalk-like object system in Snap?

Isn't this forum for discussion about Snap!?

and computer science in general

It's fine to ask about Smalltalk here; we have a historical connection with Smalltalk, which was the implementation language for BYOB before it was rewritten as Snap!. Jens started programming in Smalltalk.

I'm not an expert on Smalltalk, but I think I can answer two of those questions.

Squeak is the right thing. At some point in the past, mainstream Smalltalk changed its mission from being a language for kids (as in Alan Kay's original vision) to being a language for adults doing production programming. Squeak is Alan's return to the original idea.

Of course. You can implement anything in Snap!. :~)

But to move beyond that answer I have to know what the question really means. Do you just want a class/instance system instead of a prototype based system? That's easy. Make a sprite, give it all the methods and class variables you want, clone it, and then hide the original. That original is now a class, and its clones are instances.

If you want it to behave exactly like Smalltalk, you have to do a little more work. In Snap!, the parent's variables are copied, not shared, in the clones. This is a compromise; the pure conceptual Snap! clones would share every property with their parents unless they do something to break that link. But too many projects depend on giving clones ID numbers by creating the clones inside a FOR loop, so if the ID number were shared, all the clones would have the same value. So you'll want to say something like

But if you want to build a class/instance system yourself, we show how to do that in Chapter VIII of the Manual. First class procedures are all you need; objects are just a metaphor wrapped around closures (the procedures you make using rings).

If there's some specific feature of Smalltalk objects I'm forgetting, ask a more detailed question.

It really depends a lot on what you want to achieve. Squeak is where I learned Smalltalk, but I moved to Pharo when I started using Smalltalk professionally.

If you want to learn how a Smalltalk works from the ground up, though, I'd suggest a smaller Squeak variant called Cuis. You can pretty much read the whole source in a weekend. It's a tiny (and much cleaner) variant. It'll set the base for you to move on to more complete Smalltalks later on.

The issue with Squeak is that at some point it started accepting all contributions from the community, leading to it having at least 3 different UI rendering engines, a bunch of different package systems, etc. You'd end up finding your way around all the bogus code, but it's way easier to begin with a Smalltalk where someone has decided on a common project view, I think.

No difference, really. IIRC, in the original Smalltalk-80, you'd use the underscore key and Smalltalk would translate it into a left facing arrow, so assignments would look like myVar ← 'Hello'.

In Squeak, and probably other Smalltalks, you can (or could, at least) use the underscore for backwards compatibility.

In any case, I'd recommend going with := because it'll make your code more portable should you ever want to try running your programs in some other Smalltalk implementation.

Darn. I need an excuse to go back to Smalltalk. I really miss it

How do I run Smalltalk code in Squeak? As in, is there a command line flag or a button in the UI?

Back a million years ago when I first learned to program, the character with ASCII character code 95 was a leftarrow. At some point, I think while I was an undergrad, which would mean late '60s, but if you really care about the date I'm sure you can look it up, some committee decided to change two character codes, 95 to underscore, and umm I think 94 from uparrow to caret. The latter change was probably to be able to use it as a zero-width accent circomflex, but I don't know of any good reason to replace leftarrow with underbar. Actually maybe it was earlier than I'm thinking, because variable assignment in Fortran uses =, although maybe they were just looking for something whose obvious English vocalization ("equals") would make some kind of obvious sense, at least if you avoid things like x=x+1 (which of course you can't in languages with primitive control structures). By contrast, it takes a little practice to learn to pronounce leftarrow as "gets."

So that's why underscore turns up as assignment in Smalltalk; it makes files with leftarrows still work.

Smalltalk code is always running in Squeak. Squeak is a live environment written in Squeak itself

OTOH, when you want to explicitly execute a piece of Smalltalk code, just select it and press Control+D, for Do It, or Control+P, for Print It, or Control+I, for Inspect It. You can also access these options from the context menu by right clicking after selecting.

37

Thats the only (2) things bad in JS!
The second one is to have a broken == (and a fine ===) so OhNoes must force uis to write ===.

If you say so. I was going by

I mean the keycode of ←
Oh no,its 8592

Oh, right, after they invented Unicode you could find any glyph you want, but not in ASCII, and hence not on most computer keyboards, and hence not in most programming languages. My point is that the code that's now underscore used to mean leftarrow, before you were born.