Live data from Hacker News

Why Ruby Is More Readable Than Python

confuzeus.com

131–140 of 149 posts

Re: Why Ruby Is More Readable Than Python

#131
post #99

Earlier quoted context omitted.

In Ruby if else is not a method for some reason also blocks are not objects for some reason "seems inelegant"

> In Ruby if else is not a method for some reason This is because there’s not a good way to pass two delayed computations - two blocks. Looping constructs were replaced by method variants. > also blocks are not objects for some reason Yeah they’re reifiable but not sure why not reified by default.

But passing two blocks/lambdas/etc doesn't inherently need to be that difficult it's not in other languages.

I don't know that much about Ruby's implementation but I think both the if else and blocks not being objects are that way to prevent Ruby from being even slower. My understanding is if you turn a block into a proc it gets a lot slower.

Re: Why Ruby Is More Readable Than Python

#132
post #12
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.

Use the Active Voice.

New Rails 8 feature? (I’ll see myself out).

Re: Why Ruby Is More Readable Than Python

#133

Earlier quoted context omitted.

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

What an extraordinarily patronising response ! Firstly, not 'scared', 'scarred' - merely a bit of harmless hyperbole to indicate a briefly frustrating situation. Secondly, this is not monkeys-at-typewriters, merely an expectation that Python would conform to any other object-based language and have a public method on string to report its length. This should be a discoverable, not an RTFM case.

While I agree with you the grandparent was unnecessarily patronizing, they do have a point. “Built-in functions” is the first chapter of the documentation following the introduction, there’s no way to miss it. If you don’t even skim the introductory documentation, I’m not exactly sure what you expect to happen. Python is not Ruby nor is it Java, and it predates both. Why would it follow the idioms of those languages?

Re: Why Ruby Is More Readable Than Python

#134

Earlier quoted context omitted.

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

What an extraordinarily patronising response ! Firstly, not 'scared', 'scarred' - merely a bit of harmless hyperbole to indicate a briefly frustrating situation. Secondly, this is not monkeys-at-typewriters, merely an expectation that Python would conform to any other object-based language and have a public method on string to report its length. This should be a discoverable, not an RTFM case.

It does have a public method, __len__(). It’s a protocol method that’s more discoverable than size/length/len/count or whatever other ad-hoc name.

Re: Why Ruby Is More Readable Than Python

#135
post #62
post #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 assertio…

PHP has a bunch of hacks that are here for technical reasons. Function names are inconsistent and terse because they were inherited from C, and there is the historical name-resolution quirk. The prefixed variable names don't bring anything and are not here for any good reason (compared to shell where "naked" identifiers are interpreted as strings). A lot of the object-oriented features had to settle for unusual token…

What’s the historical name resolution quirk?

Re: Why Ruby Is More Readable Than Python

#136

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…

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 working on it from the start to teach me how to find/read and debug everything the "Ruby" way.

Re: Why Ruby Is More Readable Than Python

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

People keep saying this (especially here, lately) but it's a nonsense strawman argument. People can do stupid and sufficiently unreadable things in any language. Further, at sufficient scale - a large, long lived proprietary codebase - it hardly matters, it becomes the local dialect.

Re: Why Ruby Is More Readable Than Python

#139
Ah, that's why my analytics is showing HN traffic. OP here. Thanks for sharing my friend.

I'm not a Ruby programmer but I wrote this post while learning Ruby and after having read through the entire Sinatra code base. I was surprised at how much easier Ruby code is to read even though I've been a Python programmer for the past 6 years.

Re: Why Ruby Is More Readable Than Python

#140
post #134

Earlier quoted context omitted.

What an extraordinarily patronising response ! Firstly, not 'scared', 'scarred' - merely a bit of harmless hyperbole to indicate a briefly frustrating situation. Secondly, this is not monkeys-at-typewriters, merely an expectation that Python would conform to any other object-based language and have a public method on string to report its length. This should be a discoverable, not an RTFM case.

It does have a public method, __len__(). It’s a protocol method that’s more discoverable than size/length/len/count or whatever other ad-hoc name.

Yes I'm aware, and yes it's 'public' in the sense that all Python methods are but my point was that it is not meant to be called directly. The whole argument as to whether or not this is a superior mechanism was exactly the cause of heated debate the first time around and something I was keen to avoid here!
Post reply on HN