TL;DR
Metho allows you to easily and safely add methods in the form of dynamic properties to any object. Sounds boring, but if used to e...
For further actions, you may consider blocking this person and/or reporting abuse
How is
2[to(13)]
better thanrange(2, 13)
? Or13[isEven]
better thanisEven(13)
?I see how it's an interesting syntax trickery to play around with, but I don't see how that produces anything other than confusion. It's definitely not something I'd want to see in production.
Completely agree. Interesting, but of no pragmatic value beyond raising an interesting idea.
Come on, the syntax looks cool. No, practicality isn't the point here.
Interesting concept I must say. Quite elegant! I don't think I would use it in a real scenario, as it's not so clear how it works and would confuse people initially. Though it's fascinating, and might use it some time in one of my projects!
Agree that it is interesting; but it's not elegant. It's confusing, abstruse, inefficient, and has no upside over writing a simple function.
This is DOPE! I'm laughing so hard ))
These are JavaScript Extensions, like Swift and Kotlin extensions
The development and discussion of extensions like this (for any language) is a great way to test the viability of new features before preparing formal proposals.
They might end up just being something the original developer finds useful or merely interesting, but others might also find them of use.
They should carry a health warning until they are fully tested, adequately documented and licenced. But then there are far too many widely used packages (JS and other stacks) that fall short of this stipulation.
Just look at how John Resig's jQuery influenced the evolution of JS and the development of Web APIs and continues to be in wide usage.
Looks like Smalltalk to me.
Really? Haha... I've read about Smalltalk, but have never seen any code
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.
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.
Point taken.. but still a messy language when compared to Smalltalk.
Nice idea!
Just a question, what about TypeScript?
Not a fan of TypeScript at all, but according to some who've looked at this idea with relation to TS - it apparently doesn't play very well.
If you want to have a go at making it integrate well with TS though, please go right ahead! Contributions welcome
You thought of it before I could! I am currently building a library that would use symbols as semi-private methods. I must say, this is quite better than whatever I was thinking :)
You keep creating things of beauty. This one seems to experiment on the connection between data and behaviour, exposing that there are more elegant ways than what was given to us as OOP.
and yet he's recreating Smalltalk syntax (and Smalltalk is the definition of what "real" OOP is)
He's using an OO language (JavaScript) with Functional style to implement another OO language's syntax
Quite interesting, but I can't at all see the proper motivation or benefits.
Hahahahaha :D