Live data from Hacker News

Why Ruby Is More Readable Than Python

confuzeus.com

101–110 of 149 posts

Re: Why Ruby Is More Readable Than Python

#101

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…

I chalk that up to the higher pain threshold I never could quite articulate why Python doesn’t resonate with me without hyperbole or snark or both. But that’s it. Python’s design includes inducing pain deliberately with the rational that I deserve it. Don’t misunderstand me. I think Python is useful. It is just that I don’t find it enjoyable and I inflict enough pain on myself with my code.

It’s not that you “deserve it”… it’s more like having an electric fence, the non lethal kind used by farmers all around the world to stop various livestock from knocking over fences in an attempt to eat the grass or mate with the animals in the next field over. It’s a strong discouragement. It’s unpleasant enough that collectively everyone just avoids it, why put yourself through the pain to do it that way when there’s another way to get it done that’s not going to hurt.

Re: Why Ruby Is More Readable Than Python

#102
Both options looked bad from the start, and only got worse. Why do I need a class with getters and setters, in-place mutation, a pointless toString and a (mutable!) static count variable, instead of:

  {
    title: “a grumpy programmer’s rant about objects”, 
    body: “Wait, hear me out y’all…”,
    published: true
  }
Both the Python and ruby examples have no post-ID, so mutating in-place is an extra-bad idea. It should not be the default.

Why does the static count variable exist? These things are all stored in some list (memory, db, whatever, perhaps multiple places) and we can count any subset of those that fits our purpose. What happens when I’m asked to add draft posts? Should I only update the count only if published == true? It depends on whether I’m looking at “number of blog posts” as a user or “my drafts” as an author.

Why does the toString exist? Nobody uses those in real app code for end-users, they are a convenience for developers. Use a better REPL/debugging environment that can handle pretty-printing data. If you need more customization, use a function.

Please, just use plain data wherever possible. Please use languages that support and encourage using plain data. Please push mutation to the edges of the system, and please carefully control the in-place updates. The computers in our pockets are more powerful than anything that existed on earth before 199x, yet the industry is still acting like we’re running them on 8086 microprocessors with 640k RAM.

Let’s grow up and think more deeply about building robust systems which can evolve with changing needs.

EDIT: Changed published to true, because this is basically that.

Re: Why Ruby Is More Readable Than Python

#103

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…

I chalk that up to the higher pain threshold I never could quite articulate why Python doesn’t resonate with me without hyperbole or snark or both. But that’s it. Python’s design includes inducing pain deliberately with the rational that I deserve it. Don’t misunderstand me. I think Python is useful. It is just that I don’t find it enjoyable and I inflict enough pain on myself with my code.

> 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 you are reaching for a powerful tool which can (and in my experience, almost always) impedes ease of code readability and reasoning about behavior. These things are toxic to growing organizations with growing teams.

It sounds a reach to misconstrue that the design "includes inducing pain deliberately with the rational that I deserve it" -- it's not that you deserve it, per sé, but you may not be using it for the use case it was intended for.

My use cases have spanned decades of experience across dozens of organizations serving billions of dollars of industrial strength pressure. Having used other languages (including Ruby, Java, Go, Scala, Cxx), accounting for tradeoffs between ecosystem maturity and language flexibility, it remains my overall top choice for getting work done and building durable, maintainable codebases.

Re: Why Ruby Is More Readable Than Python

#104
post #89

Earlier quoted context omitted.

Absolutely. DSLs are a great application of metaprogramming. Same with libraries like ActiveRecord. Metaprogramming in a pull request at work? Nope. I'm going to smack some knuckles with a ruler. :)

Depends. In library code? Great (probably). In application code? That's a paddlin'.

I chuckle-snorted at the Simpsons reference. Thanks you for that.

Re: Why Ruby Is More Readable Than Python

#105
post #59

Earlier quoted context omitted.

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 universa…

This has always been true. However, the way that you should distinguish fact from opinion is analyzing the content. You should not rely on other people to explain to you which things are facts and which things are opinions. In a world where people (in general) are capable of distinguishing fact from opinion (most of the time), you can omit the "I think", "I believe", "I feel" crap. In a world where people are bad at…

That the reader should distinguish fact from opinion in no way absolves the writer of doing that first and expressing clearly which is which.

Re: Why Ruby Is More Readable Than Python

#106
post #59

Earlier quoted context omitted.

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 universa…

> "Which programmers find Ruby more readable than Python?" What if you don't care about analyzing the psychologies of programmers, and just want to say why one thing is more readable than another thing?

Readable for whom? And how could you possibly understand why something is readable for a given person or group without touching upon psychological topics? Reading is a mental experience that varies from person to person in many ways. Reading code even more so.

Re: Why Ruby Is More Readable Than Python

#107

Earlier quoted context omitted.

I chalk that up to the higher pain threshold I never could quite articulate why Python doesn’t resonate with me without hyperbole or snark or both. But that’s it. Python’s design includes inducing pain deliberately with the rational that I deserve it. Don’t misunderstand me. I think Python is useful. It is just that I don’t find it enjoyable and I inflict enough pain on myself with my code.

> 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.

Re: Why Ruby Is More Readable Than Python

#108

Moving to Python from Ruby, one very early scarring experience was battling trying to get the length of a string, before eventually discovering len() - a free function, whereas in Ruby (OO purist that it is), everything is a method. Well I thought this was rather silly and counterintuitive of Python, and said so in some forum or other, whereupon i discovered the very passionate views of folks who have come down hard…

> was battling trying to get the length of a string

This makes it sound like you where trying to learn the language by typing in random stuff and just hoping something runs.

Yes every language will leave you scared if your path to learning it doesn’t even involve reading a single page about its most basic functioning.

Re: Why Ruby Is More Readable Than Python

#109

Earlier quoted context omitted.

I chalk that up to the higher pain threshold I never could quite articulate why Python doesn’t resonate with me without hyperbole or snark or both. But that’s it. Python’s design includes inducing pain deliberately with the rational that I deserve it. Don’t misunderstand me. I think Python is useful. It is just that I don’t find it enjoyable and I inflict enough pain on myself with my code.

It’s not that you “deserve it”… it’s more like having an electric fence, the non lethal kind used by farmers all around the world to stop various livestock from knocking over fences in an attempt to eat the grass or mate with the animals in the next field over. It’s a strong discouragement. It’s unpleasant enough that collectively everyone just avoids it, why put yourself through the pain to do it that way when there…

I’d rather eat well and get laid. YMMV.

Re: Why Ruby Is More Readable Than Python

#110
post #31

Earlier quoted context omitted.

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.

I think this is a tooling problem, as far as LISPs go, because unlike C, you (as far as I remember, perhaps I'm wrong) aren't relying on the compiler to fill in the bits, the macro is just a shortcut, if you will, to functionality. Not always transparent, but it should be solved with correct tooling. I think the bigger problem was LISP was far too long tied to LISP Machines, rather than being able to run independentl…

Lisp itself precedes the Lisp Machines for about 20 years, and was available in UNIX workstations as well, in fact that is where Allegro Common Lisp started.
Post reply on HN