Live data from Hacker News

Why Ruby Is More Readable Than Python

confuzeus.com

51–60 of 149 posts

Re: Why Ruby Is More Readable Than Python

#51
Does Ruby have support for just exporting functions around? All these examples are class based. When I was a Python programmer, we found functions scaled infinitely better over time (with the exception of data classes, unfortunately) for complex business logic especially.

Re: Why Ruby Is More Readable Than Python

#53
Surely there's a correlation between ease of reading and ease of compilation?

I'm thinking in terms of avoiding back-tracking in your syntax.

E.g.: regices are hard as shit to read, and I don't think that back-tracking helps

   (ab + c)*
Or

   *+(ab, c)
The first says ab, no - it's the union of ab and something, something is c, no - it's one or more of those.

The second says one-or-more of the union of (ab) and (c).

Why haven't languages pushed that way?

Re: Why Ruby Is More Readable Than Python

#55

Does Ruby have support for just exporting functions around? All these examples are class based. When I was a Python programmer, we found functions scaled infinitely better over time (with the exception of data classes, unfortunately) for complex business logic especially.

No, unfortunately. This is one thing I've always wished Ruby had.

Re: Why Ruby Is More Readable Than Python

#56

I find Ruby to be more straightforward than Python. In isolation, I’d argue Ruby is greatly more readable and understandable than Python. In practice, Ruby code isn’t. Once someone starts doing advanced meta programming, get the shovel, because you’re going to kill whoever wrote it and need to bury the body. Rails largely gets away with this by having opinionated design, good documentation, and a large user base who…

I think that misses the point. Ruby doesn’t have macros! The metaprogramming makes it possible to create very readable DSLs but it’s all very consistent not “magical” like macros.

At the end of the day coding is hard. I’d rather have nice DSLs to learn than verbose spaghetti to read.

Re: Why Ruby Is More Readable Than Python

#57
The article closes with this thought:

> While both languages are much easier to read than say, PHP or Java, [...blah blah blah...]

Which leads me to wonder: Have there been any serious studies of the readability of programming language syntactic and semantic conventions? For instance, a good friend of mine (whose day job is working as a software consultant, and whom I imagine would disagree with the author's assertion) finds it extremely difficult to understand python code in particular due to his dyslexia, and I wonder how common such problems are, both as a % of people and % of programming languages.

Re: Why Ruby Is More Readable Than Python

#58

I find Ruby to be more straightforward than Python. In isolation, I’d argue Ruby is greatly more readable and understandable than Python. In practice, Ruby code isn’t. Once someone starts doing advanced meta programming, get the shovel, because you’re going to kill whoever wrote it and need to bury the body. Rails largely gets away with this by having opinionated design, good documentation, and a large user base who…

> Once someone starts doing advanced meta programming, get the shovel, because you’re going to kill whoever wrote it and need to bury the body.

This is why Elixir makes me hate life sometimes. They took a language like Erlang where it seemed almost impossible to write an unreadable program even when it was doing very sophisticated things, and Rubied it up.

Re: Why Ruby Is More Readable Than Python

#59
post #9

Subjective opinion presented as fact? Say it ain't so.

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.

What concerns me is that I see quite a lot of writers who don't know the difference between fact and opinion. Without that, the reader doesn't have much hope. Especially when the writer has some incentive to muddy the waters.

I'm all for pieces clearly from a personal perspective. There one can drop the redundant "I think" bits. But often dropping the qualifier turns it from a statement about one person to a universal statement, as with the title of the article. For me this erases the many interesting possibilities in between.

For example, a post title something like, "Which programmers find Ruby more readable than Python?" is way more interesting. The universal is false, but I'm sure it's true for some people and false for others. An exploration of that could lead to interesting ways to think about languages. E.g., is it better for novice programmers? For programmers from non-engineering backgrounds? For programmers with difference cognitive styles or capabilities?

Re: Why Ruby Is More Readable Than Python

#60

Does Ruby have support for just exporting functions around? All these examples are class based. When I was a Python programmer, we found functions scaled infinitely better over time (with the exception of data classes, unfortunately) for complex business logic especially.

Not sure what you mean.

You can do…

    module Foo
      extend self

      def bar
        “Bar!”
      end
    end

    Foo.bar #=> “Bar!”

And you can include that module in other modules. No classes required.
Post reply on HN