3 ms·
I learned several prototype OO languages (Self, LambdaMOO and variants) before I learned JS back in the mid-90s. I even wrote my own compiler and VM for my own
by cmrdporcupine 7y ago
I learned several prototype OO languages (Self, LambdaMOO and variants) before I learned JS back in the mid-90s. I even wrote my own compiler and VM for my own.
My take is that JS's implementation of prototypes isn't terrible, but it's also not clear what it's doing all the time. Like many other things in JS the semantics are often odd (strange scoping rules, functions as construtors in certain contexts only, etc.)
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...
- sergeykish 7y agoI agree, interface is arcane but once it clicks... And that may be a problem - world divided by those who grasped that Object.__proto__ === Function.prototype and other. I've heard similar stories in XSLT land. 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!