Deprecating {{}} and welcoming %{}

Hey guys,

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?

Ah, I must add that using %{} removes the need to use the
interpolation compiler.

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.

-Norman

Ah, the benchmark performed the following operation:

I18n.backend.translate :en, :“activerecord.errors.models.user.blank”,
:model
=> “User”, :attribute => “name”

With the following yml:

i18n/benchmark/example.yml at master · ruby-i18n/i18n · GitHub

Hi José

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