News for hackers. Stuff that matters.
Re:Ask HN: What does Ruby have that Python doesn't? by aconbere on Friday August 22, 2008 @02:56PM (#284052)
True python's lambda's suck. And Ruby's lambda's for the most part don't suck.

But ruby's methods really do suck, and so do the complex construction of Blocks. While I recognize that blocks allow you to do weird things (like use return on the calling scope), the fact that they necessitate a special form (yield) and cannot be bound to a variable, and are not passed as standard function parameters just makes them inconsistent and gross.

Methods which aren't first class functions (but can be transformed into one with the helpful helper function!) also suck, and passing those around in a functional way is just a lesson in futility.

All that being said, I have much more faith in these warts being fixed as time goes on, than python's nasty lambda, and the gross over use of dunders.

Re:Ask HN: What does Ruby have that Python doesn't? by shevy on Friday August 22, 2008 @06:28PM (#284274)
"the fact that they necessitate a special form (yield) and cannot be bound to a variable, and are not passed as standard function parameters just makes them inconsistent and gross."

Which brings us to another point - when exactly do you actually need them? I have for every 1000 lines of ruby code maybe one line of "yield" code, and this is only to further extend classes for flexibility. Other languages dont allow you to choose what you want to have, ruby does.

You simply have to make decisions when to use what.

For me it is simplicity, elegance and beauty. These are my biggest design criterias.

Re:Ask HN: What does Ruby have that Python doesn't? by aconbere on Friday August 22, 2008 @07:47PM (#284325)
I'm 100% with you on simplicity, elegance and beauty. I just demand that as much from the design of the languages I use as from my own code.

I've tried to explain it like this. To me ruby feels Turtles all the way down with respect to Objects, but some kind of nightmare tunnel of interleaved beasts down with Functions.

I don't think I should have to make that compromise, so I'll happily go about writing my ruby when I have to, but I'm waiting for the language that is consistent all the way down.

If I could replace every yield I've ever written in ruby with a .call() I would be so much happier :)

Re:Ask HN: What does Ruby have that Python doesn't? by troels on Saturday August 23, 2008 @03:36PM (#284785)
> I'm waiting for the language that is consistent all the way down.

Lua is close.

Re:Ask HN: What does Ruby have that Python doesn't? by MaysonL on Saturday August 23, 2008 @02:51AM (#284515)
but I'm waiting for the language that is consistent all the way down.

Newspeak is coming... http://gbracha.blogspot.com/

Re:Ask HN: What does Ruby have that Python doesn't? by tptacek on Friday August 22, 2008 @08:03PM (#284341)
Ok, now I'm not sure I follow. Apart from the performance issues, why can't you replace every method that "yields" with a method that takes the explicit block parameter, and .call() it?
Re:Ask HN: What does Ruby have that Python doesn't? by aconbere on Friday August 22, 2008 @08:26PM (#284362)
sigh yeah... you could do that, but you often times you have to deal with methods that aren't invoked that way.

http://blog.sidu.in/2007/11/ruby-blocks-gotchas.html

is a good run down of some of the problems here

Re:Ask HN: What does Ruby have that Python doesn't? by shevy on Saturday August 23, 2008 @07:31AM (#284570)
No it is not. You dodged the question again, by throwing a hardly related blog of someone else at it.

How many people will use yield _AND_ self.send in the same method please?! That seems like an awfully complicated and contrived example. Who the heck does this?

Re:Ask HN: What does Ruby have that Python doesn't? by tptacek on Friday August 22, 2008 @06:40PM (#284281)
I think the "can't be bound to a variable" thing is a bit of a red herring too, especially if you're OK with Lisp and Javascript's syntax --- you can create a full-fledged Proc object with "lambda" any time you want.

The inconsistency is annoying, but 99.999% of the time, Ruby is actually giving you what you want.

Re:Ask HN: What does Ruby have that Python doesn't? by aconbere on Friday August 22, 2008 @07:48PM (#284326)
Right, it just doesn't seem to be Ruby style, and it would be nice to be able to use the "pretty" block syntax to accomplish that.
Re:Ask HN: What does Ruby have that Python doesn't? by DougBTX on Friday August 22, 2008 @07:23PM (#284300)

   and cannot be bound to a variable
&block ?
Re:Ask HN: What does Ruby have that Python doesn't? by tptacek on Friday August 22, 2008 @07:40PM (#284319)
The block itself isn't being bound; it's being converted to an explicit Proc object named "block".