From: ptkwt@... (Phil Tomson) Date: 2004-05-11T02:23:55+09:00 Subject: Re: in search of a compelling reason to use ruby.... In article , Ryan Paul wrote: >i'm a python programmer, and I have recently been hearing a lot about >ruby. Good. >A lot of python people seem to think ruby is in some way inferior, >but I have yet to find any significant differences between the languages. >The only differences I have found so far have been superficial syntactic >things. The only real significant difference I have detected, is the >absence of a module system in ruby. ?? absence of a module system in ruby? What do you mean by that? We've got modules. > >I would like to be able to make an objective and educated comparison. Ruby >seems to have a relatively small, but intensely devoted following. >Software that inspires such fervent support from a small community usually >possesses tremendous power that most people are just too dense to discern >(eg: ocaml, and BeOS). Consequently, I figured it would be worth my time >to find out what it is that the fanatics find appealing. > >I am looking for: > - examples of tangible features that ruby has, which python doesnt. Continuations, blocks. > - examples of scenarios where some facet of, or property specific to > ruby contributed to the simplification or improvement of a programming > project. Here's one: Ruby's code blocks. Deceptively simple, but very powerful in practice. They allow you to easily create domain specific languages very easily in Ruby. Quick example: I'm taking a Quantum Computing class. The prof is looking for a language for designing quantum circuits. I signed up for the project and createed a 'language' I call QDL (Quantum Design Language), but it's reeally just plain Ruby under the covers - no parser needs be created. Here's an example of QDL: circuit = QCircuit { QBits = 4 l0 = QLayer { feynmann(0,3) feynmann(1,2) } l1 = QLayer { toffoli(2,3,0) } } Basically this describes the structure of a simple quantum circuit with two layers and 3 gates. It can be simulated. I can now have my classmates write QDL without having to know anything about Ruby at all. Of course, if they're willing to learn a little Ruby it becomes much more powerful since they can access all of Ruby from QDL. The magic here is Ruby's code blocks (the code between '{' and '}'). They can be passed around and 'called' or 'yield'ed to. I suspect it would be very difficult to implement a QDL-like language in Python because Python doesn't have code blocks like this (you would have to create a parser). (BTW: QDL is implemented in about 400 line of Ruby, that includes all the additional matrix operations (Kronecker product) and some simple error checking). > - facets of the language which may not necessarily be useful, but are > notably creative/innovative. > >Additionally, I realize that there is more to a language than its syntax >and functionality. As a result, I am also interested in hearing about >facets of the ruby community and ruby ideology, and anything else that >ruby programmers feel contribute to their affinity for the language. > >I have a feeling that most of the things that make ruby worth using can >also be found in python. From the perspective a python programmer who has >taken only a precursory glance at ruby, it looks like ruby suggests a >functional style, while python suggests an imperative style. It also looks >like ruby may be better suited for quick shell scripts, whereas python is >better suited for bigger programs. I realize that I probably suffer from >misconceptions, and i'm looking forward to having them corrected. You can use Ruby for large projects as well. There are rumors of 20,000 to 30,000 line Ruby programs here. Personally, I don't think I've written anything that was more than ~5000 lines of Ruby - of course, in my experience, 5K lines of Ruby packs about the same functionality as 20K to 25K lines of C++ code. > >I sincerely hope nobody finds any of my comments offensive, I dont mean >them as criticisms of ruby. I intentionally withhold criticisms until I am >better versed in the benefits! Mostly you need to try using Ruby on a small test project. Actually using the language will give you a better feel for it than us telling you about it. Phil