Live data from Hacker News

Python for Ruby Programmers (LA RubyConf 2013)

speakerdeck.com

1–10 of 54 posts

Re: Python for Ruby Programmers (LA RubyConf 2013)

#4
Weird that author never mentioned PEP8 guide. I think it's the main thing that difference Python from Ruby developers. If you follow the PEP8 rules, you can interact with other Python programmers without much problems, and enforce you to be a better and organized programmer.

Re: Python for Ruby Programmers (LA RubyConf 2013)

#6
Not bad, but the big weakness is that the author seems to be very familiar with more expert-level aspects of Ruby, but not so much with Python. And turns that into "Python doesn't have these".

For example, he mentions Python doesn't have an equivalent of method_missing -- it's technically true that there's nothing you define on a Python class to specifically intercept a nonexistent method, but that's because Python's standard facility for this operates more generally at the level of attribute access. Suspect there's a bit too much expectation of Python to be message-passing like Ruby in not seeing that one.

Similarly, Python has plenty of metaprogramming features, they're just implemented differently -- and from a different conceptual standpoint -- than Ruby's. And so on and so forth.

Re: Python for Ruby Programmers (LA RubyConf 2013)

#7

Not bad, but the big weakness is that the author seems to be very familiar with more expert-level aspects of Ruby, but not so much with Python. And turns that into "Python doesn't have these". For example, he mentions Python doesn't have an equivalent of method_missing -- it's technically true that there's nothing you define on a Python class to specifically intercept a nonexistent method, but that's because Python's…

There are also a few non-idiomatic practices he seems to favor. For example, he seems to advocate use of `filter`, `map`, `reduce` in a few places, which, in Python, are better expressed with list comprehensions, combined with builtins like `sorted`, `all`, `any`, `sum`, etc. Adding the `operator` module opens up even more functional constructs without ever touching `map`, `reduce`, or `filter`.

Re: Python for Ruby Programmers (LA RubyConf 2013)

#8
I know very little of Ruby, but difference 13 states that Ruby has stronger metaprogramming features in that "Python doesn't have define_method, class_eval, and method_missing". Are these really things that can't be implemented with metaclasses and overloading __getattr__?

Re: Python for Ruby Programmers (LA RubyConf 2013)

#9
The presentation incorrectly identified Python dictionaries as “lists”. It also identified actual Python lists as lists.

The presentation states that tuples are “immutable lists“ and that they ”should be homogeneous, but [this is] not enforced“. I disagree: tuples are meant to act as “records“ (as in a database or other set of data), which are neither lists nor homogeneous.

The presentation brought up multiple times filter and map. An article by Guido in 2005 [1] argued that these tools should be cut from Python 3. While they still exist, I am under the impression it is considered more Pythonic to use list comprehensions in the place of filter and map, as stated in the article.

Python not having define_method is misleading. One can define a method of a class as one would any attribute of the class [2]. However, it is far easier to dynamically define a method in Ruby than in Python, because lexical scoping is inherent to a Ruby block but not a Python loop.

Python not having method_missing is wrong. One can simply override __getattr__ and return the appropriate function [3].

[1]: http://www.artima.com/weblogs/viewpost.jsp?thread=98196

[2]: http://ideone.com/njXDzO

[3]: http://ideone.com/EB9MQ8

Post reply on HN