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.