Slashdot Mirror


Programming Ruby: The Pragmatic Programmers' Guide

James Edward Gray II writes " Programming Ruby: The Pragmatic Programmers' Guide (Second Edition), known as the Pickaxe II to its fans, is an extremely current view of the Ruby programming language. Revised primarily by Dave Thomas, a founding father of the English Ruby community, Programming Ruby is distilled expertise from a reliable source. In the past, quality English documentation of Ruby has been in short supply, but if any one volume could solve that problem, this is it." Read on for the rest of Gray's review. Programming Ruby: The Pragmatic Programmers' Guide author Dave Thomas with Chad Fowler and Andy Hunt pages 830 publisher Pragmatic Bookshelf rating 9 reviewer James Edward Gray II ISBN 0974514055 summary The definitive source for all things Ruby.

If you're not familiar with it, Ruby is a very fun and elegant scripting language that has been described as "more powerful than Perl and more object oriented than Python." I won't start a language war by defending that statement, but I will tell you what makes Ruby very attractive to me: Extremely object oriented, super clean syntax, and a smooth blending of iterators and code blocks for straightforward, concise solutions. If that sounds like a language you would like to know more about, Programming Ruby is the book for you.

At 830 pages, this edition is considerably larger than the first. It represents an expansion on many topics originally covered, in addition to all new coverage on topics like unit testing, RDoc documentation for Ruby source code, and more. Better still, "Duck Typing," a topic central to Ruby philosophy, receives its own enlightening chapter. This volume covers the very latest release of the language, often highlighting new features and even giving tips for things to watch for in future versions.

Programming Ruby is divided into four distinct sections. "Part I - Facets of Ruby" is a tutorial on the Ruby Programming Language. It's very effective, but I probably better give a warning here: This book teaches you how to program in Ruby, not how to program. You likely won't feel comfortable, even in this tutorial section, unless you have some experience with other programming languages. As an example, Ruby is object oriented on a scale with languages like Smalltalk, so you'll need to know object oriented programming. This book makes no attempt to teach such concepts, excepting how they apply to Ruby. As long as you come with the proper background, this section will get you on your feet with Ruby in under 200 pages. It's very well thought out.

"Part II - Ruby in its Setting" is a mixed-bag tour on the many places Ruby sees use. Web programming, command-line hacking, using TK to build GUIs, and Windows programming are just some of the covered topics. Other chapters in here focus on elements unique to Ruby, like the earlier mentioned RDoc or "irb," the interactive Ruby shell. There's even a chapter in here on package management with RubyGems.

When you're ready, "Part III - Ruby Crystallized" will take you deep into the core of Ruby syntax and functionality. This section tells you all the details about how Ruby reads your code, and how it runs. I think few people could soak in all the tidbits in here in one scan. I've read it twice now and learned about as much both times. There's a lot of great Ruby knowledge waiting to be mined out of here.

Finally, "Part IV - Ruby Library Reference" is the best Ruby reference I've yet run across. It covers every class, module, method and constant in core Ruby. The descriptions for these entities tell you exactly what you need to know, the examples, though short, are inspiring, and the comments sneak in subtle hints that are more than useful. Following this, the book gives an overview of all Standard Libraries included with Ruby. This section really opened my eyes to the tools I've been missing out on simply because I didn't know they were there. Be warned: These Standard Library summaries won't teach you every feature available. They just tell you what they're for so you'll know where to look for the information you need. The last great feature in this section is a terrific index. I care about the index and a book that has a bad one will really bother me. Luckily, that couldn't be further from the truth here.

Programming Ruby isn't perfect, of course. Some of the chapters are not as thorough as you wish they could be, simply because of the amount of information that needs to be covered. The chapter on threads is probably the biggest example of this, but remember that entire volumes have been written on threading. Another minor point is that some of the examples are quite contrived. This bothers some people, but I don't feel it's too much trouble for the book's target audience. As I've said, you're expected to know how to program going into this book, just not how to program in Ruby.

Programming Ruby at least touches on most things central to the Ruby Programming Language, and goes into considerable detail more often than not. There's something for all levels here. You can learn Ruby from the tutorial, as I did with the first edition, but you'll keep coming back to the wonderful reference and to go deeper into specific areas of interest. That's a lot of great mileage for one book. I'm willing to bet most Ruby Gurus keep it in arm's reach, because Ruby wouldn't be half as much fun without it.

You can purchase Programming Ruby from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

231 comments

  1. First edition is available online. by Kenja · · Score: 5, Informative

    http://www.rubycentral.com/book/

    --

    "Have you ever thought about just turning off the TV, sitting down with your kids, and hitting them?"
    1. Re:First edition is available online. by Cygnus78 · · Score: 1
    2. Re:First edition is available online. by Anonymous Coward · · Score: 4, Informative

      The 1st edition is very out-of-date. It's kinda like reading a Perl 4 book to learn Perl 5.8. But the author was generous to provide it for free and it is available in MANY formats online from PDF to Microsoft Help to HTML.

      I own the 2nd edition and am VERY happy with it except for the quality of paper. Reminds me of Java in a Nutshell because it quickly teaches the language and also provides a reference to keep on your desk. This is my first and only hardcopy Ruby book and I doubt I'll need another one for a few years.

      For those of you new to Ruby or just curious, here are some useful links:

      Ruby Home
      http://www.ruby-lang.org

      Ruby Forum (new! primarily for beginners)
      http://www.ruby-forum.org/bb/

      Ruby Online Docs
      http://www.ruby-doc.org

      Ruby Project Archives
      http://raa.ruby-lang.org
      http://rubyfor ge.org

      Ruby Package Manager (easy to install ruby apps)
      http://rubygems.rubyforge.org/wiki/wiki.pl

      Ruby IDE (free!)
      http://freeride.rubyforge.org/wiki/wiki.p l

      Ruby One-Click Installer for Windows
      http://rubyinstaller.rubyforge.org/wiki/w iki.pl

      Ruby IRC channel
      #ruby-lang at irc.openprojects.net

      Ruby Newsgroup
      news://comp.lang.ruby

      Ruby Links
      http://www.rubycentral.com/links/index.html
      http://dmoz.org/Computers/Programming/Languages/ Ru by/Software/

    3. Re:First edition is available online. by some+guy+I+know · · Score: 1

      And here they are converted to actual links:

      Ruby Home
      http://www.ruby-lang.org/

      Ruby Forum (new! primarily for beginners)
      http://www.ruby-forum.org/bb/

      Ruby Online Docs
      http://www.ruby-doc.org/

      Ruby Project Archives
      http://raa.ruby-lang.org/
      http://rubyforge.org/

      Ruby Package Manager (easy to install ruby apps)
      http://rubygems.rubyforge.org/wiki/wiki.pl

      Ruby IDE (free!)
      http://freeride.rubyforge.org/wiki/wiki.pl

      Ruby One-Click Installer for Windows
      http://rubyinstaller.rubyforge.org/wiki/wiki.pl

      Ruby IRC channel
      #ruby-lang at irc.openprojects.net

      Ruby Newsgroup
      news://comp.lang.ruby

      Ruby Links
      http://www.rubycentral.com/links/index.html
      http://dmoz.org/Computers/Programming/Languages/Ru by/Software/

      --
      Those who sacrifice security to condemn liberty deserve to repeat history or something. - Benjamin Santayana
  2. Web programming by fembots · · Score: 0, Offtopic

    The review mentioned web programming, does one need a specific platform installed or it "just runs"?

    1. Re:Web programming by Luk+Fugl · · Score: 4, Informative
      The review mentioned web programming, does one need a specific platform installed or it "just runs"?

      I'm not sure what you mean by platform or "just runs". If you mean, do you need a certain OS? No. Do you need Apache in particular? No, though Apache and Ruby work very well together. Do you need any external web server? No. One of the standard libraries that comes with Ruby is WEBrick, which is a standalone webserver. You can get Ruby running web apps using WEBrick on any OS, no other software required.

      Along those lines, let me throw in a quick plug for Ruby on Rails. Rails makes web application using the MVC model very quick and easy. The default setup includes a WEBrick servlet so you can have your application listening for requests minutes after installation, literally.

      Visit #ruby-lang and #rubyonrails on freenode for more information about Ruby in general or Rails.

      Jacob Fugal

    2. Re:Web programming by fembots · · Score: 1

      Ahhh thanks, that's what I need to know. I don't mind to try out new languages, as long as they're easy to set up.

    3. Re:Web programming by cmowire · · Score: 1

      It's in the packages/ports trees for most modern unix-ish operating system. It's installable from cygwin. And it's available as a windows binary.

      It supports CGI and FastCGI, plus there's an Apache module.

      And there's a variety of frameworks that are trying to be Ruby's answer to Zope, but that's not anything required.

    4. Re:Web programming by Anonymous Coward · · Score: 0

      There are a bunch of interesting web frameworks for ruby one (incomplete) list is at http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ ruby-talk/92222 my personal favorite: Iowa at http://www.enigo.com/projects/iowa/index.html

  3. About the Ruby Gems chapter... by tcopeland · · Score: 4, Insightful

    ...it was written twice. Chad Fowler wrote it the first time while he was on vacation in Europe. Then he had to rewrite it after his Powerbook was stolen on his trip home. Argh!

    More on Ruby Gems here.

    1. Re:About the Ruby Gems chapter... by DAldredge · · Score: 1

      And that is why programmers should not be in charge of backups ;->

    2. Re:About the Ruby Gems chapter... by chadfowler · · Score: 4, Funny

      In my own defense, I was backing it up...to a USB drive that also got stolen ;)

    3. Re:About the Ruby Gems chapter... by tcopeland · · Score: 1

      > backing it up to a USB drive
      > that also got stolen

      argh ** 2

    4. Re:About the Ruby Gems chapter... by goldspider · · Score: 3, Funny

      After reading that, I think Ruby has a long way to go in terms of security.

      --
      "Ask not what your country can do for you." --John F. Kennedy
    5. Re:About the Ruby Gems chapter... by johndeeregator · · Score: 3, Funny

      I hope he learned a lesson about doing work while on vacation. Hell, most of us don't even do work while at work.

    6. Re:About the Ruby Gems chapter... by chadfowler · · Score: 2, Insightful

      But, if you're doing Ruby, it's not work ;)

    7. Re:About the Ruby Gems chapter... by tcopeland · · Score: 1

      > After reading that, I think Ruby has a
      > long way to go in terms of security.

      FWIW, Chad doesn't maintain the Ruby core - he was writing a chapter of the book. So his laptop getting stolen was a major hassle for him, but it didn't endanger the Ruby CVS repository.

    8. Re:About the Ruby Gems chapter... by DAldredge · · Score: 1

      Fine, come up with a good excuse! Me, I never lose my USB drive...

      HEY, where is my Virgin USB drive!!!

      Never mind ;->

    9. Re:About the Ruby Gems chapter... by Anonymous Coward · · Score: 0

      Aap ki maata ko shabd hai.

      I understand Hindi, but dont understand your sig. What does it mean?

    10. Re:About the Ruby Gems chapter... by abhinavnath · · Score: 1

      "Word to your mother."
      Generic hip-hop greeting, I believe it's related to "Word"/"Word up!".

      --
      My other sig is also a .Porsche
    11. Re:About the Ruby Gems chapter... by JamesOfTheDesert · · Score: 1

      That reminds me: have to upload code deltas from my laptop! (I'm coding Ruby on vacation in Germany)

      --

      Java is the blue pill
      Choose the red pill
    12. Re:About the Ruby Gems chapter... by whereiswaldo · · Score: 1


      If you can get access to the net occasionally, I'd recommend backing your stuff up online.

    13. Re:About the Ruby Gems chapter... by chadfowler · · Score: 1

      Right...it's silly colloquial American English translated directly to Hindi (which means most Indians wouldn't understand it at all ;)

  4. Ruby is great. by nullvector · · Score: 4, Insightful

    Ruby is like the glue that holds alot of my programs together.

    The first edition of this book came in really handy in college, when I'd have to find creative ways to do something (especially text manip), where C++ or Java just seemed to get in the way.

    Ruby is quick to learn, and Dave Thomas from Pragmatic is a great teacher...he came to my school for a little lecture/speech one day, and talked on the merits of Ruby, which is how I got introduced to it.

    The network aspects of Ruby are great too. Small concise ruby programs can do a whole lot :)

    1. Re:Ruby is great. by hoggoth · · Score: 4, Funny

      > The first edition of this book came in really handy in college

      Man, I feel old.
      For me, 'Programming Cyber 7600 Assembly' came in really handy in college.

      --
      - For the complete works of Shakespeare: cat /dev/random (may take some time)
    2. Re:Ruby is great. by nullvector · · Score: 2, Funny

      The nice thing about computer engineering, though, is that I took a look at quite a few of those old assembly books as well :) The Motorola 68HC11 book was a well-worn part of my arsenal also.

    3. Re:Ruby is great. by bcrowell · · Score: 1
      I bought the first edition of the book, but was scared off from doing too much with Ruby because (a) it seemed like the language was still changing rapidly, and (b) Unicode support had to be bolted on.

      How are these issues now? Are there still changes being made to the language that will break code? I heard that Ruby was eventually going to have "something better than Unicode" for dealing with non-ASCII characters --- has that happened?

    4. Re:Ruby is great. by mccoma · · Score: 1
      I was thinking the same thing with my "IBM 370 Assembler" banana book.

    5. Re:Ruby is great. by Anonymous Coward · · Score: 0

      Cyber 7200? Luxury! Why, in my day, all we had were CDC 6400s, and we were grateful for that!

  5. Given all the gem analogies... by grunt107 · · Score: 4, Funny

    Why didn't reviewer say 'Brilliant, but slightly flawed'.

    1. Re:Given all the gem analogies... by GMFTatsujin · · Score: 4, Funny

      Put three copies of it into your Horadric Cube ... that'll upgrade it from "flawed book" to just "book."

      Anyone want to do the math on making a perfect book?

    2. Re:Given all the gem analogies... by Moonbird · · Score: 1

      Informative?? Funny maybe ... if you're into Diablo 2...

      --

      --
      All extremists should be taken out and shot.
  6. Goodbye Ruby Tuesday by Timesprout · · Score: 3, Funny


    Who could hang a name on you

    Oh come on someone had to do it.

    --
    Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
    What truth?
    There is no dupe
    1. Re:Goodbye Ruby Tuesday by samberdoo · · Score: 1

      Yes it is Tuesday. Hey isn't Dave thomas that Wendy's guy?

    2. Re:Goodbye Ruby Tuesday by sbowles · · Score: 1
      Hey isn't Dave thomas that Wendy's guy?

      That's the dead Dave Thomas. He must be this Dave Thomas from Bob & Doug McKenzie fame.

      --
      You sly dog: you got me monologuing! - Syndrome
    3. Re:Goodbye Ruby Tuesday by samberdoo · · Score: 1

      Beauty eh?

  7. What demand is there for RUBY in the workplace? by Anonymous Coward · · Score: 0

    Is it a desirable function that employers are looking for? Can you make money or is it just like other jobs, non existant and low paying.

    1. Re:What demand is there for RUBY in the workplace? by Rich_Kilmer · · Score: 3, Interesting

      We have built an extremely robust distributed testing framework for a Java-based multi-agent system completely implemented in Ruby (see Cougaar for more on the project and the ACME testing framework). We were told on starting this project (at DARPA) that it would never work...I really like proving people wrong ;-) My company is using its Ruby expertise as a differentiator in the market and getting very good reception.

    2. Re:What demand is there for RUBY in the workplace? by CatGrep · · Score: 2, Informative

      These Guys just hired about 4 Ruby programmers to work with Rails (a Ruby-based web application framework that uses an MVC model that's generating a lot of interest in Ruby)

      I suspect that you'll see more small shops using Rails (and thus Ruby) in the coming months.

    3. Re:What demand is there for RUBY in the workplace? by Anonymous Coward · · Score: 1, Informative

      There was absolutely no demend for it where I work until an enthusiastic Ruby programmer gave a talk on the language and its libraries. Now it has helped to make people here quite a bit more productive because of both its simplicity and how fun it is. So first, learn it (it's really easy---don't worry), and if you decide it'll help where you work, then create the demand. This won't make you any more money however, but this is about making your job easier and more enjoyable.

    4. Re:What demand is there for RUBY in the workplace? by Anonymous Coward · · Score: 0

      ...robust distributed testing framework for a Java-based multi-agent system...

      sigh...

    5. Re:What demand is there for RUBY in the workplace? by Phrogz · · Score: 2, Interesting

      a) See http://www.rubygarden.org/ruby?RealWorldRuby

      b) It's a marvelous tool to increase productivity; I wrote something in ~2 hours which parses ~70 XML documents in ~10 directories and creates 150+ static HTML pages (for a help system shipping with the application) from moderately complex business logic off of 5 template files.

      Changed or added an XML document? Run the ruby script. Need an HTML tweak? Change one template file and run the script. 3 seconds to parse the XML documents (and apply Textile markup to certain sections) and 3.5 seconds to create the HTML.

      Ruby allowed me to very quickly write a complex tool that now saves me a huge amount of time every time I use it. Even *if* no companies were hiring specifically for Ruby skills, having a tool in your belt that makes you stand out is still a Great Thing.

  8. It's got to better than... by foistboinder · · Score: 2, Funny

    The non-Pragmatic Programmers' Guide

    1. Re:It's got to better than... by Anonymous Coward · · Score: 1, Insightful

      Actually, I think that would depend on the development environment. And in your case, with that 'it's got to be better than' mentality, perhaps you would prefer the non-pragmatic version?

  9. RubyConf 04 was held recently.... by tcopeland · · Score: 3, Informative

    ...thanks to Ruby Central for sponsoring it.

    A BitTorrent of the presentations is available here.

    1. Re:RubyConf 04 was held recently.... by chadfowler · · Score: 2, Informative

      Thanks Tom. It's actually http://rubycentral.org.

    2. Re:RubyConf 04 was held recently.... by tcopeland · · Score: 2, Informative

      Curses... thanks. Would that there was a post editing capability... ah well. Retry:

      Thanks to Ruby Central for sponsoring RubyConf 2004!

  10. pickaxe? by Suppafly · · Score: 1

    where does the pickaxe name come from?

    1. Re:pickaxe? by Rich_Kilmer · · Score: 5, Informative

      It comes from the pick and axe on the front cover of the book :-)

  11. Good/bad points by 2.7182 · · Score: 1

    I liked this book a lot but there are a lot of typos.

    1. Re:Good/bad points by Feminist-Mom · · Score: 0

      True, but I can live with that. What really bothers me is how bad the index is. I am not as positive about this book as most people I have spoken too.

    2. Re:Good/bad points by PragDave · · Score: 3, Informative

      Could you give some examples? I'd love to fix stuff. if it's broken.

      Why not e-mail me directly as well as posting here: dave pragprog.com

      Cheers

      Dave

    3. Re:Good/bad points by PragDave · · Score: 2, Informative

      Please drop me an e-mail (dave pragprog.com) and let me have them: I'll fix up any you find.

      Cheers

      Dave

    4. Re:Good/bad points by Anonymous Coward · · Score: 1, Insightful

      Hi, Dave is it possble to make any version 2.X (of the book, not ruby) available to people who buy the 2.0 version of the PDF (without having to pay again)?
      I liked to have the corrected versions. TIA

  12. Eager to have this book by rolling_bits · · Score: 4, Informative

    Many of us, Rubyists, have been introduced to Ruby by the very first version of this book. And the first version is online and is still handy for consulting:
    http://www.ruby-doc.org/find/pickaxe

    But this new version covers all the changes from Ruby 1.6 to Ruby 1.8; making this book a must have.

    As far as I know, it's available as PDF and as paper, and I'm gonna have both.

    Thanks Dave for helping the occident know Ruby and Matz for creating the must inspiring language for me.

    Cheers!

    1. Re:Eager to have this book by davegaramond · · Score: 1

      Second that. Sometimes I'm scared to think that we might dismiss Ruby because there are no good English books about it. It was this book (and the freeing of it to the Internet) that started it all. So, thanks Dave and Andy!

  13. Too many new languages at once... by Doesn't_Comment_Code · · Score: 2, Interesting

    I have to admit I've never tried Ruby. I use C++, Perl and PHP all the time. I just got started learning Python because of a book review I saw here on Slashdot. In fact, I also got interested in Python because someone suggested I use it to solve a problem that needs extensive parsing (Perl strength, nightmare in C++) and large, pointer-addressable arrays of objects(C++ strength, Perl weakness).

    Anyway, I was told Python was a good compromise. I've just started into it, but maybe Ruby is a better fit for this problem? I can only learn so many languages at once, and still have time for my projects.

    Can I get any advice? Is Ruby really "more powerful than Perl and more object oriented than Python" - is this what I'm looking for, or should I put it off and learn Python first?

    --

    Slashdot Syndrome: the sudden, extreme urge to correct someone in order to validate one's self.
    1. Re:Too many new languages at once... by tcopeland · · Score: 4, Informative

      > Ruby is a better fit for this problem?

      There's a good C2 Wiki page on this - PythonVsRuby.

    2. Re:Too many new languages at once... by Vaevictis666 · · Score: 1
      I can't say I've delved too deeply into Python, but I know enough of it to read it. I'd recommend that you look at the web version of the 1st edition of this book (linked above in a few comments) and just browse through the first section on syntax.

      As far as I am aware, the guts are about comparable (though anecdotal evidence suggests faster runtime with python) but I much prefer Ruby's syntax. A few of the constructs are really really nice, such as code blocks. Plus, it's much more consistent in the OO department - python (and php5) are half-OO, meaning there's OO stuff, but you still have functions like strlen which are (presumably) based off of the root Kernel object... In Ruby you have the object you want to find stuff out about do the check itself - mystring.len is all it takes.

    3. Re:Too many new languages at once... by Doesn't_Comment_Code · · Score: 0, Troll

      Thanks, I just looked at that page, and it has a lot of info. I still can't decide which to use though. The page suggests Python is easier to learn if you like C (which I do), and Ruby makes more sense if you like Perl (which I do also).

      I hope I don't have to learn them both before I can make a decision, but maybe I'll have to.

      --

      Slashdot Syndrome: the sudden, extreme urge to correct someone in order to validate one's self.
    4. Re:Too many new languages at once... by jonastullus · · Score: 2, Informative

      at the risk of being totally flamed by all the ruby followers out there:

      i have for quite some time now been programming in python and it just works like a CHARM!!
      i used to be so proud of my perl skills, but at some point i just felt dirty using perl and once i had started with python there DEFINITELY was no turning back! (well, maybe for a few-line regexp script...)

      from what i have gathered about ruby, the distinction between ruby and python is really slight! the syntax of ruby is VERY similar to that of python and python's object orientation is really decent.
      so in case you have already started into python i wouldn't swap for ruby, but as i said, the difference seems rather marginal to me, so it doesn't make that much of a difference.

    5. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      Is Ruby really "more powerful than Perl and more object oriented than Python"

      There nothing you can write in Ruby that you can't write in Perl. So by no definition is Ruby "more powerful" that Perl.

    6. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      in python as of 2.4 everything is ano object, too, even if it shows some of his history in things like len(sequence) for sequence.length or type(foo) instead of foo.class.
      Just subtle differences, anyway.

      Both ruby and python are beatiful and powerful languages,it just happens to me that the former fits my brain better than the latter, but YMMV.

      ruby vs perl is a a different comparison, ruby has a much more clean appearance than perl, and perl6 appers to have stolen^Wlearned lots of things from it. ruby's text processing capability are as strong as perl's cause they were stolen^W inspired from it, but they come in a more elegant cloath, imo.

      I suggest you to try ruby, it will take you little time to learn, and it *may* be an eye opener for you.

    7. Re:Too many new languages at once... by cmowire · · Score: 4, Interesting

      No, there is a difference. It's a mistaken notion that Ruby is like Python meets Perl.

      It's more like Smalltalk + Regular Expression + Incidental Other Goodies + Culture.

      I've tried both, and I like Ruby far more than Python. Ruby is an incredible language that tends to enable really simple, yet sophisticated code. When people talk about the Ruby Way, they aren't kidding. Ruby is endearing to me in ways that Python never was.

      Ruby and Python are both drinking from the smalltalk fountain, but they are still very different. Ruby plows head-on into more functional-programming types of paradigms while still using objects.

    8. Re:Too many new languages at once... by AuMatar · · Score: 1

      I'd suggest downloading some C or C++ libraries for string parsing. Rolling your own is a pain, but there's regular expression libraries that will give you all the strength of perl's. In fact, its a little known secret but glibc has C regular expression functions built in. Here's some documentation.

      Really, unless a language brings in a completely new way of programming (functional vs procedural, for example), the time spent learning a new language is usually a waste. Odds are 90%+ that you can either buy or download a library in a language you already know, and learning an API is a lot quicker than learning a new language. The new languages really don't increase the ease of programming, especially not compared to using a language you're already comfortable in. Programming would be a much more advanced art if people stopped pretending the new language will be a silver bullet and instead worked on producing good libraries and APIs for existing languages.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    9. Re:Too many new languages at once... by ultrabot · · Score: 1

      Ruby plows head-on into more functional-programming types of paradigms while still using objects.

      Err, like first class functions for example? Or list comprehensions?

      It's funny, Ruby programmers never seem to know what functional programming really means. It must be some widely spread misconception within the Ruby community...

      --
      Save your wrists today - switch to Dvorak
    10. Re:Too many new languages at once... by CatGrep · · Score: 4, Insightful

      Can I get any advice? Is Ruby really "more powerful than Perl

      That's really difficult to quantify. How do you define 'more powerful'?

      Personally, I prefer Ruby's clean syntax to Perl's (especially when compared to OO programming in Perl, which is just a disaster from an aesthetic viewpoint, as well as the amount of work that is required from the Perl programmer to do OO). There are a few features that Ruby has that Perl doesn't: continuations, code blocks and exceptions.

      and more object oriented than Python" - is this what I'm looking for, or should I put it off and learn Python first?

      This tends to be an area where there is a lot of dispute between the two camps. I've already revealed my bias toward Ruby, so take that into consideration regarding the following comments: In Python I get the feeling that object orientation was tacked on. Granted it was tacked on much earlier in the language's development than it was in Perl where OO programming is essentially a do-it-yourself project. There are a couple of nagging issues in Python which give me this idea:
      1) why do I need to include 'self' as the first parameter of each method definition?
      2) In Python people tend to prefer, for example, to find the length of an array by saying:
      length( array ) instead of array.length (the latter being the way you would do it in Ruby). Of course Pythonistas are now screaming that you can also say: array.__length__ (or something similar) in Python as well.

      Python now also has something similar to Ruby's iterators (though they're a bit different), but something to keep in mind is that Ruby's standard libraries and built-in classes were built from the ground up with iterators in mind - I think that's a big advantage that Ruby has over Python.

      I suggest that you try to write a smallish program in each language (pick a project that might take an hour or two) and see how each language 'fits' with the way you think. I find Ruby fits my way of thinking much better than Python does, but as they say, YMMV.

    11. Re:Too many new languages at once... by fredrikj · · Score: 2, Informative
      It is not true that Python is "half-OO", at least by the merit of your argument. Finding the length of an object is done by calling a method:
      >>>"bla".__len__()
      3
      >>>class Foo:
      ... def __len__(self): return 5
      >>> Foo().__len__()
      5
      You can also do len(Foo()) or len("bla"), and although I agree that the existence of this legacy function makes the language less consistent I fail to see how it makes it any less OO.
    12. Re:Too many new languages at once... by ultrabot · · Score: 1

      The page suggests Python is easier to learn if you like C (which I do), and Ruby makes more sense if you like Perl (which I do also).

      Python is widely seen as the one that is easier to learn. Just learn it first, learning Ruby afterwards is trivial if you feel like it. The languages are extremely similar on most points.

      --
      Save your wrists today - switch to Dvorak
    13. Re:Too many new languages at once... by rolling_bits · · Score: 2, Insightful

      Yes, you could keep punching cards or writing asssembler. Or maybe, write C or Java. Or... You could use Ruby and build your programs and libraries in a special way, that makes them concise and much more maintenable. That way instead of creating one program per year, you could create one per week, and keep improving them as needed. You are not free from creating your own libraries, though. You are even encouraged to. And it's much easier to create a library in Ruby than in other languages. The payoff is that *you* will have the library *soon*. I could say that in other languages either you find a library to do what you want, or you are sold. With Ruby, you don't even think. You create the library right away. Though we don't need to write all the libraries necessary for our programs, because I think that Ruby has advanced from being used by early adopters to being used by application developers. See this article by Eric Sink, for example: http://software.ericsink.com/Act_Your_Age.html Cheers!

    14. Re:Too many new languages at once... by baka_boy · · Score: 3, Informative

      Ruby has first-class functions; you just have to disambiguate them syntactically, since bare property access (like foo.bar) is actually calling method bar on the object foo. So, if you want to reference the method explicitly, you have to write foo.method(:foo), which returns a Method instance which can be invoked or used like any other scalar value.

      So, while in Python, you might write something like this:
      controller.set_handler('some_action', myObject.handle_some_action)
      ...the Ruby idiom would be one of the following:
      controller.set_handler('some_action', myObject.method(:handle_some_action))

      -or-
      controller.set_handler('some_action') { myObject.handle_some_action }

      The extra method(...) syntax is needed to ensure that all communication between objects is via method calls, rather than direct property access. Python allows you to directly assign to and read from object attributes, much like public members in C++ or Java classes. Ruby forces all attribute access to be wrapped in get/set methods, but provides a lot of support to make implementing those methods effectively automatic.

      The latter example also uses a code block, cover many cases where first-class functions would be otherwise -- they're basically a compact syntax for lambda expressions, and prevent you from needed sugar like list comprehensions in most situations.

      For example, instead of the following Python list comprehension:
      [x*2 for x in myArrayOfValues if x % 3 == 0]

      ...you would use this:
      myArrayOfValues.map {|x| x*2}.find_all {|x| x % 3 == 0}

      Blocks are also a general idiom used throughout the standard library and most Ruby code in the wild. You can use them to write callbacks, query databases, and even to build domain-specific languages (another traditional stronghold of functional languages).

      Really, though, neither Ruby or Python is a truly functional language; both borrow from the more "academic" languages those features and concepts they find useful, and leave behind those that the maintainers and users don't want, need, or understand. (Except for continuations, of course -- Ruby has those, and I would guess that only a very small percentage of Ruby coders ever grok them.)

    15. Re:Too many new languages at once... by Anonymous Coward · · Score: 0
      Err, like first class functions for example? Or list comprehensions?


      Well, Haskell has to be better at *something*. ;)

    16. Re:Too many new languages at once... by fredrikj · · Score: 2, Informative
      1) why do I need to include 'self' as the first parameter of each method definition?
      It's nicer for unbound methods, and makes calls to superclass methods clearer. This is also answered in the Python FAQ.

      2) In Python people tend to prefer, for example, to find the length of an array by saying:
      length( array ) instead of array.length (the latter being the way you would do it in Ruby). Of course Pythonistas are now screaming that you can also say: array.__length__ (or something similar) in Python as well.
      See my previous post in this thread. I agree that this is something of a wart, but a minor one.

      As for Ruby vs. Python, I don't think it's a big deal as they are similar in many ways. If you're comfortable with either language, there's probably no need to switch to the other. Myself, I don't think the higher level of consistency in Ruby's object system offers any practical advantage, and find Python's syntax much nicer. Haven't seen anything particularly interesting in Ruby that isn't also in Python.

      Indeed, if I had discovered Ruby before Python, it's quite possible that I would've stuck to that instead.
    17. Re:Too many new languages at once... by MetalNoise · · Score: 2, Insightful

      I know both languages, although I know Python better. I first learned Ruby and then switched to Python. In many ways I think both languages fit the same niche. They both make many tasks easier and you really can't go wrong with either. If you started with Python I would stick with it. You'll never regret knowing Python well. For me, Python offered 1) more bindings to existing "C" libraries. 2) a bigger community with more support. Ruby is pretty decent in both 1) and 2) also, just not as far along (I'm about 2 yrs out of the loop though). In many ways the languages are similar. Some major differences are: Python: list comprehensions, generators. Ruby: blocks, cleaner OO, more complete closures, continuations. By the way, both languages helped me realize that you can do many things easier and cleaner without OO techniques. Both languages have a bit of a functional side to them and I find this to be one of their stronger attributes.

    18. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      There nothing you can write in Ruby that you can't write in Perl.

      And then someone mentioned threads, mutexes, thread queues and synchronization and the game was up.

    19. Re:Too many new languages at once... by xteddy · · Score: 3, Interesting
      You don't have list comprehensions in SML. Last time I checked, this was still a functional language.
      The comp.lang.functional FAQ says
      Functional programming is a style of programming that emphasizes the evaluation of expressions, rather than execution of commands. The expressions in these language are formed by using functions to combine basic values. A functional language is a language that supports and encourages programming in a functional style.
      Actually Ruby only has expressions, so it seems to be a pretty good candidate. You can also create functional objects and use them as arguments:
      def add(x, y) x + y end

      (1..10).inject &method(:add) # => 55
      The same in Common LISP, also a functional programming language:
      (defun add(x y) (+ x y))

      (reduce #'add (list 1 2 3 4 5 6 7 8 9 10)) ; => 55
      Doesn't look so different, does it?
    20. Re:Too many new languages at once... by cmowire · · Score: 2, Informative

      Notice I said "functional-programming types of paradigms", not functional programming.

      It does have first-class functions (the Proc class) it's just that the syntax is driven towards making closures accessible instead of functions and creating Procs is a lot more involved.

      On the other hand, what they do with the closures (a.k.a. Code Blocks) is quite amazing on its own merits. The concept of being able to iterate over arbitrary stuff in a variety of ways with them comes in quite handy, plus all of the other ways to make the language easier to deal with.

      And, then of course, there's the functional library. ;)

    21. Re:Too many new languages at once... by binary42 · · Score: 1

      The only thing I can come up with right off the bat is: continuations. I don't recall perl being able to do that.

      --
      ruby -le"32.times{|y|print' '*(31-y),(0..y).map{|x|~y&x>0?' .':' A'}}"
    22. Re:Too many new languages at once... by AuMatar · · Score: 1

      A new language gives no additional power, at a large cost of time to learn the language. The limiting factor of programming isn't what the language can express- every Turing complete language has the same expressivity. The limit is the amount of work you can reuse- the amount of library code that already exists. And there's more library- and equally important, those libraries are better tested from real world use- in older languages.

      Changing languages might earn you geek points on /., but it doesn't solve any problems. What DOES solve problems is creating reusable abstractions that handle the issue you need. Changing languages is just overhead to the process.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    23. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      Haven't seen anything particularly interesting in Ruby that isn't also in Python.

      How about continuations? How about two different kinds of exceptions (real exceptions, and catch/throw nonlocal flow control)? How about code blocks? How about "open" classes that you can extend after they are declared?

      Sure, if you don't see the difference between Ruby and Python, you probably won't USE any of those things, but it's not true that Python and Ruby are almost the same.

      I wish Python had blocks (or rather, I used to wish), so I could do stuff like (made-up syntax):

      with_open_file('/tmp/file')(f):
      f.write('hello, world')
      or
      with_busy_cursor():
      foo()
      bar()
      baz()

      That's what blocks let you do. Not as powerful as Smalltalk or lisp macros but pretty nice. I don't think it's hard to add this to Python since you can do the above with named functions, just not arbitrary blocks/closures.

    24. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      In Python I get the feeling that object orientation was tacked on [...] why do I need to include 'self' as the first parameter of each method definition?

      Because that's what is really being passed around and is exactly the same way that other OO languages (like C++) work. In C++, the first parameter to a member function of a class is the pointer to the class itself, which becomes exposed through the "this" pointer. C++ programs are effectively translated to straight C by the precompiler anyway - how's that for "tacked on"? In most implementations it's completely hidden.

      In some ways, the Python solution is quite elegant because it's going to be the exact same interpreter code path for receiving member function calls as receiving non-member calls.

    25. Re:Too many new languages at once... by Jerf · · Score: 2, Informative
      There are a couple of nagging issues in Python which give me this idea:

      Here's how I think people should evaluate Python vs. Ruby:
      1. Run Python, downloading it if necessary.
      2. Run a Python shell (OS-dependent).
      3. Type "import this", and read it.
      If everything speaks to you, as it does me, than try Python first. Otherwise, try Ruby. I'll leave a Ruby-ist to explain the exact differences.

      I can give a couple of the differences, though; mostly, the differences between the languages and capabilities are philosophical. Ruby has more "purity", Python says "Although practicality beats purity." (although with a strong cultural understanding that purity isn't worth tossing away as Perl seems to). Python also thinks "Readability counts.", Ruby seems more interested in making the syntax always concise. I'd much rather read a Ruby program than a C++ program, but the Python one will look more like pseudo-code with real English words, and Ruby will have a bit more syntax. Python has no culture of saving keystrokes and such things are usually considered a joke when the topic comes up, as are various language comparision benchmarks that incorporate that as a measure. (Typing speed is very, very rarely the constraint on programming speed.)

      Which is right? Well, it mostly depends on what you want.
    26. Re:Too many new languages at once... by rolling_bits · · Score: 1

      This kind of "indifference" to Ruby from Pythonists is understanble. The worst that can happen is that they will miss the language that they should be using for another 3 years. And no, they aren't interchangeable. Ruby is not perfect, and neither is Python. There is still room for improvements, so in 3 years a lot may change, maybe making the gap even bigger and more easily noticeable.

    27. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      I've been programming for over 20 years, from assembly language to c/c++ to delphi/pascal to cobol (yuck) to perl and a few others.

      I recently evaluated "get shit done really fast, but make the code readable next year" languages and chose Ruby over Python and Perl.

      If you haven't invested a lot of time into Python yet, then I think Ruby is cleary the better choice. The only way to tell is to dabble in both and see which one makes you more productive (assuming productivity is your goal).

      Ruby Pros:

      1. true OO. even numeric literals are objects with methods
      2. blocks and closures. once you try blocks & closures, you will HATE languages that don't offer them
      3. super easy to use c/c++ libraries.
      4. very friendly and helpful community. the newsgroup and irc channel are full of people willing to help noobs.
      5. most importantly, my productivity and enjoyment of programming is the greatest when I use Ruby--it might not be this way for others but this is the reason I use Ruby 1.8.

      Ruby Cons:

      1. Confusing release management. I don't think there's an official release manager to oversee releases of Ruby. For example, I'm using Ruby 1.8.2 stable-snapshot right now, but Ruby 1.8.2 hasn't been officially released yet. This is simply lame and there's no excuse for making us choose between a nightly snapshot and an 1+ year old buggy release.

      2. Speed. You pay for convenience. Features that double of triple my productivity as a programmer cost extra CPU cycles to provide compared to other interpreted languages that offer reduced productivity. And you can't compare Ruby's speed to compiled languages like c, c++ or delphi because they're not even in the same ballpark.

      3. Almost non-existant job opportunities for Ruby programmers in USA compared to most other languages. Since programming is getting rapidly outsourced anyway, this might not matter in a few more years when salaries drop from $60,000/year average to around $20,000/year. I think American programmers will either be working for themselves (in which case they choose their language) or program as a hobby rather than full-time work.

      4. (Temporarily?) Smaller size of English-speaking community compared to Perl or Python but growing rapidly thanks to recently published English-language Ruby books. In Japan, Ruby is already more popular than Python.

      5. (Temporarily?) Fewer number of open-source Ruby applications or libraries than Perl (CPAN will be unbeatable for years) and Python. However, these sites are creating pretty rapid growth in the number of Ruby projects (but don't expect CPAN-like number of projects for at least a few years):

      http://www.rubyforge.net
      http://raa.ruby-lang.o rg

      This ruby package management project is also helping to fuel the boom:

      http://rubygems.rubyforge.org/wiki/wiki.pl

    28. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      If everything speaks to you, as it does me, than try Python first

      When I first used Python, I was hungry for exactly what that text describes.

      However, Python doesn't live up to any of those things. The code is cluttered with parens and underscores. Punctuation is used where it isn't needed (next to space or other punctuation), and isn't used where it would enhance readability (list comprehensions for instance).

      Python claims "one way to do it" but offers two distinct ways of forming classes, old-style and new-style. It offers methods as well as "builtins" which look like functions. They don't seem to be aliases, they are just two different things.

      Python's "explicit" philospohy just means: more keys to press.. "def foo(self):" where "def foo" conveys the same meaning. Regular expressions as methods and classes, rather than thread-locals like "$1", "$2" to make code shorter and more readable (regular expressions aren't even first-class syntax objects, so it's not like they are readable to begin with).

      If python is so "explicit" why do I need 5 lines and the "imp" module to import an arbitrary pathname (something I struggled with writing a unit test runner just recently).

      Why does python insist on getting in my way?

    29. Re:Too many new languages at once... by xteddy · · Score: 2, Insightful

      Following this logic and given there were enough libraries for brainfuck available, we could program everything in brainfuck as well?

    30. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      you speak like a politician, you're full of rhetoric but give no meat and potatoes examples. can you list two comparable code snippets comparing how ruby shines against python?

    31. Re:Too many new languages at once... by fredrikj · · Score: 1

      How about continuations? How about two different kinds of exceptions (real exceptions, and catch/throw nonlocal flow control)?

      Except for escape continuations, which Python support through exceptions, I really don't see the use. Maybe I don't "get it" because I've never made myself appreciate them through writing a program where they solve a problem. Feel free to enlighten me.

      How about "open" classes that you can extend after they are declared?

      Python supports this. Just create a class and add new methods to it as you go along, if you really need to.

      Blocks are more useful, but basically just syntax as indeed you can do the same by passing lambdas or named functions.

    32. Re:Too many new languages at once... by arkanes · · Score: 1
      1) why do I need to include 'self' as the first parameter of each method definition?

      Several reasons: requiring the explicit parameter fits a Python Zen concept (explicit is better than implicit), it avoids adding a new keyword to the language (you can call self whatever you want) and it supports these features when you you have things like class methods.

      2) In Python people tend to prefer, for example, to find the length of an array by saying: length( array ) instead of array.length (the latter being the way you would do it in Ruby). Of course Pythonistas are now screaming that you can also say: array.__length__ (or something similar) in Python as well.

      array.__len__(). The double underscore convetion is really widely used in python, and the global level functions that wrap them are a common Python idiom. They're the Python version of Java Interfaces (you can iterate over anything that implements __iter__, you can convert to a string anything that implements __str__, etc. You can get the length of anything that implements __len__). I don't see this as tacked on OO, I see this as a very powerful way of integrating objects. As an excellent example, you can call anything that implements __call__, using the standard () syntax (I understand Ruby has a similiar concept).

    33. Re:Too many new languages at once... by AuMatar · · Score: 1

      I don't know too much about Brainfuck, is it Turing complete? If so, yes. But I don't think it has the necessary mass of existing libraries and users. But if someone who mainly used Brainfuck had a problem, I'd point him to look twoards solving it in Brainfuck rather than switching languages as a solution.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    34. Re:Too many new languages at once... by Kristoffer+Lunden · · Score: 1

      The two big reason I'm not using ruby much is:
      * No CPAN (RAA and Rubyforge does not compare)
      * No community even close to the one Perl has

      Really, ruby is super sweet, but for productivity and getting things done, those above things are really, really important. And since Perl is a great language too, it wins out every time.

      Python... I never got what was so great about it. It feels limited and limiting in so many ways, although I suppose it is easy in a "one way only" kind of way. This is one of the things that probably boils down to taste and taste alone.

      Ruby is wonderfully crystal clean in its syntax, yet powerful and it doesn't feel at all limiting. Perl is a bit more obscure at times, although if you think of it as a natural language, the pieces fits quickly.

      I'd be hard pressed to choose. However, if Parrot could just get out the door, maybe I could finally try ruby + CPAN. That might just be heaven. ;-)

    35. Re:Too many new languages at once... by wtd · · Score: 1

      array.__len__(). The double underscore convetion is really widely used in python, and the global level functions that wrap them are a common Python idiom. They're the Python version of Java Interfaces (you can iterate over anything that implements __iter__, you can convert to a string anything that implements __str__, etc. You can get the length of anything that implements __len__). I don't see this as tacked on OO, I see this as a very powerful way of integrating objects. As an excellent example, you can call anything that implements __call__, using the standard () syntax (I understand Ruby has a similiar concept).



      I think the Ruby take on this, and my own feeling, is that this represents an unnecessary level of abstraction.



      Why use len(array), which calls array.__len__(), when you can just call array.length() and skip the extra step? In a language that doesn't statically type variables, this doesn't make things any less flexible. "array" could be of any type, and as long as it has a "length" method, everything's fine.

    36. Re:Too many new languages at once... by arkanes · · Score: 1

      For the casual programmer, they work exactly the same way. The Python way allows for more syntatically correct exceptions to be thrown. Trying to use the various interface wrappers will generate TypeError exceptions, while trying to call non-existant methods will generate AttributeError exceptions.

    37. Re:Too many new languages at once... by xteddy · · Score: 1

      Yeah, sure it is turing complete. It also has a self -hosted interpreter, that's of course always a sign of a rather mature language.
      You seem to be stuck in the Turing Trap. That can easily lead to another verification of Greenspuns 10th Rule of Programming. Try to find out how to beat the averages, please.

    38. Re:Too many new languages at once... by wtd · · Score: 1

      Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> class Foo:
      ... pass
      ...
      >>> len(Foo())
      Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      AttributeError: Foo instance has no attribute '__len__'
      >>>

      It doesn't appear that len() intercepts AttributeError exceptions and reraises them as TypeError exceptions.

    39. Re:Too many new languages at once... by SyntheticTruth · · Score: 1

      > 1) why do I need to include 'self' as the first parameter of each method definition?

      I was *just* discussing this a few weeks ago with a friend. I *like* that python enforces the 'self' syntax. Where in other languages, like C++, 'this' is just there. For someone *reading* python code, you *see* where 'self' is given, not having to guess where it came from.

      Not sure if Ruby allows this, but using that syntax then allows me to also call the Class directly, using my Instance as an argument *if* I need to for some reason.

      Keep in mind, I have never really looked at Ruby, but I am interested, but the above is something that I have, over the years of learning python, have come to enjoy about it.

    40. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      I *like* that python enforces the 'self' syntax. Where in other languages, like C++, 'this' is just there. For someone *reading* python code, you *see* where 'self' is given, not having to guess where it came from.

      I don't think this is a very good argument. Once you learn what "self" means, there's no guessing. It's not as though the rest of the language is instantly learned. Having an implicit "self" reference just happens to be part of Ruby and is simple to learn. I mean, I didn't know what the hell "lambda" meant when I first saw it, butI learned; now I just remember that it's a synonym for proc. Simple.

    41. Re:Too many new languages at once... by Tellalian · · Score: 1

      Is Ruby really "more powerful than Perl and more object oriented than Python"

      In regards to Python's OO design, this was perhaps true when Ruby was first envisioned. At that time, Python's object oriented features were indeed just being implemented, much as an after-thought as Ruby's creator complains. However, with the release of Python 2.3, the paradigm of "everything's an object" has been adopted. So no, today Python and Ruby are at least equally object oriented, so I wouldn't let that be a factor. Personally, I prefer Python's attention to whitespace as it results in cleaner, more uniform code.

    42. Re:Too many new languages at once... by bgs4 · · Score: 1

      A program that requires a lot of parsing is the perfect example of why python is superior to ruby. Google "ruby parsers" and "python parsers". For ruby, it's not clear exactly what is available, maybe there's one good hit. For python, on the other hand, there are a ton of different parsers available. The third google link is a list of like twenty of them. There's c-based ones, python-based ones, GLR, LALR, etc., and many of them are very mature.

      Maybe it's cool that in ruby you don't need "self" and you can say "arr.length()" rather than "len(arr)" (or whatever the syntax is) etc., etc., but the fact is that when you want to actually get something done, python has much more available for it. The languages themselves, in the grand scheme of things, are pretty much the same.

    43. Re:Too many new languages at once... by mccoma · · Score: 1
      >>>"bla".__len__()
      Why the underscore ( _ ) characters?
    44. Re:Too many new languages at once... by AuMatar · · Score: 1

      No, you seem to be into the silver bullet trap. You seem to think solving languages will actually help. It doesn't. Learning a new language takes time, for little to no gain. There's nothing you can't do in Java, C, C++, perl, etc you can't do in another with a simple donload of a library. SO do it in the one you know best, and make it reusable so yourself and others don't have to do it ever again. It is more efficient this way.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    45. Re:Too many new languages at once... by JamesOfTheDesert · · Score: 1
      , but the Python one will look more like pseudo-code with real English words

      None of my pseudo-code has "self" everywhere, nor frequent use of underbar characters.

      I tried Python, and it felt forced, not practical, as if purity were indeed the main point.

      Even with the compulsary indentation I find Python hard to read, as there is a lot of syntax one has to read past. Persoanl preference, I guess, but Ruby is easier to read and write.

      --

      Java is the blue pill
      Choose the red pill
    46. Re:Too many new languages at once... by arkanes · · Score: 1

      It's actually a property of the base object class.
      Try this:
      Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> class Foo(object):
      ... pass
      ...
      >>> len(Foo())
      Traceback (most recent call last):
      File "<input>", line 1, in ?
      TypeError: len() of unsized object
      >>>

    47. Re:Too many new languages at once... by rffrff · · Score: 1

      myArrayOfValues.map {|x| x*2}.find_all {|x| x % 3 == 0} I'd do: ary.map {|x| x*2 if x %3==0}.compact

    48. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      The new languages really don't increase the ease of programming, especially not compared to using a language you're already comfortable in.

      I have used C for over 20 years, for writing everything from device drivers and kernels to libraries and applications.
      Python (one of the "new languages" that you dismiss) has most definitely increased the ease with which I program libraries and applications.
      (It is less useful for device drivers and kernels.)
      It is a great prototyping language, even if I later recode to C, C++, or whatever.

    49. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      C++ programs are effectively translated to straight C by the precompiler anyway

      That's not the case for modern C++ compilers. It's extremely difficult or impossible to compile things like templates into C with any degree of efficiency.

    50. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      A semantic (ie, intended-as-information-to-programmer) hack to distinguish "special" methods you shouldn't call from code, since Python doesn't have true private methods.

    51. Re:Too many new languages at once... by mccoma · · Score: 1
      Thanks for the information, but does that mean I shouldn't call "bla".__len__() because it is private? Why is len private?

    52. Re:Too many new languages at once... by wtd · · Score: 1

      Does this work because object provides a default implementation of __len__(), which raises a TypeError?

      I'm not sure I'm fond of this regardless of how it's implemented. The AttributeError or NoMethodError (in Ruby) clearly indicates a missing method. The "len() of unsized object" I'm sure has meaning to an experienced Python programmer, but it seems like handling errors is the wrong place for abstraction. :-)

    53. Re:Too many new languages at once... by jovlinger · · Score: 1

      things with __ in the name have special syntax shortcuts.

      len(foo) -> foo.__len__()

      a = foo[bar] -> a = foo.__gettitem__(bar)

      a = foo.bar -> a = foo.__getattr__('bar')

      Foo() calls Foo.__init__(new Foo object)

      The __ methods allow you to override how an object behaves; the same object can be a method, a dictionary, and have instance variables.

    54. Re:Too many new languages at once... by fredrikj · · Score: 1

      All the standard methods with leading and trailing double underscores are those which provide functionality available through some other syntax (calling, iteration, constructing the object, etc). Think of len() as an operator, a syntactical interface for .__len__(), like + is the syntactical interface for .__add__(). These methods are only private in the sense that there is a more standard way to access them. If you want to call them directly, which is sometimes useful, you can do that.

    55. Re:Too many new languages at once... by Anonymous Coward · · Score: 0
      things with __ in the name have special syntax shortcuts.

      len(foo) -> foo.__len__()

      Um, this is dumb. If you just had foo.len(), you wouldn't need the inconsistent "shortcut" in the first place!

    56. Re:Too many new languages at once... by Tellalian · · Score: 1

      2) In Python people tend to prefer, for example, to find the length of an array by saying: length( array ) instead of array.length (the latter being the way you would do it in Ruby). Of course Pythonistas are now screaming that you can also say: array.__length__ (or something similar) in Python as well.

      The underscores are invaluable in securing a "utility" namespace in which Python can continue to evolve new basic functionalities without compromising backwards compatibility. Suppose Python didn't use this notation, and that these basic functions were accessed as array.len(). What happens when the developers want to introduce a slick new feature, such as iterators? You could use array.iter(), or array.iterator(), but there are good odds someone is already using this notation. However, with a utility-specific namespace the developers could introduce array.__iter__() and continue Python's evolution without worrying about breaking someone's code.

    57. Re:Too many new languages at once... by Anonymous Coward · · Score: 0

      Changing languages might earn you geek points on /., but it doesn't solve any problems.

      Yes it (sometimes) does. Do you know the Sappir-Whorf hypothesis ? It states that the (natural) language we use affects the way we think. It's exactly the same with programming languages. If it's difficult to use some structure in a language, speakers of this language most likely won't use this structure, and will find another way. A language may be "more powerfull" than another not because it allows more computations, but because it makes them easier or more natural.

      For on-topic example, Ruby is an Object Oriented language, so you naturally can code mostly like with Java, but it includes some functional elements, in a way that makes them natural to use. What you could spend ten minutes to code, you now spend one to code. Doesn't solve more computing problems, but solves many coding problems.

    58. Re:Too many new languages at once... by Merk · · Score: 1

      Come back to the loop. A lot has changed in two years, including the release of Ruby 1.8. The community is pretty big now, and every day there are more and more bindings to C libraries, etc. With Ruby Gems and RPA there are also much better and easier ways of packaging the various libraries and extensions.

      Overall though, I think your assessment of the core of Ruby vs. Python is correct. They're essentially aimed at the same niche, and now that Python is finally cleaning up some of its non-OO cruft, the languages are even becoming more syntactically similar. It's more a matter of what fits for you. Ruby fits for me, and for a growing number of other people.

    59. Re:Too many new languages at once... by Merk · · Score: 1

      Having to include 'self' as the first parameter to method calls in Python is one of the biggest reasons I hate using it. Most of their reasons for why they require it as a parameter are really weak. It could just as easily be a language keyword. As it is, calling that first parameter 'self' is just a convention. I've been known to deviate from that convention just because it annoys me so much.

      I found Python first, and used it without too much unhappiness until I found Ruby. When I found Ruby, there was no turning back. Mostly the problems with Python are small warts, but there were enough of them to really bother me. These days, when I'm forced to use Python, I'm not too unhappy, but I still keep wishing I could use Ruby instead.

    60. Re:Too many new languages at once... by jovlinger · · Score: 1

      alas, the idiom is for len to be used like so:

      len(foo)

      not

      foo.len()

      you can of course implement the latter if you wish, but then you can't pass objects of your class to methods expecting a list.

  14. Note that the Ruby standard library docs... by tcopeland · · Score: 2, Informative

    ...are also available on ruby-doc.org here.

  15. Poignant vs Pragmatic by weston · · Score: 4, Informative

    Why's Poignant Guide to Ruby has got to be the most entertaining Ruby read out there....

    1. Re: Poignant vs Pragmatic by ClarkEvans · · Score: 1

      "Why The Luck Stiff" rocks.

    2. Re: Poignant vs Pragmatic by ClarkEvans · · Score: 1

      Seconded. The author, "Why The Lucky Stiff" is quite a clever fella.

    3. Re: Poignant vs Pragmatic by Rysc · · Score: 1

      I'll go a step further: It's the best intro to programming I've ever seen.

      Okay, the best non-traditional intro. Maybe in the long run it would be less helpful than a standard (Programming C-style) introduction, but I doubt that.

      --
      I want my Cowboyneal
    4. Re: Poignant vs Pragmatic by Lerxst+Pratt · · Score: 1

      As one who has read Why's Poignant Guide from start to finish, I will agree with the parent post. This guide is exceedingly funny while being instructional as well. I guarantee you will not get bored learning Ruby while using this guide. Contrary to "Pragmatic" (which I just ordered, BTW), Poignant is well-suited for beginners as well. I have never in my life been so entertained pursuing anything worth studying as I have with Why's Poignant Guide to Ruby. If you're new to Ruby, do yourself a favor and check it out. Peace!

    5. Re: Poignant vs Pragmatic by Anonymous Coward · · Score: 0

      Chunky.

      Bacon.

    6. Re: Poignant vs Pragmatic by killjoe · · Score: 1

      I have "The Ruby Way" and I really like it. It covers just about everything you are likely to need and is a good read.

      Ruby is a fun language that's for sure. Does anybody know of a decent J2EE like container for ruby? One that supports remoting complex objects via SOAP. I want to tie a ruby back end to a VB front end (for god's sake don't ask why).

      --
      evil is as evil does
    7. Re: Poignant vs Pragmatic by rbullo · · Score: 1

      That has to be the most well-written piece I have ever read, on any subject. I don't know how Why pulled it off, but he should be rewarded handsomely.

      May I suggest giving him a private island in the South Pacific?

      --
      OH NOES!!! IT APPEARS YUO DO NOT HAVE ENOUGH MONEY TO PAY FOR DIS HERE PIZZA! WAHT EVER ARE YOU GOING TO DO!?!?
    8. Re: Poignant vs Pragmatic by Anonymous Coward · · Score: 0

      remoting complex objects via soap! oops nevermind, I missed the fact that your work in VB too.

  16. Informative? by Anonymous Coward · · Score: 0

    Way to keep those eyes peeled, mods!

  17. Wendy's by skilljoy · · Score: 0
    ...Dave Thomas, a founding father of the English Ruby community
    He makes some pretty good cheeseburgers, too.
  18. Ruby + C == World Domination by Anonymous Coward · · Score: 2, Insightful

    Well not exaclty, but the combination of Ruby and C is unbelievably powerful.
    A graceful and dynamic OO language coupled with, well C - fast, portable (more or less) and used everywhere.
    Because it is so easy to go back and forth between Ruby and C you get the strengths of both languages (also all those C libraries out there).

    If you haven't used Ruby, your missing out to say the least - and this book is an excelent way to get started.

    1. Re:Ruby + C == World Domination by CatGrep · · Score: 2, Interesting

      mod the parent up!

      Ruby isn't the fastest language on the block, but it's so easy to write C extensions for a Ruby program. Usually only about 10 to 20% of your code is speed critical, so this allows you to write that small part of your code which is speed critical in C while writing the rest of your code more quickly in Ruby. Oh and there's a profiling module that comes with Ruby that will help you figure out where your code is spending it's time.

      I would also add that if you use Swig, it's quite easy to integrate your Ruby code with your C++ code. I tend to prototype in Ruby to get my design squared away, then I translate methods to C++ while all along using the same unit tests written in Ruby to make sure that everything is still functioning the way I intended.

    2. Re:Ruby + C == World Domination by Anonymous Coward · · Score: 0

      You don't even need swig (for C functions at least)!!

      Ruby comes with Ruby/DL which lets you load dynamic libraries AT RUNTIME and call into them. For me it's a "deal breaker".. I can't imagine using Ruby without.

    3. Re:Ruby + C == World Domination by orangepeel · · Score: 1

      it's so easy to write C extensions for a Ruby program.

      This is an honest question: how? Do you know of any good online examples or documentation of how to do this?

      --
      Whoever designed level 61 in Frozen Bubble is a sadistic bastard.
    4. Re:Ruby + C == World Domination by Anonymous Coward · · Score: 0

      Here is how to get started:
      Extending Ruby
      That is from the 1rst edition, I recommend getting the 2nd.
      Also take a look at the README.EXT (come with the ruby source code).

      Here are some helpful links (a bit more advanced):
      Ruby Source Code Browser
      Ruby C API Docs
      GC And Extensions
      Ruby Talk

      I must admit the learning curve for C extensions is a bit steap if you don't have experiance in either language. Also more tutorials are needed.

      -Charlie

    5. Re:Ruby + C == World Domination by Anonymous Coward · · Score: 0

      your missing out

      "you're".

    6. Re:Ruby + C == World Domination by Anonymous Coward · · Score: 0

      where your code is spending it's time

      "its".

    7. Re:Ruby + C == World Domination by orangepeel · · Score: 1

      Thanks!

      --
      Whoever designed level 61 in Frozen Bubble is a sadistic bastard.
  19. Dave Thomas by dfn5 · · Score: 2, Funny
    a founding father of the English Ruby community...

    ... and hamburgers

    --
    -- Thou hast strayed far from the path of the Avatar.
    1. Re:Dave Thomas by upsidedown_duck · · Score: 1

      .. and hamburgers ...and The Mutants Of 2051 A.D.

      --
      -- "Makes Little Debbie look like a pile of puke!" - Moe Szyslak
  20. Ruby and Perl over Python for cross-platform dev by Dystopian+Rebel · · Score: 5, Insightful

    I can live with Python's having no statement terminator (";" in C, C++, Perl, Java).

    What I find unacceptable in Python is that whitespace (tabs) determine the logical flow. I once wrote a script on Windows and moved it to UNIX; the UNIX editor handled tabs differently, and my script wouldn't work without a few hours of attention just to set the spacing right.

    Ruby has Pascal-like blocking. That alone makes it superior to Python. And for all other situations that do not require a good OO implementation, there is Perl.

    --
    Rich And Stupid is not so bad as Working For Rich And Stupid.
  21. Hope to buy book soon by davidross · · Score: 1

    Waiting was the hard part. Hopefully I can get a copy of the book soon. Great work.

    Ruby is a great language to program in and embed. Ruby and SOAP is a decent combination and anyone looking for a newlanguage, this is the language for you to try out. You'll get hooked on the great syntax, community, and Matz!

    Remember to check out your local copy of ruby stable-snapshot today!

    The online community has a mailing list and various channels on Freenode.

    #ruby-lang, #rpa, #rubymine, #rubyonrails, and more!

    Thank Matz and the other core devels.
    Ruby Power! ;)

    David Ross
    ------------------
    Hassle-free packages and package system
    http://rubyarchive.org/

  22. Comment removed by account_deleted · · Score: 0

    Comment removed based on user account deletion

  23. Re:REXX by transami · · Score: 1

    Funny you mention that. I'm a Ruby coder, but with a bent toward exploring languages. I've been thinking about learning a little REXX myself.

    Also I'm exploring K and R. But not C ;-) Ironic isn't it?

    For general programming language discussion try:

    https://lists.berlios.de/mailman/listinfo/suby-mus e

    Signed,
    Amiga Owner #51 ;-)

    --
    :T:R:A:N:S:
  24. Not as fast as others though ... by reborn · · Score: 1, Interesting

    I've written code in many, many different languages. I got interested in Ruby a long while ago but never bothered doing anything about it, then a few weeks ago I started looking into it seriously. After doing quite a lot of speed testing (in particular various mathematic statements) against PERL I found that Ruby usually took twice as long to complete an operation than PERL did, which was rather disappointing. However, IIRC Parrot is going to support Ruby so any speed concerns should be eliminated - maybe I'll dive in properly sometime :)

    1. Re:Not as fast as others though ... by CatGrep · · Score: 1

      I found that Ruby usually took twice as long to complete an operation than PERL did

      Perl is often faster than Ruby. However, if you compare OO Perl code with OO Ruby (well, in Ruby OO is pretty natural) you'll find that Ruby tends to be faster than OO Perl. So if you want to write object oriented code, you'll have some advantage with Ruby.

      Parrot is going to support Ruby so any speed concerns should be eliminated - maybe I'll dive in properly sometime :)

      There is a project called Cardinal that aims to produce a Ruby frontend for Parrot.

      Also, since it's quite easy to write C extensions for Ruby programs, you can easily speed up things by writing certain time-critical functions in C and then call them from Ruby.

    2. Re:Not as fast as others though ... by xteddy · · Score: 1

      Well, you should consider that Ruby's number tower supports arbitrary precision arithmetics with autoconversion, so you will never have an integer overflow in Ruby. I guess that Ruby's Bignum methods are faster than the Perl's Math::BigInt, while computing with smaller integers should be faster in Perl.

    3. Re:Not as fast as others though ... by Anonymous Coward · · Score: 0

      found that Ruby usually took twice as long to complete an operation than PERL did

      Are we talking 50ms vs 25ms? I suppose this matters if you're just doing number crunching, but for the most part who cares? Time to market is where Ruby (might) help you out.

    4. Re:Not as fast as others though ... by rffrff · · Score: 1

      and if you need number crunching in ruby you'd use the NArray library, as fast as octave, usually. But, hey, if you want fast cpde you'd use C and, ruby allows you to access C libraries withouth even writing C bindings, thanks to ruby/dl (integrated module to take advantage of platform specific dynamic loader)

    5. Re:Not as fast as others though ... by reborn · · Score: 0

      Perhaps you're not aware, but most applications (be they game, CGI, GUI or whatever) usually require considerable arithmetic to achieve their result, therefore it's generally a good idea to go with the tool(s) that will produce the optimal result(s). So yea, we may be talking 50ms vs 25ms multiplied several thousand times a second.

  25. Offtopic? by Anonymous Coward · · Score: 0

    Dave Thomas? Wendy's? Chicken Nuggets? Come on; it's funny!

  26. Re:Ruby and Perl over Python for cross-platform de by ultrabot · · Score: 1

    my script wouldn't work without a few hours of attention just to set the spacing right.

    Python distribution has reindent.py that does this for your file(s) automatically.

    Using tabs for indenting is recommended against in Python. It's a Python newbie mistake that is usually only done once.

    Ruby has Pascal-like blocking. That alone makes it superior to Python. And for all other situations that do not require a good OO implementation, there is Perl.

    I guess that paragraph kinda speaks for itself and makes it obvious where you are coming from in the, uh, Computer Science landscape.

    --
    Save your wrists today - switch to Dvorak
  27. Great book, great language by CatGrep · · Score: 2, Insightful

    I got my copy a couple of weeks ago. It's a great followup to the first edition - much more information. I've already learned new things from it even though I've been programming in Ruby over 3 years now.

    I also think that the philosophy espoused in the chapter on 'Duck Typing' could apply to other agile languages like Smalltalk and Python. I haven't really seen these ideas come out as strongly in other language communities as they have in the Ruby community.

    I don't think there is any one thing about Ruby that's truly revolutionary, but the combination of features (code blocks, very consistent and complete standard libraries, OO'ness, etc.) make it very compelling. Do yourself a favor and buy the book - learning Ruby can help you think differently about how you approach problem solving in your day-to-day programming work (even if you don't program in Ruby for pay).

  28. Struth! by sbowles · · Score: 0, Redundant
    From the ,a href="http://www.pragmaticprogrammer.com/titles/ru by/">Pragmatic Bookshelf page:

    The Pickaxe book, named for the tool on the cover, is the definitive reference to this highly-regarded language.

    Juat as PerlFans refer to The Camel or The Panther.

    --
    You sly dog: you got me monologuing! - Syndrome
  29. Re:Ruby and Perl over Python for cross-platform de by Anonymous Coward · · Score: 0

    Using tabs for indenting is recommended against in Python. It's a Python newbie mistake that is usually only done once.

    Exactly. Set your editor to insert n spaces (instead of a tab) when you hit the tab key. If your editor won't do this, you need a different one.

  30. Re:As usual, it's cheaper here by PragDave · · Score: 1

    Cool link, wrong book :)

  31. Re:Would you like to probe my body? by Anonymous Coward · · Score: 0, Offtopic

    Ah, nothing like a classic troll...

  32. Comment removed by account_deleted · · Score: 2, Informative

    Comment removed based on user account deletion

  33. Language selection parameters by Mr_Icon · · Score: 4, Insightful

    There are several kinds of programmers, at least when it comes to the language selection:

    • The Hardcore Kind: Everything must be written in something as low-level as possible, meaning C, but only if you absolutely cannot do ASM.
    • The I'm Special Kind: I am going to pick a language that is not commonly used, because having an obscure preference in programming languages makes me feel special. To justify my preference, I am going to learn a few facts that make this language marginally better than a similar language $FOO, ignoring all other advantages of $FOO.
    • The Hammer-Happy Kind: I know one language and I will use it whether it makes sense or not

    The first kind gives us applications that cannot be easily ported to other OSes or platforms, because everything is so low-level that it is tied to the underlying architecture. The second kind gives us duplicated effort and software that becomes unmantained whenever the main developer quits, since few other programmers know the language in which the project is written. The third kind gives us solutions that make sane people scream, like shell scripts that start with #!/usr/bin/php -q.

    It's fun to learn other programming languages, and contribute to the development of new ones, but in the open-source environment it is also very important to remember that you a) do not and should not work in a vacuum, b) that there are freaks who will probably try to run your software on bizarre setups, and c) that there is always a chance that circumstances will require that you quit working on that project.

    This is the reason why when picking a development environment for a project it is important to consider things like portability, maintainability, and suitability for the purpose. I'm not sure I can justify writing something in Ruby at this point, seeing as its adoption is far below Python, while its advantages over Python are slim to questionable.

    --
    If you open yourself to the foo, You and foo become one.
    1. Re:Language selection parameters by Anonymous Coward · · Score: 0

      You know, for most people Python is just as obscure as Ruby.

      The advantage of Ruby over Python is that I can be much more productive in Ruby because it is a better-designed language.

      I guess I'm "type 2" then. It's not my fault that more people don't use Ruby. But they will. Once you run into the walls of Python or other languages you naturally move to Ruby. However some people won't ever hit those walls, that's fine, Ruby won't help them.

    2. Re:Language selection parameters by shirai · · Score: 2, Insightful

      I use language zealotry as a clue-factor. Anybody who says "A" is better than "B" with strong conviction and no caveats, tells me how much they know about programming.

      Great developers know two rules that keep them happy:

      1. Choose the best tool for the job

      2. Given that, know that the best tool is not always the best choice (e.g. everybody in your company knows Java but you want to write in PHP)

      And I suppose even before all of this is, learn at least a few languages. It will give you the clue factor that each language does indeed have its strengths and its weaknesses.

      --
      Sunny

      Be my Friend

    3. Re:Language selection parameters by X-Nc · · Score: 1
      > This is the reason why when picking a development environment for a project it is
      > important to consider things like portability, maintainability, and suitability for the purpose.

      Oh. So that would mean COBOL would be your first choice for languages.

      Seriouslly, that wouldn't be as far fetched as you might think. COBOL is on every platform you'd probably ever need to run on and now has OO capabilities that are better than C++. No, I wouldn't use it for the Next Great OS®, but if you're pushing data around you'd be a fool not to concider it as an option.

      --
      --
      If I actually could spell I'd have spelled it right in the first place.
    4. Re:Language selection parameters by Anonymous Coward · · Score: 0

      I'm not sure I can justify writing something in Ruby at this point, seeing as its adoption is far below Python, while its advantages over Python are slim to questionable.

      It's funny you say this, because my impression of things is that neither Python nor Ruby has the adoption rate of something like Perl, and Ruby seems a lot cleaner and consistent to me. So I've always thought that if I'm going to switch from Perl, it would be to Ruby and not Python.

      I think I'm not alone in this.

      Something else to keep in mind is that Ruby isn't exactly a no-name language anymore. Most people familar with scripting languages by now at least know what it is. If someone new to programming is going to learn one, they might pick Ruby.

      I think with Perl, Ruby, and Python, the adoption rate thing is less of an issue than lower-level languages like C/C++, Fortran, or Java. The reason for this is that much of the scripting language use out there is for local needs and smaller projects. I'm not sure there's as much of a legacy issue with scripting languages, because much of it is written from scratch anyway. This isn't completely true of course, but I think it's more true of languages such as Perl/Python/Ruby than languages such as C/C++/Java/Fortran.

    5. Re:Language selection parameters by Anonymous Coward · · Score: 2, Insightful

      You know, there are some people who actually enjoy programming, and enjoy the aesthetics of different languages. Some of us are interested in obscure languages because they represent a different way of thinking about programming, algorithms, and other such issues. It's not about "feeling special", it's about enjoying a particular language on its own merits.

      If everyone adopted the perspective you seem to present, people would only be interested in math because of what it can do, not what it is.

    6. Re:Language selection parameters by Fweeky · · Score: 1

      Adoption seems healthy here. Should I stop using FreeBSD too because it's not as popular as Linux, or Windows perhaps?

      Ruby's mature, portable (do Python's threads work in DOS?), easily popular enough for general use, has excellent support, and I find it a hell of a lot nicer than Python. Why shouldn't I use it, especially when I see so much more interesting development there?

    7. Re:Language selection parameters by Anonymous Coward · · Score: 1, Insightful
      Don't forget:

      • The Clueless Expert: never used a language, but feels he's an expert on it. You know, the kind of guy who says things like I'm not sure I can justify writing something in Ruby at this point, seeing as its adoption is far below Python, while its advantages over Python are slim to questionable. You know that, of course, because you've not ever used Ruby to write anything of substance. And that makes you an expert!
    8. Re:Language selection parameters by Phrogz · · Score: 1
      I'm not sure I can justify writing something in Ruby at this point, seeing as its adoption is far below Python, while its advantages over Python are slim to questionable.

      Do you have a reference for that? I was under the impression that while Python adoption was slightly ahead of Ruby in the US, Ruby was more widely-adopted in Japan, and (on the whole) they were roughly on par.

    9. Re:Language selection parameters by lewp · · Score: 1

      You know what's really ironic? The post you replied to said the exact thing you italicized. What a coincidence!

      --
      Game... blouses.
    10. Re:Language selection parameters by lewp · · Score: 1

      And no, it wouldn't actually be irony (yes, it's one of the most-misused English words ever, blah blah blah) even if my post's parent wasn't being silly.

      (If I hadn't pointed that out, someone else would've.)

      --
      Game... blouses.
  34. Go for Python, then Ruby by jesterzog · · Score: 1

    Is Ruby really "more powerful than Perl and more object oriented than Python" - is this what I'm looking for, or should I put it off and learn Python first?

    I've never bothered to learn Perl, although from what I understand you're likely to miss being able to do some things in one line that might take a few extra lines in either Python or Ruby.

    Python has been by far my favourite scripting language for several years now. It's structured, it forces relatively consistent syntax, and it has a huge amount of support. The (online) documentation has room for improvement, although I might have been spoiled somewhat by the online Java documentation. (That said, I've hardly used Java at all for three or four years.)

    About a year ago I took my first proper look at Ruby. Ruby is a nicer language. It's more consistent and feels a bit more natural once you get to more in-depth language-related things.

    For instance, one thing I'd really like to do in Python is to modify a few things about the built-in string class. I'd like to just be able to import a module into my program, and have the string class work differently from then on.

    Python simply doesn't let you do this, short of something drastic like hacking the interpreter. Although a large part of the standard libraries are very flexible, the string class is something that's just built in. It can't be touched, because the string implementation is built into the interpreter. I spent a month trying to get my idea to work before I was able to find out that the string class is inconsistent with other classes, and what I wanted really wasn't possible.

    Python's a great language and it's wonderful for prototyping and scripting, but it's this type of thing, where the occasional part of the language is still inconsistent that still lets it down on occasion. For me, at least. My experience with Ruby so far has been that everything just acts the way that you'd expect it to act based on how everything else acts. I'm still not an expert Ruby programmer and there are parts of the language that I'm still working to get my head around, but I haven't yet encountered anything that seems painfully inconsistent.

    Putting all of that aside, I'd recommend definitely learning Python if you want to be productive, and learning Ruby as a side project for the future. The reason I say this is that Python just has so much more support and more depth. eg. Ruby doesn't yet have great support for a lot of often-needed things like Unicode, and you're likely to find a lot more Python support for parsing routines, too.

    Ruby is certainly likely to be useful in a production environment and on a later day may be superior to many other scripting languages. It's worth becoming familiar with it just for that, but I wouldn't want to base everything on Ruby (yet) without backup plans.

    1. Re:Go for Python, then Ruby by Sweetshark · · Score: 1
      For instance, one thing I'd really like to do in Python is to modify a few things about the built-in string class. I'd like to just be able to import a module into my program, and have the string class work differently from then on.
      So whats wrong with this:
      class mystr(str):
      .def __eq__(self, other):
      ..print "I am unique!"
      ..return False

      a=mystr("bla")
      print a==a
      resulting in:
      bjoern@lord:~/ > python pytest.py
      I am unique!
      False
      Yes, you have to init the strings explicitly as mystr, but so what - anything else would be *very* confusing, since all other modules (from the language distribution itself or from other sources ) expect a certain behavior from the str class, and a different behavior would just create havoc ...
      (why does slashcode break indenting in ecodes? Arghh ... I guess you still understand waht I mean ...)
    2. Re:Go for Python, then Ruby by jesterzog · · Score: 1

      Yes, you have to init the strings explicitly as mystr, but so what

      This is what I do at the moment for my compromise in Python, but it's really not good enough.

      I don't want to have to dramatically change it. I want to add a method and add a property to the string meta-class so that I can treat every string the same way, and probably augment some of the operators to deal with my adjusted string more appropriately. I'm fully aware that fundamentally changing how it acts could potentially break other modules -- that's what you get when you meddle with nearly any meta class. But I'm satisfied that the particular change I want to make isn't going to create serious problems for existing code.

      It's for some string-safety research that I'm doing. Having to explicitly declare any given string to be a safe string simply isn't good enough, because it defeats the purpose of a string being "safe" if the programmer has to remember every time a string is used. I want every string that the program generates from anywhere to act my way --- not just the strings I remember to update.

      I can do it in Ruby.

      Anyway, my point was that Python tends to have these inconsistencies and they pop up and make themselves apparent at what usually seem to be the most annoying times... which isn't really unusual considering they're inconsistencies. It's not a bad language, but there are clearly aspects of Ruby that beat it as far as consistency is concerned.

  35. Why is it not Release on Amazon by egoots · · Score: 1

    When I go to Amazon.com it tells me the book is not yet released, but according to Oreilly it is.

    Hmmm.

    Anyone know why?

    1. Re:Why is it not Release on Amazon by MobyTurbo · · Score: 1
      When I go to Amazon.com it tells me the book is not yet released, but according to Oreilly it is.
      You must be confusing it with a different book by O'Reilly. "Programming Ruby: The Pragmatic Programmer's Guide" is published by Addison-Wesley.
  36. Re:Ruby and Perl over Python for cross-platform de by TwistedSquare · · Score: 1

    Ah but the advantage of a tab over n spaces is that it can be removed with a single backspace, whereas n spaces can't. Unless you bind backspace to un-indent, but then it wouldn't delete normal characters...

  37. awesome book, awesome language by Anonymous Coward · · Score: 5, Informative
    I've been using Ruby since I read about it in DDJ a while back.

    What really struck me about Ruby is how it "solved" many of the issues that had been bugging me about other languages (and I've used a bunch). Such as:

    * In many languages, a built-in method will either mutate an object "in-place", or it will work on a copy of the object and return that, leaving the original untouched. Sometimes pretty arbitrarily. But in Ruby, there's a convention like in Scheme (and maybe others): methods ending in "!", like "array.sort!" will sort the array in-place, and the other methods return a new sorted copy. Nice! One annoying issue solved.

    And booleans end in "?" which is nice too. instead of "is_foo" you write "foo?".

    * In many languages, you can have fields on objects, and you can have methods. So when you have "attributes" (like "first_name", "last_name" on a customer object), do you use fields which are simple and straightforward with natural syntax:

    object.first_name = "Joe"

    or do you use methods, which can be refactored:

    object.setFirstName("Joe")

    So, do you go for the awkward syntax, keep the fields private, and allow refactoring? Or do you expose the field, and rewrite all the code later when the requirements say "name must default to 'Anonymous Coward' when no name set"? Or do you convolute your code around the issue?

    Ruby solves this elegantly. There are NO PUBLIC FIELDS! Instead, you always use methods:
    # setter
    def first_name=(f)
    @first_name = f
    end

    # getter
    def first_name
    @first_name
    end

    object.first_name = "Joe"
    And no goofy "set_first_name" .. it's UNIFORM ACCESS. Beautiful! Now when the anonymous coward requirement comes in, just rewrite:
    def first_name
    @first_name || "Anonymous"
    end
    No client code has to be changed. And "first_name = 'joe'" still works.

    AND you don't even have to create the basic getter/setters! Ruby classes have a built-in class method that creates them dynamically:
    class Customer
    attr_accessor :first_name, :last_name
    end
    Very elegant! Well-written programs are very clean and light.

    * No need to use exceptions for non-local flow control.

    Ruby has exceptions, but sometimes you want to jump out of a deep tree search (for instance), and an exception is what you need: "raise SearchFinishedException" or something like that.

    But is that a good idea? Using "exceptions" for flow control? No because exceptions are, well, *exceptional*, they don't occur normally.

    Ruby helps me here too. It has catch()/throw() which is a simple alternative to exceptions, designed for nonlocal flow control. And of course you can write your *OWN* flow control because it has continuations (encapsulate program flow into an object for later return).

    Anyway Ruby is such an amazingly elegant language, and the pickaxe book is the appropriate companion! Buy a copy now, even if you don't use Ruby, it's very clear and easy to read (not just because of the language, but because of the enthusiastic and talented authors).
    1. Re:awesome book, awesome language by 12357bd · · Score: 1

      But in Ruby, there's a convention like in Scheme (and maybe others): methods ending in "!", like "array.sort!" will sort the array in-place, and the other methods return a new sorted copy.Nice!

      Nice what?, the previous phrase or his copy? Excuse me, silly question, it's the previous phrase!

      --
      What's in a sig?
    2. Re:awesome book, awesome language by Fweeky · · Score: 1
      AND you don't even have to create the basic getter/setters! Ruby classes have a built-in class method that creates them dynamically:
      class Customer
      attr_accessor :first_name, :last_name
      end


      What's also handy is you can write your own methods which work like this to dynamically generate repetetive blocks of code for a class or object. ActiveRecord makes great use of this with things like:
      class Author < ActiveRecord::Base
      has_many :articles
      has_one :account
      end

      class Article < ActiveRecord::Base
      belongs_to :author
      has_and_belongs_to_many :categories
      end
      Which then gives you things like Article#author (and Article#author=, letting you change the relation by assigning another Author object to it), Article#categories?, Author#articles, Author#articles?, Author#article_count.. mmm, metaprogramming tastic.
    3. Re:awesome book, awesome language by OmniVector · · Score: 2, Informative
      one of my favorite featuers of ruby is the ability to dynamically modify built in data types at runtime. say, for example, i want to add a pretty format method to hashes. i just type:
      class Hash
      def format
      data = self.keys.collect do |key| key = "#{key} => #{self[key]}" end
      "{ #{data.join( ', ' )} }"
      end
      end

      now i can make a hash and print it just by saying:
      hash1 = { 1 => "one", 2 => "two", 3 => "three" }
      puts hash1.format
      which outputs
      { 1 => "one", 2 => "two", 3 => "three" }


      i don't know of any OOP language that has an ability that powerful.
      --
      - tristan
    4. Re:awesome book, awesome language by Anonymous Coward · · Score: 0
      javascript for one...
      Object.prototype.format = function() {
      var retArr = [];
      for (var i in this) if (i != "format") retArr.push(i + ' : "' + this[i] + '"');
      return "{ " + retArr.join(", ") + " }";
      }

      var nObj = { attr1: "one", attr2: "two", attr3: "three" };
      alert(nObj.format()); // if run in a browser...
  38. ruby documentation by pizza_milkshake · · Score: 4, Informative
    one thing that really hurts ruby is that it's documentation is sparse. i used to be a big ruby fan, but documentation has not kept up with its releases. whereas i think ruby is a very nice language, languages like perl, php and python have much more complete docs, and it makes the difference between 30 seconds to figure out the right function/method and digging around 15 minutes through out-of-date docs and finally going in and reading the source code.

    i own the first edition, it's a good tutorial-type ruby book

    1. Re:ruby documentation by Anonymous Coward · · Score: 0

      Well, (1) this second edition is a far better reference. This time, it's been vetted thoroughly by the community, which didn't exist at the time of the first edition.

      (2) Ruby 1.8.1 has an integrated interactive documentation system called "ri," so reference material shouldn't be a problem anymore.

    2. Re:ruby documentation by Anonymous Coward · · Score: 0

      this is better in the 1.8 series, ruby 1.8.1 has everything builtin documented and easily accessible (ri and RDoc were integrated in the base library).
      but there is still a looooong way to go to reach perl's documentation quality. OTOH, python's one is not that good in these days:

      >>> a=10
      >>> help(a.__pos__)
      Help on method-wrapper:

      __pos__ =

      not very useful :/

  39. Re:Syntactically significant whitespace by dozer · · Score: 4, Interesting

    Ever notice that there's tons of Perl, PHP, and Ruby snippents all over the web but very few Python snippets? It's because you really can't copy Python from the browser and paste it into a text editor! The whitespace gets changed and the program breaks in very hard-to-diagnose ways. It's rather funny.

    There are many features of Python that will be adopted by future languages, but I doubt that significant whitespace is among them.

  40. python and ruby by Ardanwen · · Score: 1

    Had to make the same choice a bit earlier as well (what scripting language to learn: perl, python, ruby) (briefly looked at scheme / lisp too).

    Finally picked ruby over python, mainly cause I liked the founder of ruby more. Been scripting the last few months in ruby, and I'm managing fine with the available documentation on the web.

  41. Re:Ruby and Perl over Python for cross-platform de by Dystopian+Rebel · · Score: 1
    I guess that paragraph kinda speaks for itself and makes it obvious where you are coming from in the, uh, Computer Science landscape.

    I come from that part of the, uh, Computer Landscape where folks believe in crop-circles, George Lucas's genius, and the arguments proving that the lunar landings never happened. Oh yeah, and where programmers don't want white-space to have the significance that it does in Python.

    It's a real mixed bag in my neighbourhood. But however crazy it gets, we always agree that Aquaman should have found a wife with gills.

    --
    Rich And Stupid is not so bad as Working For Rich And Stupid.
  42. Re:Ruby and Perl over Python for cross-platform de by William+Tanksley · · Score: 1

    I don't know of any editors that work that way. Most will gladly allow you to configure them to use emulated tabs: any line beginning only with whitespaces acts as though that whitespace consisted only of tabs.

    It's a pretty fundamental feature, thanks to all the disputes about the One True Indentation :-).

    -Billy

  43. offtopic... by aled · · Score: 1

    Your sig is my favorite Philip K. Dick quote.

    --

    "I think this line is mostly filler"
    1. Re:offtopic... by hoggoth · · Score: 1

      > Your sig is my favorite Philip K. Dick quote.

      In an unexpected symmetry, your sig is my favorite Buffy quote.

      --
      - For the complete works of Shakespeare: cat /dev/random (may take some time)
  44. Re:Ruby and Perl over Python for cross-platform de by Anonymous Coward · · Score: 0

    Tabs are superior because they are easy to adjust to whatever the reader's preference is, just by changing the tab stop setting. Tabs also save 3 bytes per line if you are using 4 space indentation. They are also backwards compatible with text editors that are unable to substitute keys. It is important to realise that people besides yourself may want to read your code.

  45. Re:Ruby and Perl over Python for cross-platform de by prockcore · · Score: 2, Interesting

    What I find unacceptable in Python is that whitespace (tabs) determine the logical flow.

    It also means you cannot take advantage of the auto-indenting feature of editors.

    If I need to go back and wrap a chunk of code in an "if" statement, I can put a { at the beginning and a } at the end and the editor will correct the indenting.

    Python will require me to go line by line and insert spaces or tabs.

  46. Re:Syntactically significant whitespace by Anonymous Coward · · Score: 0

    Of course, there is already a Data Description Language with whitespace significance, vying to replace XML: YAML. And, interestingly enough, this particular instance of style-as-substance seems to be quite popular with the Ruby crowd.

  47. Re:Ruby and Perl over Python for cross-platform de by Anonymous Coward · · Score: 0

    So you use spaces instead of tabs. Big fucking deal.

  48. Re:Syntactically significant whitespace by wtd · · Score: 1

    YAML differs somewhat from Python in this regard. When a Ruby programmer deals with YAML, it's largely by reading in the YAML code, which creates a Ruby object, dealing with that object, then calling another method to reserialize that object to YAML.

    Python code requires more direct editing.

  49. Psst! We're all boycotting amazon by Szplug · · Score: 1

    You must be new here. It's due to their 1-click business-practice patent, some years ago.

    I'm not infinitely serious but, that's why the slashdot links use bn.com instead of amazon.

    And I for one don't buy /new/ books there.

    --
    Someday we'll all be negroes
  50. Safari? by shutdown+-p+now · · Score: 1

    When will it appear on Safari?

  51. Answer 1. by Balinares · · Score: 1
    why do I need to include 'self' as the first parameter of each method definition?

    So that you can import a generic function that goes, for example, parse_stuff(some_string, flags) and then tack it onto a local class:
    MyAdvancedStringClass.parse = parse_stuff
    And instances of that class can now call mystring.parse(self, someflags) and it just works, magically.

    This is especially godsent for writing decent wrappers for C libraries.

    But I agree that it remains an idiosyncrasy of the language, even if it happens to be a powerful one.
    --

    -- B.
    This sig does in fact not have the property it claims not to have.
  52. Re:Ruby and Perl over Python for cross-platform de by Tellalian · · Score: 1

    What I find unacceptable in Python is that whitespace (tabs) determine the logical flow. I once wrote a script on Windows and moved it to UNIX; the UNIX editor handled tabs differently, and my script wouldn't work without a few hours of attention just to set the spacing right.

    Having been a rapid C++ programmer, this was my largest complaint against Python when I was first introduced to the language, but now I consider it one of Python's strengths. Most languages that ignore whitespace invariably have cultures or conventions for defining "proper code indentation". This leads to a redundant mess where you (the programmer) still respect whitespace, often with conflicting "styles", but also respect the language's syntax for doing the exact same task. Python cuts through that crap by throwing out explicit scope declarations ('{', '}', 'begin', 'end', etc), as every language rightly should. This results in shorter, cleaner, more easily readable code. Btw, you can still use ';' in Python, it's just not mandatory.

    As for your "complaint" about crossplatform whitespace, that's the fault of your editor, not Python (I've yet to find a decent editor that doesn't allow you to view whitespace). The recommended Python indentation is four spaces, which is interpreted the same on all platforms.

    Overall, I have to admit Ruby is at least Python's equal in most regards, but it's lack of whitespace is one of the main reasons I haven't considered seriously adoption.

  53. Re:Ruby and Perl over Python for cross-platform de by Tellalian · · Score: 3, Informative

    Python will require me to go line by line and insert spaces or tabs.

    No offense, but that's a load of crap and evidence that you've never actually coded anything in Python. If you had, you'd know that Python comes with a fully functional editor called IDLE, which includes auto-indentation. You can also select whole chunks of code and press ctrl+] to indent or ctrl+[ to unindent. Explicit scope declarators serve no purpose but to frustrate the programmer who forgets to declare that last '}' of 'end' statement. All Python forces you to do is write clean, readable code.

  54. as a complete non programmer by cinnamon+colbert · · Score: 2, Insightful

    I downloaded both python and ruby when I started thinking about learning how to program. I cd download and install correctly both languages on my Win2K OS laptop, but ruby had two things python did not: a really neat intro tutorial out of berkeley, and some sample progams (like abouncing red ball in a box) to play with. For kids learning to progam, this sort of basic hold your hand stuff is invaluable
    Based on this, ruby is better thought out. ON the other hand, I started to puke at all the ruby way stuff.

  55. In Japan... by r6144 · · Score: 1

    I wonder why there has not been any "In Japan" jokes here!

  56. Do Real Programmers write in Ruby? Or in Python? by Anonymous Coward · · Score: 2, Interesting

    Sorry for an off-topic rant by an old man, but this pointless duscussion has just reminded me a recent story comparing Java to C# when someone apparently devoted to the macho side of programming made the bald and unvarnished statement: Real Programmers write in Perl.

    Maybe they do now in the 21st century, in this postmodern era of blogs, smartphones, and "user-friendly" software, but back in the Good Old Days, when the term "software" sounded funny and Real Computers were made out of drums and vacuum tubes, Real Programmers wrote in machine code. Not Perl. Not C. Not, even, assembly language. Machine Code. Raw, unadorned, inscrutable hexadecimal numbers. Directly.

    Lest a whole new generation of programmers grow up in ignorance of this glorious past, I feel duty-bound to describe, as best I can through the generation gap, how a Real Programmer wrote code. I'll call him Mel, because that was his name.

    I first met Mel when I went to work for Royal McBee Computer Corp., a now-defunct subsidiary of the typewriter company. The firm manufactured the LGP-30, a small, cheap (by the standards of the day) drum-memory computer, and had just started to manufacture the RPC-4000, a much-improved, bigger, better, faster -- drum-memory computer. Cores cost too much, and weren't here to stay, anyway. (That's why you haven't heard of the company, or the computer.)

    I had been hired to write a FORTRAN compiler for this new marvel and Mel was my guide to its wonders. Mel didn't approve of compilers. "If a program can't rewrite its own code," he asked, "what good is it?"

    Mel had written, in hexadecimal, the most popular computer program the company owned. It ran on the LGP-30 and played blackjack with potential customers at computer shows. Its effect was always dramatic. The LGP-30 booth was packed at every show, and the IBM salesmen stood around talking to each other. Whether or not this actually sold computers was a question we never discussed.

    Mel's job was to re-write the blackjack program for the RPC-4000. (Port? What does that mean?) The new computer had a one-plus-one addressing scheme, in which each machine instruction, in addition to the operation code and the address of the needed operand, had a second address that indicated where, on the revolving drum, the next instruction was located. In modern parlance, every single instruction was followed by a GOTO! Put that in Pascal's pipe and smoke it.

    Mel loved the RPC-4000 because he could optimize his code: that is, locate instructions on the drum so that just as one finished its job, the next would be just arriving at the read head and available for immediate execution. There was a program to do that job, an "optimizing assembler," but Mel refused to use it. "You never know where it's going to put things," he explained, "so you'd have to use separate constants." It was a long time before I understood that remark.

    Since Mel knew the numerical value of every operation code, and assigned his own drum addresses, every instruction he wrote could also be considered a numerical constant. He could pick up an earlier "add" instruction, say, and multiply by it, if it had the right numeric value. His code was not easy for someone else to modify.

    I compared Mel's hand-optimized programs with the same code massaged by the optimizing assembler program, and Mel's always ran faster. That was because the "top-down" method of program design hadn't been invented yet, and Mel wouldn't have used it anyway. He wrote the innermost parts of his program loops first, so they would get first choice of the optimum address locations on the drum. The optimizing assembler wasn't smart enough to do it that way.

    Mel never wrote time-delay loops, either, even when the balky Flexowriter required a delay between output characters

  57. It is extremely important to mention Parrot by Pan+T.+Hose · · Score: 2, Interesting

    Can I get any advice? Is Ruby really "more powerful than Perl and more object oriented than Python" - is this what I'm looking for, or should I put it off and learn Python first?

    No, it is not more powerful than Perl. But than again, nothing is. The points is not what is more powerful per se, but rather which is more powerful in your hands and which one best fits your own brain. At this point it is extremely important to mention Parrot: "The amazing project [...] to really unite Perl and Python one day (not to mention Tcl, Scheme, Forth and Ruby, to name just a few)."

    Perl, Python and Ruby, while not the only ones, are certainly the most important languages for the Parrot development. Parrot will not be considered ready until all of them are fully supported, and at this point Parrot will be their main target Virtual Machine, running each of them and allowing them to interoperate. At this point it won't matter which of those languages you personally use, because whatever you choose you will still have access to all of the libraries and module, class and object, of each of them.

    Few years ago I will tell you: "go for Perl because of CPAN." Now my advice woule be: "go for whatever you please, for in few years it won't really matter. We will be able to work on the same project, write the same application. I will write my part in Perl 6, you will write yours in Ruby, someone will write in Python and another one in Scheme. We will all subclass our classes, invoke our methods, use our objects, and we will produce a single, monolithic Parrot application anyway."

    Just imagine picking up some fresh, young and cutting-edge language designed weeks ago--or even designing your own language--and having every module from CPAN available at once, working just fine using your new language syntax. This is the future Perl, Python and Ruby. Interoperation instead of competition.

    --
    Sincerely,
    Pan Tarhei Hosé, PhD.
    "Homo sum et cogito ergo odi profanum vulgus et libido."
    1. Re:It is extremely important to mention Parrot by Doesn't_Comment_Code · · Score: 0, Troll

      Thanks! That's really interesting. I've never heard of Parrot before. I wonder to what lengths the languages will be interoperable. It is a noble goal (and I'm just imagining how great it would be to switch back and forth between languages within a program) but it's also a lofty goal. What about languages that treat data differently? There must be some level beyond which you cannot interleave languages. Lines, or at least functions would have to have uniformity wouldn't they?

      I'm not a nay-sayer. But I am very curious about this project. Perhaps I'll read more about it when I get a chance.

      --

      Slashdot Syndrome: the sudden, extreme urge to correct someone in order to validate one's self.
  58. Re:Why is it not Released on Amazon by egoots · · Score: 1

    You must be confusing it with a different book by O'Reilly. "Programming Ruby: The Pragmatic Programmer's Guide" is published by Addison-Wesley.

    Oops... you're right, O'Reilly isnt the publisher, but neither is Addison-Wesley for the 2nd edition. It is published by the Pragmatic Bookshelf publishers

  59. OOP meets functional meets dynamic by Anonymous Coward · · Score: 0

    Ruby combines a lot of goodies from different programming paradigms which results in an incredibly powerful yet simple language.

    Ever awed at Perl hacks producing things you never thought to be able to do in a few lines? The same done in Ruby, and you might actually understand the few lines of code at first glance...

    Ever awed at consistent object oriented design in Smalltalk or (well done) C++? Try Ruby and you wouldn't believe that there's languages that try to do it another way....

    Ever awed at LISP programs passing code chunks around and evaluating as if there's never been a difference between code/data? In Ruby you are allowed to do that and other dynamic magic and you are still given a beautiful, clear syntax beyond ((braces) (which ought to be enough anyway))...

    Ruby is a gift to us developers. It is the future of language design, brought to us now...

    Learn the Ruby way and you will learn to develop software.

  60. No, you are caught in the by warrax_666 · · Score: 1

    moron trap. Learning a language is a one time thing. If you spend 1 week learning a language which lets you write programs 7 times faster vs. your "already known" language, which do you think will come out on top in the end? (Hint: If you write more than 7 programs it will be the new language). Sure, libraries *are* a factor, but please don't tell me that C doesn't let you write programs faster than symbolic assembler (yet giving you the exact same libraries to work with).

    --
    HAND.
    1. Re:No, you are caught in the by AuMatar · · Score: 1

      Great- where is this language that lets you write 7 times faster? It doesn't exist. Writing Java is no wuicker than C, is no quicker than C++, is no quicker than perl (assuming you have regular expression libraries downloaded for C, C++ and Java if doing strings). For that matter, its no quicker than assembly- I'm fairly fluent in assembly, I write it at about the same pace as C. I wish I could use it more frequently at work- assembly is fun.

      --
      I still have more fans than freaks. WTF is wrong with you people?
  61. Re:Ruby and Perl over Python for cross-platform de by hgiddens · · Score: 1

    I think Haskell had the right idea with the whole whitespace-denotes-flow thing - it used the offside rule, but if I remember right, you could throw in braces and semi-colons and have any old formatting.

  62. Re:Ruby and Perl over Python for cross-platform de by Anonymous Coward · · Score: 0

    Propaganda. What would motivate someone to spread idiocy like this against a programming language? I'm genuinely curious.

  63. History repeats... by Big+Sean+O · · Score: 1
    I'm not sure I can justify writing something in Ruby at this point, seeing as its adoption is far below Python, while its advantages over Python are slim to questionable.


    if you ...

    s/Python/Perl/g
    s/Ruby/Python/g

    You would be making a statement I heard many many times in 1999.

    Yet Python use has been growing. I just recently started looking at Ruby (I bought "Programming Ruby" 1st Edition from the overstock rack for $5 the other day) and I see it has a lot of the 'just makes sense' things that drew me to Python over Perl and drew me to Perl over Java.

    Picking a development environment for a project is important if you're spending someone else's money. If you're hacking around at home, you deserve to use what you like.

    Much of the reason why Python has grown so successful (besides Guido Van Rossum, BDFL) is that lots of 'regular folk' liked it better than Perl.

    Also, from what I've seen so far, the surface differences between Ruby and Python can probably be learned in a day or two. If you know one, you probably should learn the other just to put it on the resume.
    --
    My father is a blogger.
  64. Re:Ruby and Perl over Python for cross-platform de by Just+Some+Guy · · Score: 1
    It also means you cannot take advantage of the auto-indenting feature of editors.

    That's a very legitimate concern - if you're using Notepad. If you use something more reasonable like Vim, Emacs, Kate, Eclipse, or any other modern programming editor, then you need to spend two minutes learning how to enable Python indenting rules.

    For example, in Kate you can highlight the block and hit <tab> to indent the block or <shift-tab> to unindent. If your editor doesn't offer similar facilities, then it's time to upgrade.

    --
    Dewey, what part of this looks like authorities should be involved?
  65. Re:Syntactically significant whitespace by Just+Some+Guy · · Score: 1
    It's because you really can't copy Python from the browser and paste it into a text editor!

    That's absolutely ludicrous. You should be using <pre> tags around your code anyway, and those preserve Python indenting every bit as well as Perl, PHP, and Ruby formatting.

    If you haven't found Python on the web, then you're simply not looking in the right places.

    --
    Dewey, what part of this looks like authorities should be involved?
  66. Re:Ruby and Perl over Python for cross-platform de by Anonymous Coward · · Score: 0
    If you had, you'd know that Python comes with a fully functional editor called IDLE, which includes auto-indentation.

    So in order to paste in bits of code from elsewhere, I have to open my source file in Another Editor that Isn't Emacs or Vi, use it's mysterious indentation features, save, then reopen the edited file in my editor of choice? Sounds fun...

  67. Re:Syntactically significant whitespace by Merk · · Score: 1

    Right, but not all bulletin boards / forums / etc. let you use <pre> tags. Take slashdot, it lets you use 'ecode' but that isn't quite the same thing. In addition, copying and pasting text from a table is always troublesome, it's really hard to make sure you get all the indentation right.

    When the language has start and end delimiters for a block of code, a good editor can re-indent it without having to "understand" the code. Python doesn't work that way. The lack of "reindentibility" of Python code is a huge drawback for Me.__init__(self).

  68. Re:Ruby and Perl over Python for cross-platform de by Merk · · Score: 1

    Python:

    if False:
    print "hello"
    print "world"

    Can Idle truly indent that python code properly? Without an end token, how does it know whether 'print "world"' is part of the conditional block, or is simply a statement following the conditional block?

    Ruby:

    if false
    puts "hello"
    end
    puts "world"

    Because the conditional block contains an end token, the indentation system can figure out how far to indent things.

    I don't know of any programmers who are frustrated by having to end their code blocks, and those few extra keystrokes are worth it if it means that my editor can fix indentation across the entire file if I choose.

  69. Learn Japanese! by Merk · · Score: 1

    Learn Japanese, ya lazy bum!

    Just kidding. You're right, documentation has been a major weakness of Ruby in the past. With 'ri' and 'rdoc', and the new wonderful book this review is all about, modern versions of Ruby are becoming better and better documented. There's still a long way to go, especially in 3rd-party libraries, but they're coming along too.

  70. Learn them both! by Merk · · Score: 1

    They're both really easy to learn, at least the basics. With the interactive interpreter ('python' for Python, and 'irb' for Ruby) you can just poke at it, and try random things. Honestly, Ruby and Python are two of the most beginner friendly languages out there.

    As for that page, my experience is that if you like Perl at all, you'll like Ruby more than Python. I know plenty of Ruby users who like both C and Perl, but in my experience it is rare to find a Python person who likes Perl. But don't take my word for it, try them both. They're really easy to play with.

    1. Re:Learn them both! by Doesn't_Comment_Code · · Score: 0, Troll

      Thanks or the advice. I'm starting to think I might like Ruby a little better than Python. The jury's still out, but I'm leaning that way.

      --

      Slashdot Syndrome: the sudden, extreme urge to correct someone in order to validate one's self.
  71. More python cruft by Merk · · Score: 1

    If I want to define something that acts like an array/hash in Ruby, I define the operator like:

    def [](idx)
    # do something with idx
    end

    The dichotomy between the name for the internal implementation of the method and the use is yet another thing that bothers me about Python.

  72. Re:Ruby and Perl over Python for cross-platform de by Tellalian · · Score: 1

    Can Idle truly indent that python code properly? Without an end token, how does it know whether 'print "world"' is part of the conditional block, or is simply a statement following the conditional block?

    Because the conditional block contains an end token, the indentation system can figure out how far to indent things.


    If you write Python code in IDLE, the indentation will be taken care of as you write it. Not after the fact. But you're misunderstanding Python. Unlike C or Java, the whitespace is part of the syntax. Forgetting to indent in Python is the same as forgetting to use a curly brace in C/C++. Can your system figure out where to add a missing brace? Both compilers will complain. The only difference is with Python, the whitespace and scope declarators are the same, so your work is less.

    I don't know of any programmers who are frustrated by having to end their code blocks, and those few extra keystrokes are worth it if it means that my editor can fix indentation across the entire file if I choose.

    Why would your indentation be broken? I understand your argument. It's a common one among programmers unfamiliar with significant whitespace. You've never known order to whitespace. To you, whitespace is a variable, to be substituted and interpreted by the programmer, and to be "fixed" if it doesn't fit your "style". What you fail to realize is that this is all meaningless and is irrelavant to the true purpose of your code, which is to DO something. With significant whitespace, there are no style wars, no "broken" indentation to be "fixed", no redundent syntax. Just clean, readable code.

  73. Troll? by Pan+T.+Hose · · Score: 1

    I have no idea why has your post been moderated as Troll. Those are very good questions. There will be many ways to interoperate on many levels. I'll start from the things you are asking about, i.e. mixing languages in the same file, and then I'll talk about what I think will be even more important. First of all, in Perl 6, eval() will take an optional argument which will be the name of the language used to compile the string:

    #!/usr/bin/perl
    # Perl 6 program
    eval "Ruby code", "ruby"; # Ruby code as a quoted string
    eval <<ENDPY, "python"; # Python code as a here-document
    # Python
    # code
    ENDPY
    # Perl 6 code again

    This is the most verbose syntax and something similar will probably be added to other languages, even those with no built-in eval(), by using some simple module or library in the worst case. Every language compiler will be available on the Parrot level, so it won't be an issue.

    Actually, inlining other languages code is already possible today in Perl 5, using the Inline modules:

    "The Inline module allows you to put source code from other programming languages directly 'inline' in a Perl script or module. The code is automatically compiled as needed, and then loaded for immediate access from Perl."

    For example I just ran this Perl program:

    #!/usr/bin/perl
    use Inline C;
    print "9 + 16 = ", add(9, 16), "\n";
    print "9 - 16 = ", subtract(9, 16), "\n";
    __END__
    __C__
    int add(int x, int y) {
    return x + y;
    }
    int subtract(int x, int y) {
    return x - y;
    }

    It printed: "9 + 16 = 25" and "9 - 16 = -7" but 25 and -7 were computed by C functions. The first time I ran it, it took longer because the C code had to be compiled, but every next time the already compiled shared object is used and it starts instantly. When the C code changes, the module recompiles the shared object automatically and saves the new version. This is a simple example which may seem useless, but you might for example write the speed critical parts of your Perl program in C to speed it up, etc. without the need to learn the XS language normally used to create an extension interface between Perl and C.

    Using other languages in Perl 5, though, especially other than C, is probably not very elegant under the hood. Also, you cannot pass live objects back and forth and axpect them to behave normally, as far as I know. Perl 5 and Python both use their own virtual machines, with different bytecode and different behaviour, like garbage collection, threading etc. When Perl 6, Perl 5, Python and Ruby are running on Parrot, they will all get compiled to the same bytecode, with the same function calling conventions, the same exception handling, they will run on the same VM, with the same threading, garbage collection, etc. only with different data semantics, because for example Perl strings in numeric context are converted to numbers, Perl 6 will have things like 0 with true boolean value, etc.

    Going back to inlining other languages in Perl 6 programs, in addition to eval(), thanks to powerful macros, someone will easily write one which would let you write:

    #!/usr/bin/perl
    # Perl 6
    use Python;
    # Python
    no Python;
    # Perl 6

    or POD-style:

    #!/usr/bin/perl
    # Perl 6
    =begin Python
    # Python
    =end Python
    # Perl 6

    or an XML-style, or some fancy bracketing, or indeed whatever syntax you'd like. But probably more important than mixing languages in the same file, would be the ability to use classes and objects from other languages. For example, you will be able to use Perl DBI module from CPAN in a Python program, using probably something like this:

    dbh = Per

    --
    Sincerely,
    Pan Tarhei Hosé, PhD.
    "Homo sum et cogito ergo odi profanum vulgus et libido."
  74. Re:Do Real Programmers write in Ruby? Or in Python by abb3w · · Score: 1
    If you aren't Ed Nather, you ought to Cite your sources. Like 500 Mile Email, it's a good story, but not YOUR good story.

    --
    //Information does not want to be free; it wants to breed.
  75. Re:Ruby and Perl over Python for cross-platform de by Merk · · Score: 1

    HTML says whitespace is not significant. Python says it is. Nuff said.

    It's not just HTML either. Whitespace isn't significant in any natural language, nor in any other computer language I'm aware of. The computer world simply isn't well equipped to deal with signficant whitespace. Any time you copy/paste code around, you run the risk of messing up indentation / whitespace. it's much harder to accidentally miss a } or 'end'

    Don't get me wrong. If python required signficant whitespace *and* closing tokens, that would be better. That way you'd have the best of both worlds. An editor could fix bad indentation because of the tokens, and you'd be guaranteed to have properly indented code for all working code.

    And, the truth is, Python does have redundancies. In this very discussion we've had people complaining about how you get the length of things in python using len(foo), but others explaining that you can actually use foo.__len__(). Significant whitespace doesn't eliminate style wars, nor does Python eliminate redundancies. Python code is clean and readable, just like Ruby code. Ruby code, by not being whitespace-dependent is much more copy-and-paste-and-share-with-the-world-friendly.

  76. Re:Ruby and Perl over Python for cross-platform de by Tellalian · · Score: 1

    HTML says whitespace is not significant. Python says it is. Nuff said.

    In other news, apples are red, so oranges must suck? Do I really have to point out the fact that HTML and Python are two completely different creatures designed to do completely different tasks?

    It's not just HTML either. Whitespace isn't significant in any natural language, nor in any other computer language I'm aware of.

    You're missing my point. Most languages, including Ruby, essentially still have significant whitespace, it's just not enforced. Try replacing all whitespace tokens with a single space in your language of choice and you'll quickly see how whitespace plays a very important role in programming languages. And btw, significant whitespace is also featured in Haskell, Occam, and YAML.

    The computer world simply isn't well equipped to deal with significant whitespace. Any time you copy/paste code around, you run the risk of messing up indentation / whitespace. it's much harder to accidentally miss a } or 'end'

    I guess all those Python programmers must be tripping over themselves on a regular basis. Hell, I don't even know how I manage to code my Python programs in a few days what would have taken me a few weeks to do in Java or C++. Yeah, significant whitespace is horrible. That's why Python's popularity has only risen in the last decade since its inception. I'm not sure what browser you're using, but I suggest you upgrade (Firefox is especially nice). I've never had trouble copy/pasting Python code around. Granted, this is still a poor measure of a language since most code is shared in files.

    Don't get me wrong. If python required significant whitespace *and* closing tokens, that would be better. That way you'd have the best of both worlds. An editor could fix bad indentation because of the tokens, and you'd be guaranteed to have properly indented code for all working code.

    With significant whitespace, there'd never be a need to "fix" indentation, so any tokens would be meaningless. I think you're associating Python's whitespace with the use of tabs. Standard Python whitespace is four spaces per level of indentation, which is quite explicit.

    And, the truth is, Python does have redundancies. In this very discussion we've had people complaining about how you get the length of things in python using len(foo), but others explaining that you can actually use foo.__len__().

    Wrong again. __len__ is a utility function meant to be overridden in the class definition by programmers who know what they're doing. It's not meant to be called outright. The reason for this is, the underscores represent a reserved namespace that allows the Python developers to introduce new functionality without breaking backwards compatibility. You shouldn't be so quick to criticize a language you seem to know little about.

    Significant whitespace doesn't eliminate style wars, nor does Python eliminate redundancies. Python code is clean and readable, just like Ruby code. Ruby code, by not being whitespace-dependent is much more copy-and-paste-and-share-with-the-world-friendly.

    Yet ironically, the Python community dwarfs that of Ruby. Actually, I suppose that's not really ironic after all.