Dear Monks, I noticed a thread on slashdot (Ruby On Rails Showdown with Java Spring/Hibernate), and a brief comparison of ruby over python piqued my interest. I believe perl 6 design has considered ruby and wonder if it considers/implements whatever whiz bang features of ruby on rails there may be (of which I am relatively clueless). Not wanting to start a flamewar.

My understanding is that with perl 6 / parrot, perl will become more extensible and could perhaps add things from other parrot-supported languages.. anyway will perl 6 have things like what ruby has below? In particular can you have code macros to create new languages over perl (like rails). Would such macros be only usable in perl? For that matter I'd also like to know if the basic grammar of perl will be fluid, i.e. if you wanted to be able to include English-like logical statements within perl.

I'm curious about the role Perl will have in the future and if parrot will give it a special role with respect to other languages. It might also have an impact on corporate decisions on whether to use perl or not in the future I suppose.

Following are some snippets that illustrate the capabilities I'm curious about, and unfortunately too lazy / backlogged on my reading to answer myself.

Automatic get/set method creation:

class Foo attr_accessor :bar, :baz, :foo end
Now the class Foo has accessor methods (getter and setter) for the instance vars bar, baz and foo. A total of six methods were created from that one line of code. No need for a 'modern Java IDE' - vi or emacs work fine. You want read-only access? Use attr_reader then only the getter methods will be created

Passing code blocks around as macros

That's what I'm talking about. In Python you can't do something like this:

def my_while(cond) return @ret unless cond @ret = yield retry end my_while i<10 { puts "i: #{i}" j = 0 my_while j<10 { puts " j: #{j}" j+=1 } i+=1 }
my_while looks like a natural extension of the language. I'm sure you could duplicate this function in Python, but it wouldn't look like a natural part of the language.

Miscellaneous claims

As far as Ruby vs. Python features go:
1) code blocks. Ruby lets you pass code blocks around. Sounds pretty dull, eh? But in fact it's what makes it possible to create Domain Specific Languages in Ruby quite easily without needing to create a special parser. In many ways Rails can be thought of as a domain specific language built on Ruby.
2) classes are always open in Ruby(including the Class class). By 'open' I mean you can always add new methods to a class (or even a particular object). Another feature that makes it easy to create DSLs
3) continuations. (Not that Rails makes use of them, but some other Ruby-based web programming frameworks do)
4) Ruby has true lambdas. AFAIK Python's lambdas are pretty limited (limited to one expression?)

Also, can you embed Python in HTML? (seems that the whitespace issue would cause a lot of problems with doing that)

I'm just looking for the practical solutions...

Give RoR a try. You might just find that it'll do everything you need it to do now without needing to wait around for a Python-based clone. What could be more practical?



Thanks, Matt R.

In reply to Perl 6 and Ruby on Rails by mattr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.