Live data from Hacker News

What Pythonistas Think of Ruby

blog.peepcode.com

91–100 of 247 posts

Re: What Pythonistas Think of Ruby

#91

Earlier quoted context omitted.

The other side of the argument: why support anonymous functions, but restrict them to one line? That seems highly arbitrary.

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.

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

#92

Earlier quoted context omitted.

> As a Pythonista I have no idea what the Ruby snippet is doing. Fair enough. Arguing over beauty is silly anyway, I just wanted to point out that the entire thing is entirely subjective. > The Python 3 version is using a function annotation. Thanks, checking out PEP 3107 now. I've always seen annotations done with the @annotation syntax like the Python 2 snippet has.

> Thanks, checking out PEP 3107 now. I've always seen annotations done with the @annotation syntax like the Python 2 snippet has. The @ syntax is for decorators. Different beast altogether.

Ah. So, Python uses the Java annotation syntax for decorators? Hm. One more thing I'll have to look into when I get the time.

Re: What Pythonistas Think of Ruby

#93
post #90
post #73

Earlier quoted context omitted.

Ah, I see. So what you are tying to say is that the non-stop bashing of Perl, PHP and Ruby from Python developers should be interpreted as just a friendly "if [you don't like python], no worries." After all, one would have to be a "Rube (that's what [Ruby developers are] called, right?)" to think that Python developers aren't friendly to people who don't worship Python.

I just browsed over this entire thread, and you're by far the flamiest person here. There are always bashers. Their existence proves nothing. The question is whether they represent the bulk of the community. It's hard to speak for an entire community, but it is certainly true that the Python community leaders are not into bashing other languages routinely.

    you're by far the flamiest person here.
Flamier than the person who called Ruby developers "Rubes" after claiming Python is friendly to other developers? Interesting.

    Python community leaders are not into bashing other languages routinely
Indeed, this is true. It's unfortunate that so many python developers don't follow suit.

Re: What Pythonistas Think of Ruby

#94
post #45

Earlier quoted context omitted.

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.

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

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.

Re: What Pythonistas Think of Ruby

#95
post #37

As someone who did nothing but Rails since 06 (two Rails-powered startups, plus some Rails contracting), allow me to explain why I dumped Ruby/Rails and switched to Python/Pylons. Batteries. Ruby is great, but outside of Rails you are on your own. Even basic things like geometry needs to be coded by hand. Python (and almost anything else) simply destroys Ruby when it comes to generic non-web centric libraries. And th…

Do you really have to switch from one to another? I learned both languages, love them both, and use them both. There's too much hate in the world of programming languages.

I reuse code a lot. If I write code in Ruby, I can't reuse it in a Python project. Since Python and Ruby occupy the same niche, I will often want to reuse code.

(This is less of an issue if I want to use Python and C++. I'll rarely want to reuse linear programming code or a PDE solver in Python, and if I did, I would just wrap the C++. Similarly, I never want to use code I've written for the web in C++.)

Re: What Pythonistas Think of Ruby

#96
post #17
post #12

"Without powerful blocks and lambdas, you can’t have Rake. You can’t have RSpec. You can’t have Sinatra’s clear REST syntax." Can anyone explain why?

Disagree on "REST syntax". Python could do just as well: Sinatra: get '/hi' do "Hello World!" end Python 2: @get('/hi') def hello(): return "Hello World" Python 3: def hello() -> "/hi": return "Hello World"

I've never worried much about which language I use to GET hi. As long as the end result is same, everyone should be feeling good.

Re: What Pythonistas Think of Ruby

#97

A main take away point: Ruby is better for writing DSLs (which is what I am doing for one customer right now)

Smalltalk is even better. Advanced Smalltalk is morphing Smalltalk into a DSL. You can even write your own domain specific if-then-else analogues, and it looks 1st class like the Standard conditional logic. Yet the implementation is just a plain vanilla method.

You can't morph Smalltalk into a DSL as Smalltalk itself is nothing but a DSL; syntactically every single control structure is library.

Re: What Pythonistas Think of Ruby

#98
post #26

I am one of those people who accepted the lisp religion of "syntax is evil". I have a descent knowledge of python, and I've read a few ruby tutorials. Neither python nor ruby are lisp. Python is not cool because of generators, list comprehensions, decorators or any other feature. Ruby is not cool because of blocks or monkey patching(im suspicions of anything called MONKEY patching). Ruby and python are cool because o…

I wholeheartedly agree that all languages should be judged on the quality of their libraries and implementation, as well as the success of the projects implemented on top of them. Ruby and Python have a pretty good track record there. One of the themes of Gary's talk was that Ruby is more expressive/flexible than Python, and lisp was thrown into the discussion as sort of a "gold standard" of expressiveness/flexibilit…

> I wish Python just had some kind of anonymous function syntax that was more rich than lambdas

A lot of people keep saying this, including the article author, and I'm having trouble understanding why. Lambdas are for "one-liners", functions are for more-liners.

Any time you want to write multiple lines in a lambda it's trivial to make it a named function.

    def listSomeTable(name):
        print name.center(40, "=")
        def getWeirdNumberPair(cap):
            while True:
                a = random.randint(1, cap)
                b = random.randint(1, cap)
                if (a==1) and (b==1):
                    continue
                return (a, b)
        for i in xrange(20):
            print getWeirdNumberPair(i)
        print "="*40
What do you want to use multiline-lambdas for that you can't do (equally simply and elegantly) with named functions?

Re: What Pythonistas Think of Ruby

#100
post #73
post #71

Earlier quoted context omitted.

There's a difference between "why aren't you using Python?" and "why aren't you following standard Python coding conventions?".

Ah, I see. So what you are tying to say is that the non-stop bashing of Perl, PHP and Ruby from Python developers should be interpreted as just a friendly "if [you don't like python], no worries." After all, one would have to be a "Rube (that's what [Ruby developers are] called, right?)" to think that Python developers aren't friendly to people who don't worship Python.

> the non-stop bashing of [...] PHP [...] from Python developers

You lost me here. PHP is the favorite flogging-boy language of a lot of developers from a lot of different environments. Trying to peg this solely on Python developers/flamers is disingenuous. You might as well try to claim that Python developers are responsible for all of the Microsoft (and/or .Net/ASP/C#) bashing that goes on around the web.

Post reply on HN