I did a couple benchmarks related with using {{}} or %{} as
interpolation option in message and got the following results.
Using Ruby 1.9.1
{{}} 525.48 ms
%{} 320.03 ms
Using REE
{{}} 813.61 ms
%{} 637.31 ms
This means a 40% improvement on using %{} over {{}} for Ruby 1.9.1 and
20% for REE. T
Therefore I want to propose deprecating the current syntax in favor of
%{}. But you may ask, why deprecate if both syntaxes works? The main
reason is that we can just obtain these good results if we remove the
gsub call:
Otherwise the improvement falls to half. So, what are your thoughts?
I think it’s a good idea. It improves performance and encourages
developers to use standard Ruby 1.9 syntax as opposed to custom
functionality specific to this library. As long as there’s a
sufficiently long deprecation period, I really see no drawbacks.
Regardless the performance improvement, I had suggested to deprecate the
{{}} months ago when %{} made it’s way into the rails code. I think it
makes more sense to stick to standard ruby syntax (which can be
optimized by the compiler) instead of sticking to a syntax that was
invented for rails only.
Cheers,
Lawrence
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.