News for hackers. Stuff that matters.
Re:What Pythonistas Think of Ruby by DanielStraight on Wednesday February 03, 2010 @09:15AM (#1097749)
I think this is a good explanation of some of the very real differences between Python and Ruby. The lambda issue is almost enough to get me back to Ruby after switching to Python. I stick with Python mostly because of syntax (especially significant whitespace) and the batteries-included philosophy. I'm also in love with a Python library called pyparsing, the equivalent of which I haven't seen in any other language.
Re:What Pythonistas Think of Ruby by mbrubeck on Wednesday February 03, 2010 @09:41AM (#1097794)
As an aside, pyparsing is based strongly on the excellent "Parsec" library for Haskell. A number of other languages have similar parser combinator libraries.

If you're looking for Ruby libraries specifically, check out: http://treetop.rubyforge.org/ (Treetop uses PEGs rather than parser combinators, but like pyparsing it integrates very well with its host language.)

Re:What Pythonistas Think of Ruby by DanielStraight on Wednesday February 03, 2010 @10:14AM (#1097861)
Good call on Parsec. Unfortunately, I haven't found Haskell nearly as practical as Python for day-to-day work.

Treetop I had not heard of. It looks interesting.

Re:What Pythonistas Think of Ruby by steveklabnik on Wednesday February 03, 2010 @10:32AM (#1097900)
The only problem I had with Treetop when I tried to play around with it is the same problem that I tend to have with lots of Ruby libraries. No docs other than code. Treetop has docs, but they were kind of sparse last time I looked at them.
Re:What Pythonistas Think of Ruby by draegtun on Wednesday February 03, 2010 @11:15AM (#1098029)
pyparsing, the equivalent of which I haven't seen in any other language

Well the "golden oldie" equivalent in the Perl world is Parse::RecDescent (http://search.cpan.org/dist/Parse-RecDescent/).

A new kid on the block is Regexp::Grammars (http://search.cpan.org/dist/Regexp-Grammars/), which is heavily based on Perl 6 rules/grammar (http://en.wikipedia.org/wiki/Perl_6_rules).

Re:What Pythonistas Think of Ruby by mclin on Wednesday February 03, 2010 @11:34AM (#1098081)
I'm not sure I get the lambda issue. If you want a > 1 line lambda why not just define a function?

    def a(x):
        def b():
           print x
        return b
Not sure what a prototypical ruby usecase would be.
Re:What Pythonistas Think of Ruby by gcampbell on Wednesday February 03, 2010 @12:35PM (#1098264)
The other side of the argument: why support anonymous functions, but restrict them to one line? That seems highly arbitrary.
Re:What Pythonistas Think of Ruby by fuzzyman on Wednesday February 03, 2010 @12:45PM (#1098293)
Nope - not arbitrary, it is because of the indentation scoping rules. Try coming up with a syntax for statement based lambdas that isn't ugly as heck.
Re:What Pythonistas Think of Ruby by jashkenas on Wednesday February 03, 2010 @01:18PM (#1098410)
First, links for context.

Guido's take: http://www.artima.com/weblogs/viewpost.jsp?thread=147358

Arcieri's take: http://www.unlimitednovelty.com/2009/03/indentation-sensitiv...

It's not hard if we disallow statements, and make everything into an expression that returns a value -- something that Ruby does right. The value of a block of statements is just the value of the last statement in the block.

So, whether you call it a function, or a method, or a lambda, or a block, whitespace with multi-line expressions can be made to work.

The commonly-cited lambda-with-multiple-prints example, in CoffeeScript:

    count: ->
      print 'one'
      print 'two'
      print 'three'
Re:What Pythonistas Think of Ruby by kevingadd on Wednesday February 03, 2010 @12:43PM (#1098285)
Not one line, one statement.
Re:What Pythonistas Think of Ruby by 0x44 on Wednesday February 03, 2010 @07:07PM (#1099324)
The prototypical ruby case would be:

  def some_method(x, &block)
    yield x
  end

  then to call it:

  some_method "hey" { |v| print v }
That might not look like much, but it allows you to create methods that can extend the language expressively and then use them without extra crufty syntax or sigils obstructing their meaning.
Re:What Pythonistas Think of Ruby by mclin on Wednesday February 03, 2010 @08:39PM (#1099512)
> some_method "hey" { |v| print v }

I'm sure ruby is great once you're initiated, but despite >10 years of programming and having learned basic, c, pascal, lisp, java, c++, python, perl, bash, php and javascript, I have no idea what code does.

Don't mean to harsh, just an observation.

Re:What Pythonistas Think of Ruby by 0x44 on Thursday February 04, 2010 @11:47AM (#1100889)
I made that method absurdly generic, how about:

  get "/hi" do |url|
    print url
  end

?
Re:What Pythonistas Think of Ruby by brutimus on Wednesday February 03, 2010 @01:01PM (#1098351)
I don't understand the argument either.. I use multi-line lambdas with ifs and forloops all the time.

  f = lambda x:(
    x if (
      x**2 > 10 or x**2 < 5
    )
    else x**3
  )
Re:What Pythonistas Think of Ruby by cturner on Wednesday February 03, 2010 @01:30PM (#1098439)
I don't think you can assign variables in these blocks, nor do sequential statements. Imagine you wanted to reduce a list, and then do something on it. Print statements don't work either.