by Y_Y · 4y ago · 0 comments
https://mitpress.mit.edu/9780262543231/structure-and-interpr...
:)
It does have some warts due to early design mistakes, mostly related to type coercion and semicolon insertion. A linter can protect against that.
Among its supporters, much is made of the fact that Eich initially wanted to do scheme in the browser. But JavaScript does not have code-as-data which to me is the defining quality of Lisp/Scheme. It does have lexical scope and closures, but any mainstream language has this these days. It has prototypal inheritance which is mostly notable because it is different from the more common class based inheritance, not because it is particular good in its own right.
With a caveat that browsers implemented a rather crippled version of it. Much goodness of prototypical inheritance comes from most everything being an object - as with smalltalk. Regrettably browser implementations chose to half-ass this. How many types does browser js have? A few primitives, and Objects, ... and great many implementation types poorly pretending to be Objects, backed with code which accepts only the implementation type and chokes on real objects. They repeatedly implemented a fast path and stopped there, ignoring the general case. Imagine how poorly smalltalk would work if similarly compromised. Browsers have gotten less bad in this respect in recent years, but far too late for the community to learn prototype style programming from js.
Code as data (homoiconicity) was ruled out by the "Make it look like Java" order from Sun and Netscape management. Sorry.
which I consider to be the defining problem of Lisp/Scheme. It becomes impossible to reason about code if it gets used too much or indeed at all.
Note that the lambda calculus has no such feature (though of course you could build an LC interpreter in LC)
In the same way that it is worth studying why super successful ancient languages like C and C++ are still used today by millions of programmers. With new C/C++ projects being started every single day. Despite the looooong list of complaints and weird design decisions and foot guns and security issues etc. etc.
And let me also (tongue-in-cheek) question your sense of fashion: Haskell is so last year compared with leading edge dependently typed languages like Idris. And Scheme is the language your grand-grand-dad was taught at uni and never used in production. Not exactly what I would call “fashionable” :)
Meanwhile, immutable.js[0] is at 10 million downloads per week and rising.
I would add that it's not just the ease of use of lambdas, but the fact that in JavaScript functions really are first class citizens. Most of the other widely used languages have closures added in as a bit of a hack and only treat some functions as real values.