Live data from Hacker News

What Pythonistas Think of Ruby

blog.peepcode.com

121–130 of 247 posts

Re: What Pythonistas Think of Ruby

#121
post #80

Python lambdas are limited to one line and can’t contain statements (for, if, def, etc.). Which leaves me wondering, what’s the point? As much as I wish that the python lambda syntax was more powerful, they are ridiculously useful for one-liners where you can't use forms that require whitespace indentation. Everything must consist of set operations. cat file | python -c "import sys; lines=sys.stdin.readlines(); lines…

It's silly to use Python when sed or awk would yield better solutions.

It would be sillier to use Java. Or COBOL.

Re: What Pythonistas Think of Ruby

#122

Python versus Ruby has always struck me as one of the absurd battles ever. The two languages seem to address a very similar space and have broadly similar features sets. Yes there are points of variation but both seem to work really well. People build cool and useful stuff in both. People are productive in both. As for me - I personally like the syntax of Python better. That could be because I learnt it first - or it…

I agree with you, the argument is pretty stupid. The reason it gets so heated is that the two languages, while similar from some perspectives, are _wildly_ divergent in philosophy. It really is a Catholic/Protestant battle, as someone pointed out earlier.

> It really is a Catholic/Protestant battle, as someone pointed out earlier.

And who's who? (Not meant as flamebait. I just want to see where the analogy leads to.)

Re: What Pythonistas Think of Ruby

#123

Earlier quoted context omitted.

> Oh, come on. You're just disagreeing for effect here. It's unclear what "get" is. Is it a function? What does it return? My guess would be that it returns a function bound to the handler of a "/hi" url, but that's a guess.

"get" is a function that takes a string and a block. And the block is bound to the uri given in the string, so your guess is correct.

Ruby always confuses me with this flexible syntax...

Re: What Pythonistas Think of Ruby

#124
post #122

Earlier quoted context omitted.

I agree with you, the argument is pretty stupid. The reason it gets so heated is that the two languages, while similar from some perspectives, are _wildly_ divergent in philosophy. It really is a Catholic/Protestant battle, as someone pointed out earlier.

> It really is a Catholic/Protestant battle, as someone pointed out earlier. And who's who? (Not meant as flamebait. I just want to see where the analogy leads to.)

As someone who's raised Catholic and prefers Ruby... I don't think that they map together well in any deeper way. Neither language started off as a fork of each other.

This particular analogy only runs skin-deep.

Re: What Pythonistas Think of Ruby

#125
post #122

Earlier quoted context omitted.

> It really is a Catholic/Protestant battle, as someone pointed out earlier. And who's who? (Not meant as flamebait. I just want to see where the analogy leads to.)

As someone who's raised Catholic and prefers Ruby... I don't think that they map together well in any deeper way. Neither language started off as a fork of each other. This particular analogy only runs skin-deep.

OK. Thanks!

Re: What Pythonistas Think of Ruby

#126
post #112
post #107

I believe Python has a yield statement, or am I missing something? http://docs.python.org/whatsnew/2.5.html#pep-342-new-generat...

Indeed. Perhaps the Ruby one works different?

Yep. `yield` in Ruby is a normal anonymous method call. It pushes a new frame onto the stack. `yield` in Python works more like Ruby's [Generator](http://ruby-doc.org/stdlib/libdoc/generator/rdoc/classes/Gen...). It freezes the current stack frame's state and resumes execution somewhere else, returning again to the same place on the next iteration. They're very different things really.

More about Python's generators here:

http://www.python.org/dev/peps/pep-0255/

Re: What Pythonistas Think of Ruby

#127
post #112

Earlier quoted context omitted.

Indeed. Perhaps the Ruby one works different?

Yep. `yield` in Ruby is a normal anonymous method call. It pushes a new frame onto the stack. `yield` in Python works more like Ruby's [Generator]( http://ruby-doc.org/stdlib/libdoc/generator/rdoc/classes/Gen... ). It freezes the current stack frame's state and resumes execution somewhere else, returning again to the same place on the next iteration. They're very different things really. More about Python's generator…

So what would yield in Ruby be like in Python? Surely there must be some analogue?

Re: What Pythonistas Think of Ruby

#128

Earlier quoted context omitted.

"get" is a function that takes a string and a block. And the block is bound to the uri given in the string, so your guess is correct.

Ruby always confuses me with this flexible syntax...

It's possible that you just haven't read enough ruby, then. There are only two variations on the syntax of passing a block to a function, "do/end" and "{ }". By convention, multiline blocks use do/end, and single line blocks use {}.

It's also possible that one of the things in the article is the gotcha, flexible parenthesis. By convention, Rubyists tend to use parenthesis when defining functions, but not when calling them:

    def get(path, opts={}, &block)

    get "/hello" do
not

    get("hello") do
Which would still work, if you preferred. The exception to this is chaining method calls:

    Users.find_all_by_age(23).select {|user| user.first_name == "steve" }
... not that that's an awesome use of ActiveRecord, but whatever.

Re: What Pythonistas Think of Ruby

#129
post #41

Earlier quoted context omitted.

As a Pythonista I have no idea what the Ruby snippet is doing. Readability depends entirely on context. The Python 3 version is using a function annotation. In Python 2 or 3 you could use a context manager (with statement) to similar effect.

As a Pythonista I have no idea what the Ruby snippet is doing. Readability depends entirely on context. Oh, come on. You're just disagreeing for effect here. I've never used Ruby but that snippet is clear as day. The Python 3 snippet suggests to me that the output would be "/hi" though :)

  Oh, come on. You're just disagreeing for effect here.
  I've never used Ruby but that snippet is clear as day.
The hell it is. I find it quite confusing. I'll take the Python 2 solution anyday, which clearly seperates what is called from when it is called. One of the main problems with the 'my language is so flexible' approach is that inventing concise solutions becomes a goal in itself.
Post reply on HN