News for hackers. Stuff that matters.
Re:Rails 3.2 Performance: Another Step Slower by coldtea on Wednesday November 27, 2013 @04:08AM (#6807203)
>I think that all the metaprogramming magic that Ruby allows is at odds with speed

Well, Javascript allows almost as much metaprogramming (and with ES6 proxies and such, exactly as much).

Re:Rails 3.2 Performance: Another Step Slower by adamnemecek on Wednesday November 27, 2013 @04:25AM (#6807252)
a.) Unless, you use eval profusely, it really does not. I'm not sure how much metaprogramming power proxies really give you.

b.) It also has Google pumping a LOT of resources into making it fast.

Re:Rails 3.2 Performance: Another Step Slower by moonie1 on Wednesday November 27, 2013 @05:40AM (#6807446)
That doesn't seem right. Can you give an example? I use lots of js metaprogramming, but it mostly involves wrapping and passing functions, mixing in methods and dynamic getters etc. I don't think I've ever actually had to use eval, or anything eval-like.

OTOH, grep for instance_eval and class_eval in rails source.

Re:Rails 3.2 Performance: Another Step Slower by adamnemecek on Wednesday November 27, 2013 @05:51AM (#6807469)
Right, you should never ever use eval but I don't think that a lot of the things that are commonly done in Ruby could be achieved in JS without eval. And what you are talking about is not exactly meta-programming.

> OTOH, grep for instance_eval and class_eval in rails source.

I mean what's your point. Yes, I realize that both are used profusely, which is one of the things that this discussion is about.

Re:Rails 3.2 Performance: Another Step Slower by moonie1 on Wednesday November 27, 2013 @07:54AM (#6807769)
> And what you are talking about is not exactly meta-programming.

I didn't describe metaprogramming, just how I usually see common metaprogramming "magic" implemented in javascript. The only reason you'd really need eval in js metaprogramming is if for some semantic reason it was nicer to accept a String of javascript somewhere. Afaik eval doesn't "get" you anything in javascript (it doesn't "unlock" private closures scope or anything, and context-injection is available using #call or #apply) and I almost never see it used, unless I am forgetting something (totally possible, I've been up all night)

> I mean what's your point. Yes, I realize that both are used profusely

My point is I don't see eval used profusely in javascript, which contradicts your assertion in a).

Edit: nvm, I stand corrected: (function(){var x = 1; eval('console.log(x)'); })() prints 1. Neat. But still, I do not see this often used, the callback + context passing approach is much more common.