Live data from Hacker News

What Pythonistas Think of Ruby

blog.peepcode.com

151–160 of 247 posts

Re: What Pythonistas Think of Ruby

#151
post #30
post #17

Earlier quoted context omitted.

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"

Decorators and annotations are very useful in Python, but I still like the terseness of Ruby--no need to define "hello()". Of course, Python wins on a different kind of terseness--no do/end--but that is mostly orthogonal.

And you could use {} instead of do/end, but a Pythonista wouldn't consider that any more terse.

Re: What Pythonistas Think of Ruby

#152
post #109
post #88

Earlier quoted context omitted.

Python is a dogmatic language. For the language, this is a good thing, helping it stay clean, simple and yet still powerful. But for the community, it breeds rabid fanboys, just like everything else that's dogmatic.

I don't know. Haskell is quite dogmatic in some ways. The people on the Haskell cafe mailing list don't strike me as rabid fanboys.

You must be joking. People like Dons run or use a blog spidering program for anything that mentions Haskell.

In less than 10 minutes after posting anything remotely negative about Haskell, I have a horde of angry fanboys telling me how I am an idiot.

Re: What Pythonistas Think of Ruby

#153

Earlier quoted context omitted.

You are correct. There is no reason not to just use an inline function that happens to have a name. I think the "lambdas can only be one line" is a newbie python mistake.

Personally, I dislike naming things that I won't use again. It feels like a waste. And then, since I have to name things, I have to come up with a _good_ name. Just a matter of taste, mind you, but it's my reasoning for preferring anonymous functions.

They do make code more readable sometimes... but I think they are often used in Ruby as an alternative to @obj.method(:foo) -- in other words the Rubyist would use lambda{@obj.foo} and the pythonista would use obj.foo

Re: What Pythonistas Think of Ruby

#154
post #37

Earlier quoted context omitted.

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++.)

And if you did, it isn't really that hideous to embed the python interpreter in your C++ app...

Re: What Pythonistas Think of Ruby

#155

Earlier quoted context omitted.

You don't have to choose a single option, even for a particular project. I've worked on websites/apps that have integrated 2 or 3 different server-side languages and frameworks. If you have a programmer that says "eww I'm not touching the WordPress part because it's in PHP" they just aren't the kind of programmer I want working on the project. Also, if you have a programmer that goes out an freaking re-implements Wor…

There is a drawback to this, obviously. If your codebase is some scattered mish mash of Python, PHP, Actionscript, Javascript, Java, etc, your ability to reuse code diminishes at the language boundaries. You end up having to write very similar code to deal with the same objects on the client side and the server side in multiple languages, producing more code to maintain overall. Unfortunately because of the nature of…

True, though I don't want to leave you with the impression that it's a mish mash implementation. It's more of a silo'd approach. One section of the website might be a wiki, so we use a particular tool there. It's a self-contained unit but perhaps pulling in some common stylesheets to retain a consistent look and feel. Another section might be a blog part of the site. Again, it might pull in some common assets for the consistent look and feel.

Instead of thinking of code re-use, we're left with a UNIX style resource re-use. Every component can stand alone, but they all work in conjunction with each other and can be re-arranged to work in different ways.

Re: What Pythonistas Think of Ruby

#156

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.

No, they're exactly the same beast!

I've used decorators to add attributes to function objects in several projects in the past -- you don't have to wrap the original.

Re: What Pythonistas Think of Ruby

#157
post #53

Earlier quoted context omitted.

I don't think the fights should be vicious, but I think the stakes are fairly high, and even though Ruby and Python are close cousins in the grand scheme of things, they really do represent profoundly different philosophies when you look more closely at the languages. It would be nice if these differences could always be discussed with civility, of course. I use both Ruby and Python enough to appreciate that both lan…

That's just another reason for vicious fights besides small stakes, small differences. Just ask the protestants and the catholics.

It is true that small differences can mean large conflicts, but I think Catholicism and Eastern Orthodoxy is a better illustration of this. The only doctrine that the two denominations disagreed on was the exact way in which the Pope is higher-ranked than the other metropolitan bishops; this plus language barriers and differences in cultural atmosphere produced something like 1500 years of mutual hostility which were only ended by John Paul II.

However, we can sometimes mistake _subtle_ differences for _small_ ones; but just as there's a substantial difference between the Mac OS and Windows, there's a substantial difference between Catholicism and Calvinism (which was the most successful form of Protestantism) -- the difference between God seeing that you went to Hell, and God sending you there. I could go into much greater detail (I count nine paragraphs in how I'd previously structured this comment), but that's the nutshell of the nutshell.

Re: What Pythonistas Think of Ruby

#158
post #142

Earlier quoted context omitted.

" ... just a troll post on Python by a Rube (that's what they're called, right?)" Speaking of which ...

It was just a joke, no offense intended. Apologies to any Rubyist who was offended.

I don't think anyone was offended, but it's exactly the sort of thing some people like to jump on and say, "See? See? That's what I'm talking about!"

Re: What Pythonistas Think of Ruby

#159
post #117

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…

Python generators (the ones you can get with "yield") are not just syntax. They can be viewed as a distant relative of continuations or lazy evaluation. Lisp (or lets say Scheme, because Common Lisp is ugly and imperative) does have some nice points. I rather like the syntax. But e.g. strict evaluation by default and lots of side-effects hamper the expressiveness and flexibility of the language.

You do Haskell don't you? :-)

Re: What Pythonistas Think of Ruby

#160
post #127

Earlier quoted context omitted.

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?

You can pass an anonymous function or lambda:

    def foo(thing, block):
      thing = "cruel " + thing
      block(thing) # like `yield thing' or 'block.call' in ruby

    def bar(thing):
      return "hello " + thing

    foo('world', bar)

    # or:
    foo('world', lambda x: "hello " + x)
Ruby's blocks are really just sugar for passing an anonymous function in the last argument and yield is just sugar for calling that function. The example above in Ruby would be:

    def foo(thing)
      yield thing
    end

    foo('world') { |thing| "hello " + thing }
Post reply on HN