As a matter of fact, I just wrongly received a confirmation email for the order of an engagement ring!
# before
def my_method
do_stuff_with("My String") # 1 allocation at each call
end
# before, optim
MY_STRING = "My String".freeze # this does 2 allocations with 1 at init being GC quite early
def my_method
do_stuff_with(MY_STRING)
end
# after
def my_method
do_stuff_with("My String") # 1 allocation first time
end
But this move also complicates strings manipulation in the sense of it will lean users toward immutable ops that tend to allocate a lot of strings. foo.upcase.reverse
# VS
bar = foo.dup
bar.upcase!
bar.reverse!
So now we have to be deliberate about it: my_string = +"My String" # it is not frozen
We have frozen string literals for quite a while now, enabled file by file with the "frozen_string_literal: true" comment and I've seen it as the recommended way by the community and the de-facto standard in most codebase I've seen. It is generally enforced by code quality tools like Rubocop. * Senior Ruby/React Full-stack Engineer: https://jobs.makesense.org/jobs/smnN9zk5LPiMZjo6YJM9
* Lead Ruby/React Full-stack Engineer: https://jobs.makesense.org/jobs/BTPoBrfV75GTwqEZZTCZ
* Senior iOS Engineer: https://jobs.makesense.org/jobs/9mBQKOvUU1tqNvbQ7tjH
* Senior Android Engineer: https://jobs.makesense.org/jobs/il6DleKLaUAWoiU77Kxr
* Electronic / IoT Engineer
Expected candidates are perfect English speakers, and also French speaking or willing to learn it.