7 ms·
Self Programming Language
- maitredusoi 7y agoThe interface builder I hope one day to design, was design 30 years ago ... gloups ;)
- agumonkey 7y agonote that Lars Bak went onto v8(js) and then Dart https://en.wikipedia.org/wiki/Lars_Bak_(computer_programmer) https://en.wikipedia.org/wiki/Lars_Bak_(computer_programmer)
- tosh 7y agoHe is currently (together with Kasper Lund et al) working on a new language and runtime for IoT use cases. a recent talk from Curry On 2019 https://www.curry-on.org/2019/sessions/the-making-of-a-secure-and-robust-iot-development-platform.html https://www.curry-on.org/2019/sessions/the-making-of-a-secur...
- microtherion 7y agoAnd Urs Hölzle also did reasonably well for himself: https://en.wikipedia.org/wiki/Urs_Hölzle https://en.wikipedia.org/wiki/Urs_Hölzle
- fzzzy 7y agoI was super obsessed with Self about 15 years ago. JavaScript's prototypal inheritance was influenced by Self. I was more interested in Self's graphical environment at the time, though.
- masklinn 7y ago> JavaScript's prototypal inheritance was influenced by Self. Sadly more as a shortcut to getting an "object system" up and running quickly than as a design principle though, most of the interesting bits of Self were left by the wayside in the process (possibly in part to provide something which feels more like Java). Not to mention the subtle (and not necessarily sensible) terminological swaps e.g. in Self a prototype is a "blueprint" instance, which is already set up with all relevant traits & mixins, and gets copied and modified to get the proper instance.
- fzzzy 7y agoYes, this is true. My point is Self's influence lives on. Also, Self's JIT was very influential and was the forerunner to Java JIT research. Copying and modifying the blueprint always did make way more sense. To this day I still don't think I understand exactly how JavaScript's prototypes work, exactly.
- masklinn 7y agoJavascript's "prototype" is really Self's "trait". Self prototypes have been replaced by constructors which rather than be normal instances are special constructs building instances then setting their prototype property as the (sole) parent to the new instance. You can partially replicate Self's mechanism by performing a regular shallow-copy (e.g. using `Object.assign(target, source)` then explicitly copying over the prototype (that's fallible as Object.assign only copies the values of enumerable own properties so it's not going to copy the properties themselves).
- ChrisSD 7y agoTo expand on masklinn's point, Javascript's prototypes are actually very simple. It's just people overcomplicated it so as to do things it wasn't designed for (e.g. emulate Java classes). These points covers most of what a prototype is: 1. A prototype is simply another object (or null). 2. Every object can have one (and only one) prototype. 3. When looking up a property that doesn't exist on the object, the object will delegate to its prototype. 4. When calling a function on an object, the `this` keyword will be bound to that object, even if the function is defined in the object's prototype. A simple example to explain what I mean: // Provide a default implementation of a kitten const kitten = { name: "unnamed :(", greet() { // Note that `this` will be bound to // the object that invoked the method console.log(`Meow! I'm ${this.name}.`); } } // Create a named kitten. // `Object.create` creates a new object and sets // its prototype. const grabbity = Object.create(kitten); grabbity.name = "Grabbity"; // Call `greet` on the kittens. kitten.greet(); // outputs "Meow! I'm unnamed :(." grabbity.greet(); // outputs "Meow! I'm Grabbity." The only other thing to mention is something you can probably infer: Every prototype is an object therefore a prototype can have its own prototype (and so on). In this way prototypes can be chained.
- nerdponx 7y agoThis was a fun watch: https://www.youtube.com/watch?v=Ox5P7QyL774 https://www.youtube.com/watch?v=Ox5P7QyL774
- Someone 7y agoNot only fun, educational, too. For example, I learned that Self had multiple code generators, just as modern JavaScript engines have “give me decent code, fast”, and “give me fast code; may take some time” engines.
- jolmg 7y agoIs there a good resource that shows the ideal use of prototypal inheritance? I imagine that the ideal use is not mimicking class-based inheritance, or is it? I mean if you have an array of things and you want a new instance of such things, it's too unnatural to take one from the array, clone it and change it. It seems more natural to have something class-like: An "empty" prototype and a constructor function. I guess what I'm wondering is what idioms and patterns are unique to prototypal-inheritance OOP languages.
- Crinus 7y agoChances are those things were cloned from something else so you can simply clone that something else and put the clone in the array. AFAIK (though my knowledge is limited) in Self there isn't a language-endorsed prototype like in JavaScript, instead an object is just a collection of slots and some slots can be marked as parent slots meaning that whenever slot lookup is made on an object, that object's parent objects will also be looked up. Prototypes are just a convention. This implies that there isn't a "this is of class foo" connection (outside of manual conventions) and hence you do not have an "array of things" but an "array of objects" and each one of these objects can be anything - it is up to the rest of the code to ensure (or not) any similarity between the objects stored in the array. FWIW the Self Handbook does seem to have a section on programming style and generally does seem to write a bit about how you are supposed to work with the system.
- masklinn 7y ago> AFAIK (though my knowledge is limited) in Self there isn't a language-endorsed prototype like in JavaScript, instead an object is just a collection of slots and some slots can be marked as parent slots meaning that whenever slot lookup is made on an object, that object's parent objects will also be looked up. That's correct, although incomplete: parents are only used when no "own" slot matches a message. Self will also trigger an error if two parents answer to the same message. > Prototypes are just a convention. Not so, however "prototype" has a completely different meaning in Self than it has in Javascript: a Self prototype is a mostly set-up object to copy, there is no semantic relation between a prototype and its "instance" afterwards. In Self, an object built to be set on a parent slot (and shared between multiple sub-objects) will be called either a trait or a mixin (depending on its parent chains, essentially). Self parent slots are no more and no less than built-in delegation. They can be used for inheritance (traits), they can be used for sharing implementation (mixins) or they can be used in the general context of composition (Go has echoes of this in struct embedding).
- vlaaad 7y agoI don't understand why languages like these are not mainstream. Why are we stuck with blindly editing text files and waiting for compilation that restarts the whole world? Why state of the art is a REPL where immediate feedback is limited to printed text with all the actual values barely reachable?
- jolmg 7y ago> Why are we stuck with blindly editing text files It's inherently more portable and composable. > waiting for compilation There are many languages that are interpreted that are mainstream. > that restarts the whole world You can program in mainstream languages without restarting the world. See skewer-mode[1] for example, for programming in javascript without restarting/refreshing. You can change top-level definitions and send them to override the previous definitions. You can do this with any language that allows overriding functions at runtime, IOW late-binding languages with an eval function, like python and ruby. This way of programming is probably very non-mainstream, though. The reason why it's not more popular is probably because most of us are working with programs that take little to no time to restart and get to the same state. Restarting ensures that whatever state we see in the program is reachable with the current state of the source code. > Why state of the art is a REPL where immediate feedback is limited to printed text with all the actual values barely reachable? Again, because that's inherently more portable and composable. What do you mean they "actual values [are] barely reachable"? You can access anything via any REPL I can think of. [1] https://github.com/skeeto/skewer-mode https://github.com/skeeto/skewer-mode
- pavlov 7y agoIt often feels like the mainstream computer industry did a single dip into PARC, took the ideas that could be reasonably implemented on a 1982 Motorola 68k in assembly and Pascal with minimal RAM, and forgot about everything else. Soon thereafter PCs became obsessed with being either Unix or VMS, and over time that created a harsh immune response to the influence of Smalltalk/Self because it's such a different paradigm.
- projektfu 7y agoFor one thing, Self was barely fast enough to work with on reasonable hardware of the day. If you don't mind 100ms+ latency on every click and keypress, it's fine. I found it frustratingly slow, so I guess I'm pretty latency sensitive. Perhaps it's zippier now on today's fancy hardware. Smalltalk (e.g. VisualWorks) felt much faster even though it was rendering components itself. Probably a mixture of optimization of common cases that was missing in Self and certain advanced compilation/interpretation tricks that were also missing. VisualAge felt slower. If you used VisualAge for Java you also were using the Smalltalk UI. (That is, until Micro Edition). Squeak using Morphic was pretty slow in its original non-jit mode but the Smalltalk-80 UI was fast (and quite different from how you expect things to work.)
- jolmg 7y agoThe handbook seems down. Here's The Internet Archive's copy: https://web.archive.org/web/20190417013701/http://handbook.selflanguage.org/ https://web.archive.org/web/20190417013701/http://handbook.s...
- dang 7y agoThread from 2017 ('Can we ever get away from the misnomer of "prototype-based OO"?'): https://news.ycombinator.com/item?id=14409088 https://news.ycombinator.com/item?id=14409088. 2014: https://news.ycombinator.com/item?id=7047953 https://news.ycombinator.com/item?id=7047953 2010: https://news.ycombinator.com/item?id=1957511 https://news.ycombinator.com/item?id=1957511 and https://news.ycombinator.com/item?id=1520246 https://news.ycombinator.com/item?id=1520246 Surely there have been others?
- stormcode 7y agoThis language also inspired LambdaMOO (created by another Xerox Parc employee) which is another early example of a prototype based language, with its own built in environment, but it's all text based. I'd heard about self in a talk, but hadn't read the docs until now. Super cool reading about it now. Good slice of history.