Live data from Hacker News

Why Ruby Is More Readable Than Python

confuzeus.com

141–149 of 149 posts

Re: Why Ruby Is More Readable Than Python

#141

Earlier quoted context omitted.

> I chalk that up to the higher pain threshold for doing really obnoxious metaprogramming in Python If you're going to quote it, don't you think you should quote the whole thing? The whole point of making the pain threshold higher for certain kinds of metaprogramming painful and obvious. I think that is a good thing. You can use it when you need to, but when it comes up in a code review, it's extremely obvious that y…

The important thing for me is that the pain is by design. That someone thinks it’s good for me doesn’t justify the deliberate application of pain to me. I don’t mind that “it works on your machine.” My distaste for Python’s philosophy is my distaste. I simply think my life is richer without aspirations to be Pythonic. And now I can put my finger on why. Thanks.

It sounds like we're talking past each other. It appears to me (and I may be wrong here) that for you, writing code is an activity that you partake in for pleasure, or otherwise aesthetic or artistic reasons. For me, while there are elements of writing code that are pleasurable, I predominantly engage in it in a professional setting, to get business goals accomplished.

In the former case, I think that having a "distaste for it[Python]'s philosophy" where one's life is "richer without aspirations to be Pythonic" is pretty reasonable.

In the latter case, there isn't as much room for that. Instead, the more practical considerations I mentioned predominate: the question is how to get the most mileage out of language in a large organization to accomplish large, complex business goals with technology in a durable way.

It's not to say that one or the other is more important (I think there is plenty of space in this world for both), but I would say that the vast majority of ecosystem space around programming languages is and very likely always will be taken up by the latter use case. If you're curious about why things are the way they are (which you may not be, or which you may simply not care about, or which may simply not apply to you), then I think it's worth considering.

Re: Why Ruby Is More Readable Than Python

#143
post #136

Earlier quoted context omitted.

That really mirrors my experience as well. Ruby is a very consistent language but I think one of the things people get really enamored with Ruby is the meta programming -- myself included and soon you're going to need a bunch of context in your head to understand all the "magic" that's happening.

I feel this comment so much. Having never done Ruby programming and was given a task from a client to work on a Ruby project. I didn't think much at the time because having dealt with all kinds of programming challenges I was confident in taking it on. Much to my surprise the amount of "magic" methods, meta-programming and anonymous classes in the source code required a lot of hand holding from the devs who had been…

> required a lot of hand holding from the devs who had been working on it from the start to teach me how to find/read and debug everything the "Ruby" way.

Yes. And even just _finding_ relevant bits of code is difficult and painful, because you can't simply `grep` for the names of these metaprogrammed methods. They're simply not in the codebase.

Re: Why Ruby Is More Readable Than Python

#145
What I enjoy about Ruby over Python the most is not intricacies of the OO implementation or delicacies of metaprogramming, but a good support for functional style. In ruby, statements are expression-like, they have a return value. Also, with Ruby it's easy to break down code to consecutive pure blocks.

Condiser the following task: take /proc/kallsyms in Linux, that lists symbols in kernel, in an ' ' format, like:

  0000000000000000 A fixed_percpu_data
  0000000000000000 A __per_cpu_start
  0000000000001000 A cpu_debug_store
  0000000000002000 A irq_stack_backing_store
  0000000000006000 A cpu_tss_rw
  000000000000b000 A gdt_page
  ...
let's make stats on it -- how much of each type is present? Wanna get the result ordered by number of occurrence.

In Ruby:

  # ruby -rset -e '$1,
   "w"=>2,
   "a"=>14,
   "R"=>98,
   "W"=>154,
   "A"=>328,
   "B"=>655,
   "D"=>2910,
   "b"=>3097,
   "T"=>22289,
   "d"=>34424,
   "r"=>49904,
   "t"=>55346}
Of this method call chain, first and last are impure (as they do I/O), the intermediate ones are pure.

In Python you'll have to grind through it procedurally. (Unless you use reach out to some advanced libs... https://gist.github.com/richardbann/5b363096de6b3de2e8178cce...)

Re: Why Ruby Is More Readable Than Python

#147
post #94

Earlier quoted context omitted.

Yeah, Ruby is like poetry. Most poetry is like https://hitchhikers.fandom.com/wiki/Vogon_poetry . And the worst is that I'm unable to do poetry . --- I'm enthusiast about learning about languages, and enjoy everything I see about APL, Ruby, Scheme, Forth, Haskell, etc. I actually LIKE the concepts. Is kind of relaxing take a look around the basic tutorial or read what the "good" poets say about that. But my instinct…

I can answer this. Ruby is my favourite language! Am I a haiku

Well, the second verse

has an extra syllable,

but that's fine by me :)

Re: Why Ruby Is More Readable Than Python

#148
Not on topic but a little rant about dark themes. After years of reading code displayed in dark mode on a white page (high contrast), I still wonder why. It's really hard to see, at least for me. Most of the time, I end up selecting the whole piece of code to have white text on a black background - it's not as good as black text on a white background, but it's much better than dark blue or dark red on a black background.

This interesting article uses dark red for operators (".", "=", "<", etc.). This is one of the worst choices. On a dark background, please do not use dark color.

Re: Why Ruby Is More Readable Than Python

#149
post #74

Earlier quoted context omitted.

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.

In python you can ‘from foo import bar, buzz’ and get JUST those two functions, without having to prefix them or clobbering your namespace. This really nice when the one function you need is giantlib.helpers.foobar.convert_baz_to_qux - it’s both less bytes (especially if you are calling it a lot) and more importantly to the next reader of the code it means that c_b_to_q is the only thing you’re using in giantlib

I see. Yeah because of this Ruby kind of pressures thoughtful coders into small modules. Heck, I created Ruby Facets and it’s basically one method per file!
Post reply on HN