Live data from Hacker News

Why Ruby Is More Readable Than Python

confuzeus.com

31–40 of 149 posts

Re: Why Ruby Is More Readable Than Python

#31

Ruby, like so many other good things, is best enjoyed alone :-) I've loved every Ruby codebase that I've written. I still consider it one of my favorite programming languages, and (in pedagogical terms) one of the best languages for learning "practical" functional programming (point-free style, blocks as intuitive closures, &c.). But when I work with others, I find that all of the things that I love are obnoxiously c…

My theory is this is also why Lisp never took off. Powerful macros are wonderful for the solo programmer but difficult for a large team to reason about.

Re: Why Ruby Is More Readable Than Python

#32
post #9

Earlier quoted context omitted.

This is a matter of style; we encourage writers to write this way and trust that readers know the difference between fact and opinion. Go through a typical college writing class and the teacher will direct you to delete phrases like “I think” and “I believe” from your writing.

I get this, and I've started to write this way, because it gets a better response; but it feels to me like it's designed to maximize an emotional response and not a cognitive response, and find I have less trust in people who write this way (Which is most things, i get) I do wonder how this style of writing has impacted the psychology of argument, I imagine there are others who read this style of writing and assume i…

I have to say I appreciated but also laughed at the sheer number of the qualifiers you're discussing in your post... "it feels to me", "I find I", "I do wonder", "I imagine", "this may"

I find it makes for less combative discussions. So I like it.

Re: Why Ruby Is More Readable Than Python

#34
post #13

Until metaprogramming, autoloading, DSLs and everything that eventually makes Ruby code unreadable takes place due to personal preferences. Ruby is clever, it can be beautiful, but I've never seen a good codebase using it grow well without enforcing strictly opinionated ways of writing it to ensure maintainability. Which breaks a lot of the expectations of some Ruby developers that chose the language because they lik…

> Ruby is clever, it can be beautiful, but I've never seen a good codebase using it grow well without enforcing strictly opinionated ways of writing it to ensure maintainability. Which breaks a lot of the expectations of some Ruby developers that chose the language because they like to write it in their own way.

Yeah, this is one of the major disadvantages of Ruby. Every Ruby shop of any size has its own idioms and internal code style, which means a lot of unnecessary overhead when onboarding new people. Even experienced devs need to take some time to feel out their team's norms.

The expressiveness also lends itself to bike shedding - I've seen many a PR comment questioning why a dev chose method A versus method B, where method B is an alias of method A. Probably an hour of staff time spent on something that has zero impact on functionality, maintainability, or performance.

Re: Why Ruby Is More Readable Than Python

#35

Earlier quoted context omitted.

Weird criticism. If I say that halloumi is better than tofu, do you not assume I'm talking about my personal opinion? Do I need to make it painfully clear that it's my subjective opinion? Taste, as much as readability, are subjective so that can be assumed. Also, if you read the post, you'll have noticed the author is constantly saying "I find this more readable", and engaging the reader with "what do you think?" que…

> Do I need to make it painfully clear that it's my subjective opinion? Yes. Because a sentence written in the Arial font, as much as I might find that font distasteful, is more readable than the same sentence written by a Captcha-generator. A bubble-sort written in Golang is easier to read than the same bubble-sort written in Brainfuck. Yes, there are exceptions to the rule (I imagine someone who knows Brainfuck, bu…

Every sentence said by a person is their opinion. That's what saying things is.

Even the "obvious" counter-example, lying, works because every sentence said by a person is their opinion. You couldn't lie if it wasn't.

Re: Why Ruby Is More Readable Than Python

#37

Earlier quoted context omitted.

Yes, you can replace attributes with properties without changing the consuming code. For example: >>> class Foo: ... @property ... def bar(self): ... return "hello from a property" ... @bar.setter ... def bar(self, value): ... print(f"tried to replace bar with {value}") >>> Foo().bar 'hello from a property' >>> Foo().bar = "asdf" tried to replace bar with asdf

I know it's completely subjective and intellectually irrelevant, but wow I think those annotations are super ugly. In Ruby it's all just method calls - properties, methods, user control-flow, everything.

It's all just method calls in python too!

    @foo
    def bar():
      ...
Is just syntactic sugar for:

    def bar():
      ...
    bar = foo(bar)

Re: Why Ruby Is More Readable Than Python

#39
post #31

Ruby, like so many other good things, is best enjoyed alone :-) I've loved every Ruby codebase that I've written. I still consider it one of my favorite programming languages, and (in pedagogical terms) one of the best languages for learning "practical" functional programming (point-free style, blocks as intuitive closures, &c.). But when I work with others, I find that all of the things that I love are obnoxiously c…

My theory is this is also why Lisp never took off. Powerful macros are wonderful for the solo programmer but difficult for a large team to reason about.

Programmers are not Computer Scientists, and the world is poorer for their conceit.

Re: Why Ruby Is More Readable Than Python

#40
There's more than one way to write the corresponding Ruby snippet. If I had been writing it, I might have translated it something like this:

    class BlogPost
      class 
This avoids needing to understand what `@@count` means, and lets you use the same syntax as in python: `BlogPost.count += 1`.

Or, if I were in a codebase using static type annotations with Sorbet, I'd do something like this[0]. To each their own, write code in the language and style that makes the most sense to you.

[0] https://sorbet.run/#%23%20typed%3A%20true%0Aclass%20Module%3...

Post reply on HN