From: Alan Burch Date: 2006-03-12T00:58:56+09:00 Subject: Re: Help me understand why the Ruby block is slower than wit James Gray wrote: > On Mar 10, 2006, at 4:57 PM, Alan Burch wrote: > >> I first saw >> that the array class mixed in enumerable and that I could use the to_a >> call from there, but a quick check using -r profile showed that my >> original call to split was a much quicker way to convert from a string >> to an array. > > This sounds like premature optimization. Remember, you start > worrying about speed when the code gets too slow. Not before. > > James Edward Gray II James: I'm going to have to respectfully disagree. I guess maybe I'm getting to old to code, but I first learned assembler and then C. Assembler served me well in that I knew how to write the fastest, least resource intensive C. Back in the early 80s on a VAX running V7 UNIX that was more important than maintainability. As I've continued my craft and learned many other languages, I've found that truly understanding what's happening "under the hood" of any language was the key to writing code that didn't break, executed quickly, and kept clients happy. Furthermore, there's something in me that makes me better love the language when I completely master it. I don't believe the language is mastered until one understands things such as why one construct executes quicker than another. I can now picture how a mix-in works and why calling the to_a mix-in is a slower construct. I don't understand all the nuances of that yet, but I intend to and that will make Ruby that much more enjoyable to me. Thanks for a different insight, Alan -- Posted via http://www.ruby-forum.com/.