4 ms·
This has been my general experience too. I've found myself taking Crockford's description of "Scheme in C's clothing" to heart. I treat object's more as first-
by calebmpeterson 16y ago
This has been my general experience too. I've found myself taking Crockford's description of "Scheme in C's clothing" to heart. I treat object's more as first-class maps/associative arrays - much in the same way that maps are first class in Clojure - than I do as proper OOP objects.
Functional JavaScript is exciting and maleable to me, which is a breath of fresh air after (still) waiting so long for proper closures and anon functions in Java.
- olavk 15y agoThis is a semantic quibble, but I disagree that objects in JavaScript are any less proper OO just because they are implemented as associative arrays. JavaScript is a fundamentally OO language in a way Scheme is not - for example all built-in types in JavaScript are objects with methods. I think OO is getting a bad name due to people annoyed with Java, and functional is hip these days. But JavaScript is still an OO language.
- chc 15y agoI think you're a little bit eager to defend JavaScript's OO credentials here. Nobody said anything like "objects in JavaScript aren't proper OO" or "JavaScript is not an OO language." Caleb said that he prefers to use a functional style of programming in JavaScript and tends to treat objects as simple maps.
- calebmpeterson 15y agoGlad to see that my explanation wasn't hopelessly incomprehensible. Now if only JS supported immutability... I think I'll go learn some more Clojure. :)
- olavk 15y agoIn ECMAScript 5 there is support for immutability with Object.seal(), Object.freeze() and Object.preventExtensions()
- olavk 15y agoYou are right. Apparently I cant read.
- calebmpeterson 15y agono problem at all-happens to me regularly
- calebmpeterson 15y ago> This is a semantic quibble, but I disagree that objects in JavaScript are any less proper OO just because they are implemented as associative arrays. JavaScript is a fundamentally OO language in a way Scheme is not - for example all built-in types in JavaScript are objects with methods. Not even a semantic quibble - more like me poorly expressing my typical use of objects in JavaScript. I agree - objects in JS are full objects. I just tend to limit my use of them to the associative array realm... > I think OO is getting a bad name due to people annoyed with Java, and functional is hip these days. Agreed. I've written ~250K lines of Java (real-time, highly parallel and concurrent systems with hardware accelerated UI) in the past 3 years and love many things about the language and (especially) the JVM. FP is certainly in vogue right now - and for mostly good reasons. Hopefully as the pendulum swings we'll end up with a healthy middle-of-the-road approach which incorporates OO and FP. After all, closures are a poor man's object and objects are a poor man's closure. > But JavaScript is still an OO language. Most certainly! I was just highlighting the ability to (mis)use it as a functional language. Though as a functional language its lack of immutability is a double edged sword...