Live data from Hacker News

What Pythonistas Think of Ruby

blog.peepcode.com

111–120 of 247 posts

Re: What Pythonistas Think of Ruby

#111
post #44

Earlier quoted context omitted.

Python doesn't have multiline lambdas, so there is no way to create an api similar to rake's: task :name do |t| # do stuff end I'm not sure what's the closest equivalent syntax you could create in python.

Why do you need lambdas to do this? Why wouldn't an inline function work?

This is correct, it would work. People who harp on this probably don't actually use Python for anything.

Re: What Pythonistas Think of Ruby

#113
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.

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.

Re: What Pythonistas Think of Ruby

#114
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…

As others have pointed out, you could just use a non-anonymous function defined in the current scope in place of a lamba...

Re: What Pythonistas Think of Ruby

#115

Earlier quoted context omitted.

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

Actually, I think Java uses Python decoration syntax for annotations, but I have been wrong before.

Re: What Pythonistas Think of Ruby

#116
post #35

Earlier quoted context omitted.

A Rubyist would argue that that Python 2 syntax is anything but clear. I have no idea what that Python 3 snippet is doing... care to share? That looks like something that's hard to Google...

It's using function annotations as a way to describe which URL to route to. Function annotations aren't used by anything in Python3 by default, so it's one possible way to do that.

I would prefer to use a decorator for that.

Re: What Pythonistas Think of Ruby

#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.

Re: What Pythonistas Think of Ruby

#118
post #41

Earlier quoted context omitted.

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

Re: What Pythonistas Think of Ruby

#119

Earlier quoted context omitted.

"Lisp, I would argue, is far more about the machine than the man and that is the simple reason why it's not more popular." Pleas do, i would love to hear your argument. I fail to see how lisp is less humane than python, when i find it to be exactly the opposite. Edit: what i meant was that lisp is more about the human, not that python is more about the machine, i hope i don't get misunderstood.

As a non lisp programmer, it is hard for me to automatically see what is going on in a lisp program because of mismatched " ' " and a lot of parenthesis. I believe this is one of his points. When I was learning python, or ruby, for that matter ( I use both! ) I never felt like I had no idea what was going on in the code even before I learned the languages.

Oh, Lisp isn't so difficult once you get used to.

Interestingly I find myself equally baffled when I have to read code with side-effects. There's just so much implicit state (and state changes going on in the background), you have to keep in your head. Pure languages are so much easier to understand.

Re: What Pythonistas Think of Ruby

#120
post #98
post #26

Earlier quoted context omitted.

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 getWe…

Yes, Python's functions are meant to be named.
Post reply on HN