Hacker News new | ask | show | jobs
by _qc3o 3388 days ago
Not just visually. It is also conceptually much more aesthetically pleasant. I still don't know how metaclasses, descriptors, __magic__ methods, multiple inheritance, all the different string formatting schemes, generators/co-routines, etc. work in Python. The amount of stuff you have to learn in Python is a lot more than in Ruby.
1 comments

> The amount of stuff you have to learn in Python is a lot more than in Ruby.

I couldn't disagree more with this.

Python is pretty thin when you get down to it. Magic methods alone are 80% of the way to knowing how everything in Python works.

Multiple inheritance in Python is way simpler than the two-pronged inheritance scheme of Ruby, where you have both a parent class and modules (which can be loaded either before or after the parent class) to deal with. Want to see what order ancestor classes are applied? `object.__class__.__mro__`. Done.

Meawhile, in Ruby, you can call a function like this - `my_function(a, foo: 1, bar:2)` - and it feels like you're passing keyword parameters... but Ruby doesn't support keyword parameters. Instead, it's implicitly creating a Hash that's getting passed as the second parameter. Even more confusing, every function has an implicit "block" parameter that can be passed to it, and is silently ignored by default.

Ruby has had keyword arguments for a while now: https://robots.thoughtbot.com/ruby-2-keyword-arguments
Interesting - I remember reading a proposal for this, but I've never seen them in production code.
It's odd... I have relatively little Ruby or Python experience, but I have a kind of undefined affection for Ruby but if I'd have to choice at gunpoint I'd go for Python.

I think the reason is that while Ruby does feel more 'pleasant' to me, especially the me that is new to programming, Python feels less vague, and I've grown to hate vagueness in my code.

I'd probably recommend Python to new coders at this point, but for web development I would probably still opt for Ruby on account of Rails and the Rails Tutorial. If there was an equivalent to the latter, I'd go for Python though (suggestions?).

I can't vouch for it myself, but the Django Girls tutorial [1] is the resource I hear recommended most often for learning Django without any prior programming experience.

[1]: https://tutorial.djangogirls.org/en/

> .. but Ruby doesn't support keyword parameters

Your information is outdated, and only applies to Ruby 1.x. Ruby added real keyword arguments in 2.0, and declaration of mandatory keyword arguments in 2.1.