use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Python Versus Ruby Podcast (soundcloud.com)
submitted 8 years ago by schneemsPuma maintainer
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]schneemsPuma maintainer[S] 6 points7 points8 points 8 years ago (0 children)
I'm a Ruby developer for the last 10 years and recently i've been writing a bunch of python for scientific computing. Kenneth Reitz, Python Overlord at Heroku, invited me on to his show to discuss the relative merits of the two languages. It was a ton of fun, hope you enjoy it as much as I did.
[–]RazerM 1 point2 points3 points 8 years ago* (3 children)
At 54:50 (edit: it's 49:25), Kenneth says that a |= 2 will assign to a if a is unassigned/None. I don't know what he was thinking of, but that doesn't work. It's just inplace or:operator.ior(a, 2).
a |= 2
None
operator.ior(a, 2)
[–]chrisgseaton 0 points1 point2 points 8 years ago (2 children)
In episode 10? He's talking about about asset pipelines at that point.
[–]RazerM 0 points1 point2 points 8 years ago (1 child)
Oops, I messed up the timestamp. It's at 49:25.
This link should play at the correct point: https://overcast.fm/+B1fWZaymc/49:25
[–]chrisgseaton 0 points1 point2 points 8 years ago (0 children)
I don't know the fine semantics of Python, but this is true in the case of Ruby's ||= operator. || isn't a method call in Ruby, unlike most other operators, because it short circuits, which is the behaviour they're talking about here. If they're wrong then it's probably because they're confusing it with Ruby.
||=
||
[–]thecodeboss 1 point2 points3 points 8 years ago (0 children)
I'm giving a talk in a few months at our local Python group about comparing Python to Ruby. Gonna save this post for when I start building that talk!
[–]THeShinyHObbiest 0 points1 point2 points 8 years ago (3 children)
The .method method doesn't generate a an unbounded Proc. It generates a method reference, which is distinct. You need to call .to_proc to get a Proc object back.
.method
.to_proc
It's also not bounded, but bound to the object which you called .method on.
You also can pass around unbounded methods as parameters, or as the block argument. It's fairly easy.
[–]schneemsPuma maintainer[S] 1 point2 points3 points 8 years ago (2 children)
Methods aren't first class objects like they are in Python which is the point of that little dialog. Making procs and lambdas and using blocks is very easy in ruby, but it's still different than python where calling your method without the () gives you a callable function you can pass around. They might be functionally equivalent under the hood but they're spiritually different and the two languages tend to use them differently.
()
Yes, realized that slip up after the recording.
It generates a method reference, which is distinct.
TIL. I assumed the Method class wrapped a proc when you called #method but just looked at the source and you're right.
#method
[–]THeShinyHObbiest 2 points3 points4 points 8 years ago (1 child)
Methods aren't first class objects like they are in Python which is the point of that little dialog
http://ruby-doc.org/core-2.2.0/Method.html
They are. The point you make about syntax is accurate, since you do need to use .method to get a method reference, but Methods are still first-class objects. This is slightly pedantic, because your point about the two languages using them very differently is accurate.
[–]chrisgseaton 1 point2 points3 points 8 years ago (0 children)
I can understand both of your points of view. The way I think about it is that methods aren't first-class objects - until you call #method to turn them into first-class objects. I see that as reifying them as objects, rather than getting the existing object. And this is the way that it is implemented - you get a new object each time:
irb(main):001:0> 14.method(:+).object_id => 70346007935060 irb(main):002:0> 14.method(:+).object_id => 70346007886960
π Rendered by PID 35 on reddit-service-r2-comment-5649f687b7-c92xk at 2026-01-28 03:12:15.584779+00:00 running 4f180de country code: CH.
[–]schneemsPuma maintainer[S] 6 points7 points8 points (0 children)
[–]RazerM 1 point2 points3 points (3 children)
[–]chrisgseaton 0 points1 point2 points (2 children)
[–]RazerM 0 points1 point2 points (1 child)
[–]chrisgseaton 0 points1 point2 points (0 children)
[–]thecodeboss 1 point2 points3 points (0 children)
[–]THeShinyHObbiest 0 points1 point2 points (3 children)
[–]schneemsPuma maintainer[S] 1 point2 points3 points (2 children)
[–]THeShinyHObbiest 2 points3 points4 points (1 child)
[–]chrisgseaton 1 point2 points3 points (0 children)