Forum: Rails I18n Deprecating {{}} and welcoming %{}

Posted by José Valim (josevalim)
on 2010-04-30 18:58
(Received via mailing list)
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:

http://github.com/svenfuchs/i18n/blob/master/lib/i...

Otherwise the improvement falls to half. So, what are your thoughts?
Posted by José Valim (josevalim)
on 2010-04-30 18:59
(Received via mailing list)
Ah, I must add that using %{} removes the need to use the
interpolation compiler.
Posted by Norman Clarke (Guest)
on 2010-04-30 19:03
(Received via mailing list)
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
Posted by José Valim (josevalim)
on 2010-04-30 19:20
(Received via mailing list)
Ah, the benchmark performed the following operation:


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

With the following yml:

  http://github.com/svenfuchs/i18n/tree/master/bench...
Posted by Lawrence Pit (Guest)
on 2010-05-03 08:00
(Received via mailing list)
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.