From: "David A. Black" Date: 2007-03-25T06:30:17+09:00 Subject: Re: Suggestion: swap name of "puts" and "print" and rename "puts" to "put_s" Hi -- On 3/24/07, Michael Brooks wrote: > Hello: > > I've been using Ruby on-and-off for about 4 weeks now and love it. > However, some of the naming consistencies really bug me. The ones that > bug me the most are the "print", "puts" and "putc". > > I'd like to suggest that the functionality of the names "puts" and > "print" should be swapped so that "print" automatically sends a newline > character and "puts" doesn't. The reasons for this are as follows: > > - "print" in other languages I've used (e.g. Basic) sends out a newline > character. > > - "putc" doesn't send out a newline so why should "puts". > > - The "puts" method sounds like a techier name so it shouldn't be doing > console style formatting and "print" sounds like the name you'd expect > to be using with terminal / printer based formatted output. > > Also, I'd like to suggest that the "putc", "puts", "gets" and "getc", > etc... should be renamed to "put_c", "put_s", "get_s" and "get_c", > etc... to keep their syntax consistent with the naming conventions used > with "to_s", "to_a" and "to_i". Or alternately, rename "to_s", etc... > to "tos", etc... Either way, just make it consistent. > > At a minimum I think the "put_c", "put_s", etc... should be implemented > and the "putc", "puts", etc... identified as obsolete syntax. > > I realize these changes would effect every piece of Ruby code but the > language is still fairly young (at least with respect to it's version > number) and since it sounds like version 2.0 is going to break a few > things it might be a good time to adjust a few names and conventions. > I'm sure a little Ruby script using regular expressions could rename > everything quite easily. Alternately, new versions of Ruby could have a > command line switch to run the old syntax but by default would run the > new syntax. > > I apologize in advance for irritating anyone... I'm still new to Ruby > and maybe I misunderstood some of the intentions behind the naming > conventions. It's because Ruby is so consistent/smart in many other > areas (I love the OO goodness) that this stuff (don't get me started on > Find.find() or Benchmark.bm()) bugs me. I love promoting Ruby with > co-workers but can't help but mention (or get asked) why some things > like this look kind of silly. This reminds me of the "old days" when so many people in the West reacted to Ruby by saying, "I love this language, and by the way, here's what should be changed to make it more attractive to [Perl/Java/C[++]/...] programmers." My reaction was always: what about Ruby programmers? Very nostalgic :-) It always struck me as a strange mix of an inferiority complex (Ruby exists to serve the needs of people who mainly use other, somehow more "real" languages) and ambition (Ruby should strive to be perfect [whatever that may mean]). The truth is neither. Ruby is just Ruby. It's being worked on constantly, but it's not a candidate language or an apprentice language or even a new language. If your co-workers are going to have a pea-under-the-mattress reaction to seeing anything they don't think is perfect in Ruby, they're holding Ruby to an unrealistically high standard -- in fact, not even high; just unrealistic. It's like pushing a lump around under a carpet: if puts and print get exchanged, then someone else will think things are worse; and if they get changed back, you'll think it's worse, and so on. The way out of the loop is to do what Ruby in fact does: it's designed by Matz, who listens extremely carefully to a lot of advice but ultimately makes the decisions himself. In fact... you should check out the various venues for discussing changes in the language (here, ruby-core, RCRchive). We do it all the time. If you want to suggest something, you don't have to package it in meta-rationalizations about what Ruby should be -- you can just suggest it. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)