Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: RFC: Simulating Ruby's "yield" and "blocks" in Perl

by morgon (Deacon)
on Apr 22, 2013 at 17:05 UTC ( #1029929=note: print w/ replies, xml ) Need Help??


in reply to RFC: Simulating Ruby's "yield" and "blocks" in Perl

I don't deny that it is somewhat cute, but I don't quite get the point of the exercise....

Of course "Ruby is semantically just a Perl dialect" - just as I could argue that Perl is semantically just a Python dialect...

Are languages like Perl, Python, Ruby, Javascript not all "essentially" the same?

But a lot of Ruby-features are really nice (all syntactic sugar I know, but sweet nevertheless) so I would not mind to see them incorported into the Perl-language (on the interpreter-level - not via (sorry) ugly hacks like your "yield").


Comment on Re: RFC: Simulating Ruby's "yield" and "blocks" in Perl
Re^2: RFC: Simulating Ruby's "yield" and "blocks" in Perl
by LanX (Canon) on Apr 22, 2013 at 17:12 UTC
    > (on the interpreter-level - not via (sorry) ugly hacks like your "yield").

    Backwards compatibility is always an issue when discussing new features.

    Ugly hacks which work (even slowly) for old Perl versions improve the acceptance of new features.

    And normally the "ugliness" would be hidden in a module, much like the code of the Perl interpreter isn't judged for prettiness.

    update

    > Are languages like Perl, Python, Ruby, Javascript not all "essentially" the same?

    Nope!

    Just to make it measurable:

    The efforts needed for an experienced Perl programmer to learn Python are at least 10 times bigger than for Ruby.

    It's because Ruby copied semantics and even names for operators and idioms deep into details. Old docs for Ruby still mentioned the strong Perl heritage.

    And you might notice that a "ruby" is a gem and not a snake.

    AFAIK the semantic influence of Python is basically the exception system.

    update

    To give a concrete example, the equivalent for an anonymous sub in Perl or a {block} in Ruby is a lamda in Python. But a lamda is restricted to at most one statement, with the effect that some functional idioms in Python look like a cluttered mess of nested lambdas.

    update

    Furthermore Python doesn't have variable interpolation in strings, you must use printf or similar replacement techniques.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re^2: RFC: Simulating Ruby's "yield" and "blocks" in Perl
by curiousmonk (Sexton) on Apr 23, 2013 at 03:29 UTC

    Are languages like Perl, Python, Ruby, Javascript not all "essentially" the same?

    Mathematically, yes they are all the same. But that is not what we are talking here.

    When a syntax feature is being added to a language. We generally discuss how that can help users avoid writing repeated patterns of code.

      Mathematically, yes they are all the same.
      What is that supposed to mean? How do you "mathematically" compare programming languages (and yes I do know about denotational semantics)?

      The point I was trying to make is that when you abstract away inessential syntactic differences then Perl, Ruby and Python are the same - and I still subscribe to that view.

      During the history of computing several programming paradigms have evolved, so we have the imperative paradigm (the C family if you want), the functional paradigm with or without strong type-systems (Lisp, Haskell), the logical paradigm (Prolog) the OO-Paradigm (Eiffel) and of course all sorts of cross-breeds.

      So if you look at the whole range of languages from assembler to C and C++, Lisp, Haskell, Prolog and so on the ecological niche of Perl, Python and Ruby is exactly the same - a few syntactical differences notwithstanding (and speed comparisons of concrete implementations are for this discussion entirely irrelevant).

        There is a difference between ecological niche and genetic relationship.

        Giraffes and elephants both live in the African savanna but share less genes than African zebras and Mongolian horses do.

        Cheers Rolf

        ( addicted to the Perl Programming Language)

        What is that supposed to mean? How do you "mathematically" compare programming languages (and yes I do know about denotational semantics)?

        All languages are same in a mathematical sense, that what you can do in one turing complete language you can do in another. Albeit with a lot of pain and kungfu

        when you abstract away inessential syntactic differences...

        Firstly, those are not 'inessential' syntactic differences. Because the very purpose Perl was invented was to solve some very essential problems. Problems both at both programmer level and the problems programmers try to solve. This continues to be the case till today.

        So if you look at the whole range of languages from assembler to C and C++, Lisp, Haskell, Prolog and so on the ecological niche of Perl, Python and Ruby is exactly the same

        You keep talking about 'small syntactical differences'. Those are not small. I solved a very pressing P1 issue on production today morning with Perl in something like 25 minutes. I can't imagine doing that in C++. Its just not possible!

        Lastly, I think you are stuck in this principle called Occam's razor- Which basically says "All things being same, the simplest thing turns out to be the best". The only problem is there are more than one condition to be considered while deciding if two things are the same

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029929]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2014-09-16 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (16 votes), past polls