Thanks for your feedback. I agree with you about use idioms for better readable code. Its cool, but Rails has many places where this not use. A lot of code can be corrected according to this, but this is not done. And I thought, why not use it in favor of speed? That is what I was based when wrote this message.
пятница, 6 мая 2016 г., 14:31:40 UTC+3 пользователь Xavier Noria написал: > > In general, the Rails code base wants to use Ruby idiomatically. > > loop is the most succinct idiom in Ruby for those kinds of loops, see for > example: > > https://github > .com/rails/rails/blob/254f57ca3668398a5fcfd4f63be5d91c4c3b1cd4/actioncable > /lib/action_cable/connection/stream_event_loop.rb#L66 > > If a Ruby programmer sees a while true there instead, generally speaking > they would shake their heads a little bit. Why is this not a loop? A > comment would be needed: "This while true is here for performance". > > When is it OK to do a little strange thing for performance? Where it > matters, not systematically across the code base. So, for example, if you > change loop with while true in the previous example, probably there won't > be any noticeable difference. So you just don't. > > And if the gain is tiny, the cost of writing something less idiomatic, > elegant, or readable is still not worth it. Because code has to be read. > > You depart from this with a scalpel, precisely where it pays off. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.