News for hackers. Stuff that matters.
Re:An Ode to Ruby by Mikeb85 on Monday January 10, 2022 @11:06AM (#29876903)
Ok, that's a nicer result (obviously I don't write Python lol) but still seems inconsistent to me (putting the function before the array) considering Python is an OO language and most people are going to be writing methods for classes where you call methods with dot. I just remember list comprehensions from Coffee-script and not going to lie, I hate them. It's like reading backwards.
Re:An Ode to Ruby by knodi123 on Monday January 10, 2022 @12:05PM (#29877860)
> still seems inconsistent to me (putting the function before the array)

I'm experienced in ruby, and learning python for a project. I don't think I'll ever not wince when using python's ternary;

ruby: size = (waist > 30) ? 'large' : 'small'

python: size = 'large' if (waist > 30) else 'small'

Re:An Ode to Ruby by cle on Monday January 10, 2022 @12:31PM (#29878306)
I've always assumed this was to maintain syntactic consistency with comprehensions like [x for x in arr if x > 2].
Re:An Ode to Ruby by iterati on Monday January 10, 2022 @11:08AM (#29876932)
Python is a multi-paradigm language, of which OO is one paradigm it supports.
Re:An Ode to Ruby by Mikeb85 on Monday January 10, 2022 @11:21AM (#29877143)
Ruby has map, filter, reduce and a bunch of other functional methods. It's more about the consistency of wondering what's a function versus what's a method and then things like list comprehensions and for loops. Python also doesn't have a lot of the goodies of a real functional language, it encourages for loops and seems to be even more procedural than Ruby but less OO?
Re:An Ode to Ruby by cutler on Monday January 10, 2022 @10:04PM (#29886860)
Not really. Python 3 is all OO under the hood including what appear to be procedural functions. It's just not as elegant as Ruby's OO.
Re:An Ode to Ruby by jimbokun on Monday January 10, 2022 @02:46PM (#29880813)
Ruby is a strongly OO language, which arguably also has better support for functional programming than Python.
Re:An Ode to Ruby by cutler on Monday January 10, 2022 @10:05PM (#29886876)
Yes, that's the Zen of Ruby and why I love it.