DEV Community

Discussion on: Introducing Metho: Safely adding superpowers to JS

Collapse
 
aminmansuri profile image
hidden_dude

This is what Smalltalk looks like:

1 to: 5 do: [ x | Transcript show: x]

That would "print" the numbers from 1 to 5.
Smalltalk is both OO and functional. It receives the method to:do: and you pass it a "block" (known as a "lambda" or "closure" in lesser languages) as [ ].

My theorem of languages states:

"Smalltalk was too advanced for it's time, and the last of the truly innovative languages. Most people don't understand it, but have spent the last 40 years trying to create languages that are more like it but utterly fail because they fail to adopt it's simple and intuitive syntax and the full breadth of it's features"

C++ added some OO-like features, but wasn't enough.
So Java added VMs and GC and some introspection that brought it closer to Smalltalk.
Ruby went further and added metaclasses and some of the other features.
Now JavaScript has suddenly become functional (and has "added" classes) but keeps getting messier and messier.

Maybe one day people will embrace the simple brilliant elegance of Smalltalk and put down these other messy and incomplete tools. But I'm not holding my breath.. more likely we'll end up with some lame imitation that is messy.

Thread Thread
 
lawrencedol profile image
Lawrence Dol

JS hasn't "become" functional, at all -- it was functional from it's inception. Even it's prototypical OO is functional. The function truly is, and has always been, the core abstraction of JS.

What I wish is that JS engines would recognize this and deeply optimize function closures to remove any penalty for using them as object instances.

Thread Thread
 
aminmansuri profile image
hidden_dude

Point taken.. but still a messy language when compared to Smalltalk.