3 ms·
Meta-programming JavaScript Using Proxies
- evilpie 13y agoPlease note that he seems to be using the old Proxy API.
- zmanian 13y agoI didn't understand what was special/novel about Proxies at all.
- kevingadd 13y agoProxies basically paper over the numerous weaknesses in Javascript's design by exposing named hooks for things like function calls and property accesses. It's not special or novel - in a language like python the equivalent is mundane things like naming a method __add__ or __getattr__. It's important for JS, I suppose, because without it a bunch of interesting metaprogramming techniques are impossible and you end up with inferior APIs that have worse performance characteristics. On the other hand, Proxy will probably be slow forever like all corner case JS features, so you really only win on API quality here :( EDIT: I should mention that Proxies do have some really interesting use cases; sadly the linked post does a terrible job of illustrating any actual reason you'd want to use them.
- pselbert 13y agoI recently wrote about a great, and very simple, use case for JS Proxies [1]. They are the cleanest way to implement the mediator pattern in JS, which has some great uses in MVC. [1]: http://blog.sorentwo.com/2013/12/06/presenting-by-proxy.html http://blog.sorentwo.com/2013/12/06/presenting-by-proxy.html
- quim005 13y agoThis seems a lot like Lua metatables. I don't know why people don't just give up on JavaShit and just name Lua as EcmaScript v6. It's vastly superior in every possible way.
- voidr 13y agoNormally I like having features like this in a language, but in JS I think it will be just a new tool for the "ninjas" to write crappy unmaintainable with it.