The Object Model of Self
github.com
github.com
Oh and it uses the same lingo as javascript, which is a net negative, I think the Self lingo makes much more sense: a Self prototype is the object you copy in order to get more instances, once the copy is done there is no relationship between the prototype and the object just as there is no strict relationship beyond kinship between your car and its original prototype. I guess "template" might have been an even better term there.
The shared behaviour (and potentially data) lives in traits and mixins.
One ‘whatever’ where it doesn’t win is in robustness. Code will make assumptions about various kinds of animal and fail when meeting a sheep with 5 legs, or a pig that can fly.
You can solve that by testing for capabilities, but you would have to do that in many places, and make sure to cover all of them.
And yes, that comes at the cost of flexibility. Your class model won’t support flying pigs until you consciously add such support.
The other thing I suppose is multi developer environments - classes and compilation win out over prototyping because they're easier to split up. There might be other reasons, but that's why I always come back to class based programming, the idea of prototypes is very enticing though.
Edit: though I have started to use a pseudo prototyping environment - breakpoints and evaluate when things get complex, though its not the same.
What is so bad about that?
And isn't it common practice around computer games for example, which can be modded and extended by custom user content?
But now, switching between a terminal that uses shift-ctrl-c for copy, and outlook/o365 in chrome, I often accidentally open developer tools in my email "application"... And wonder how much better we might be off with a solid smalltalk (or strongtalk, self) system -- than the current mix of crappy web apps and crappy electron behemoths...
I should note that it's generally possible to strip out/hide and disable most of the introspection stuff from smalltalk applications and ship more end-user style applications.
Sure, programmable by what today we'd call "programmers" but certainly not by "users." This is because programming has become a niche trade (as I said before, like a scribal culture).
I'll give an example. Most users' experience with their host Operating System involves prodigious use of buttons. They know how buttons work and they know how to interact with them. But in all these OSes it is extremely difficult for a user to make a button that does something they want, then, say, place it on their desktop for future use.
In the past there were really good attempts at authorship in computing media (which is more like what the LRG was going for with Smalltalk etc), including Hypercard. In the latter system, you could pop open a button and see how it worked in a comprehensible scripting language. You could copy the button and paste it somewhere else. You cannot do any of this with buttons in the major OSes. The capability is not there.*
The only option available to "users" is to learn a full fledged, general purpose programming language with all the pitfalls that entails, which means learning build systems and all the rest. At that point they have to become what today we call a "programmer," ie a scribal-programmer.
Our dominant systems have been explicitly designed for a strict delineation between scribal-programmers and consumer-users. That's the rub.
* - AppleScript is a so-so attempt at this, but even that has been allowed to die on the vine.
I'm not against them - these are reasons I can see for not using prototype languages.
Edit: I suppose to the environment a developer wants isn't the environment that a game user wants, like a game user wants to just extend a few things - but having the whole self environment for arguments sake would be fairly intimidating I'd imagine.
With FP you can simulate both class based approaches and prototype based approaches. The slightly 'warped' perspective of the FP lens might give you more insights into your question.
(I can expand, if you are interested.)
It makes it very easy to follow exactly how the OO works, what it is, and is not.
Everything felt like a hack.
Protoypical OOP was the only savior left, haha.
Many of the warts have smoothed over time, but JS got a reputation for being an ugly hack language early on, and unfortunately that also rubbed off on the idea of prototype OO. I remember hearing a lot of griping about how JS isn't a "real OO" language (!#@!@#!@) because it only had prototypes and not classes. And a lot of rejoicing when classes were proposed for the language. Which to me was a sign of defeat.
Prototypes are more expressive and can express classes but classes cannot express prototypes.
FWIW I used to talk to and correspond with Steve Dekorte (author of Io) back when he was starting out. Looks like he's stopped working on it, which is unfortunate. It was always a nice language, though not suited for my purposes. And I think he chose a bad name as it wasn't easily Googleable. I'd like to see what he could do with it now in the era of Wasm...
What if interface matters? Just recently I've discovered how to clear some confusion:
Object
Object.proto === null
object = new Object
object.proto === Object
object.toString === Object.toString
fun = new Function
fun.proto === Function
It's almost io (just don't touch 'constructor') Object = Object.prototype
Function = Function.prototype
syntax new = function (ctx) {
let ident = ctx.next().value
return #`new ${ident}.constructor`
}
// bonus point - make it more like io
Reflect.defineProperty(Object, 'proto',
Reflect.getOwnPropertyDescriptor(Object, '__proto__'))
And io is great!I've never done any real work with Io, only read about it. First came across it in 7 languages in 7 weeks[1]. Compared to JS, it seems like a much more coherent realisation of protypes. It recognises the difference between "types" - descriptions of things - and "objects" - exemplars of those descriptions. But the only difference (that I recall) is that types are capitalised by convention, objects aren't. On my "todo list" for further exploration st some point.
[1] https://pragprog.com/book/btlang/seven-languages-in-seven-we...
EDIT: fixed book title & corrected case
(My interest in prototype OO languages back then was specifically as authoring languages for shared virtual worlds so I wanted something with security baked in. The language I implemented accomplished this through very strong encapsulation, among other things.)
Like I said above, it'd be nice to see something like Io done with Wasm in mind, as a cleaner alternative to JS, say.
It's limited, confusing and muddled, because the prototypal stuff was really there for the ease of implementing an object system (until ES6 the prototype was the red-headed stepchild of the language standards-wise) and ctors were tacked on for familiarity with Java but actual inheritance support (actually supporting JS-level subtypes) was all half-assed and very confusing before ES6. Basically pre-ES6 it was a complete mess unless you used non-standard extensions (e.g. `__proto__`).
ES6 both dramatically surfaced the prototypal inheritance (Object.create, Object.getPrototypeOf, Object.setPrototypeOf, Object.defineProperty) and made it even more of an implementation detail of the "class" syntactic sugar.
Nowadays you can pretty much use JS as a class-based language… and most people do that because frankly it's not worth messing around with the underlying prototypal system, you'll just confuse both your colleagues and your editor.
The `class` keyword was introduced in ES6, which is indeed a kludge on top of prototypes.
You’re right, I did. So the actual timeline was somewhat less dim than I remembered.
> The `class` keyword was introduced in ES6, which is indeed a kludge on top of prototypes.
I wouldn’t say that it’s a kludge. I’d anything it’s more of a realisation of the original vision of JavaScript (which you could fairly call a kludge): using a prototype system to underlie a langage approaching java semantics.
Which may well be the dumbest way to approach it as you get the flexibility of a class-based system and the performances of a prototype-based system rather than the other way around, but at the same time JS’s prototype system was kneecapped from the start.