Blogged by Ujihisa. Standard methods of programming and thoughts including Clojure, Vim, LLVM, Haskell, Ruby and Mathematics written by a Japanese programmer. github/ujihisa

Saturday, April 11, 2009

Why Ruby doesn't have the IO.write method

While Ruby has a class method IO.read to read the whole contents of a file, Ruby doesn't have the corresponding method IO.write. The reason why Ruby doesn't have the class method IO.write is already mentioned by Matz in Japanese.

Q. Is there any positive reason why IO.write isn't there even though IO.read is there?

A. No. I have only the negative reason that IO.write won't be used as many times as IO.read. I'm also afraid the method causes users to waste memories. I ignore the symmetrical property.

I also found another disscussion about it in English.

Although Ruby doesn't have IO.write, we can define it in just three lines. That's OK. But, it's laborious to define it every time we need IO.write or to write equivalent one. There must be shortcuts.

I searched that from Rails' ActiveSupport::CoreExtentions and Merb's Extlib. There are a lot of utility methods, but there isn't IO.write! Does nobody feel bothered by it?

No comments:

Post a Comment

Followers