Hacker News new | ask | show | jobs
by yedpodtrzitko 1428 days ago
I read through the article waiting the whole time to see that "this is more readable", but I found nothing. Also I'm not sure if the Python examples are so blatantly wrong on purpose or if the author read one Python tutorial beforehand and then decided to write this article. For example this:

> In Python, you will never do post.__str__ for example. Instead, you’ll do str(post)

No you dont. You do the same thing you did with `puts post` in your Ruby example: `print(post)`, which will call `__str__()` method.

> In Python, it’s easy to accidentally write to the count attribute — which can break your program.

To address writing into attribute directly - you can use @property decorator, which will stop you into writing into given attribute, unless you add a setter.

However the main problem in this fabricated example wouldnt be that you can break your program by accidentally writing into an attribute. I'm not sure how common is it in Ruby, but mixing the instance variables together with class variables this way seems like a bad design, and that is what will break your program.

Regarding the Django example - ok that is far from perfect, but comparing a framework which maintains backward compatibility for years with code you write from scratch without worrying about anything is barely a fair comparison.