Live data from Hacker News

Ruby vs. Python comes down to the for loop (2021)

softwaredoug.com

81–90 of 193 posts

Re: Ruby vs. Python comes down to the for loop (2021)

#82
post #52

First impressions apply to languages too. A lot of mathematicians went into AI but didn't start out with any programming experience. They dabbled in some languages and gravitated toward the one(s) they found most useful. Paraphrasing Guy Steele [1]: > It's important that when you design a language that does a familiar thing, that you do the familiar thing exactly... it's criminal that you can write 1/2 and get values…

Having to work with scientists and mathematicians, as in offering my programming help to them... I see no value in making languages look like math formulas.

Math formulas are an awful language. It served its purpose to discover how to do things better, but it became obsolete many decades ago. People who hold on to these ideas create truly awful languages like Haskell. These languages make comprehension prohibitively difficult. So much so that a lot of people who would otherwise benefit from using the language and would have enough mental capacity to appreciate its higher-level concepts are prevented from doing so by a very superficial thing s.a. syntax.

Also, have had you done any math beyond high-school, you'd not have a problem understanding why the result you see in Ruby makes sense. I think some high schools today also include set theory in math curriculum, which would include concepts like closure, domain / co-domain etc. So... this is really not a good example of the concept you mention.

In general, I think that being correct, minimal and internally consistent is a lot more valuable for the language than to be similar to the prior knowledge newcomers might have. It's nice to be also newcomer-friendly, but that shouldn't come at the expense of sacrificing any of the aforementioned desirable properties.

Re: Ruby vs. Python comes down to the for loop (2021)

#83
post #52

First impressions apply to languages too. A lot of mathematicians went into AI but didn't start out with any programming experience. They dabbled in some languages and gravitated toward the one(s) they found most useful. Paraphrasing Guy Steele [1]: > It's important that when you design a language that does a familiar thing, that you do the familiar thing exactly... it's criminal that you can write 1/2 and get values…

0 is also the behaviour of C and of pretty much any serious programming language.

I feel like everyone making comments along this line is completely missing his point.

It's not wrong that 0 is the behaviour of C/Ruby, it's just that 1/2=0.5 is the expected result of much of Python's target audience.

Re: Ruby vs. Python comes down to the for loop (2021)

#84
post #59
post #55

Earlier quoted context omitted.

Notable that this was python behaviour until Py3.

The shift towards // vs / also shows great acumen by the Python designers: they tried (and arguably, largely succeeded) in catering to the greater data science/statistics/numerical analysis communities, where 1/2=0.5 is obvious, rather than sticking to the "compsci-obvious" 1/2=0.

Neither is obvious in either community...

And this isn't the reason Python succeeded. Nor is this the reason for the particular change.

The reason Python succeeded with data-science is NumPy and related group of libraries. They happened to be the first to offer easy access to R-like features of other statistically-flavored languages in an all-purpose language. I.e. it makes it easy to combine general-purpose code with statistics-specific code, and once it accumulated critical mass, the process became self-sustaining and alternatives died off quickly.

The reason for most of the changes that happened to Python in the last fifteen or so years is design driven by fashion. Which means the majority decides what to do with the language. Which also means that Python is made to look more and more like other mainstream languages (eg. Java, JavaScript, C++...) So, a lot of changes, this one included were made out of subconscious fear of non-conformity.

Re: Ruby vs. Python comes down to the for loop (2021)

#85
post #21
post #19

Ruby always seems so appealing. Can anybody tell me how the Ruby ecosystem looks like w.r.t. - (Desktop) GUI - Natural language processing I would really like to learn Ruby, but I can only justify the effort if I can use its ecosystems for some private projects, and I often have been burned by languages not offering too much in those two areas. And speed-wise, as I understand, Ruby is the same ball-park as Python?

Ruby is only relevant because of Rails, and if those two things are your use-cases then you’ll be better off with Python

GUI stuff with Python sucks just as much as it does with Ruby. I.e. if you want to do GUI, don't choose either of these languages.

GUI kind of works best with whatever language the platform for the GUI toolkit wants you to use, but a lot of the time C++ will be that language, competing with JavaScript. Every other language, almost always will end up having bindings, or some other sort of outsourcing mechanism to connect its runtime to either C++ or JavaScript. If you want to just deal with one language when working on a GUI project, it's best to just go with the one the target platform wants you to use.

Re: Ruby vs. Python comes down to the for loop (2021)

#86
post #65

Earlier quoted context omitted.

I made the opposite choice 20 years ago, and could say the same about my choice. But I wouldn't because realistically language choice is largely about what makes you happy. A good dev needs to be a polyglot anyway.

And I chose Ruby about the same amount of time ago, spent 18 years or so writing that professionally, and now write Python for a living. They’re not that dissimilar, if you can use Ruby you’ll pick up Python pretty quickly. (You will however swear profusely now and again as you encounter another incredibly clunky bit of syntax)

Yeah, I'm avoiding Python when I can over the syntax, but I can't always and that's ok - I've used far worse over the years.

Re: Ruby vs. Python comes down to the for loop (2021)

#87
post #52

First impressions apply to languages too. A lot of mathematicians went into AI but didn't start out with any programming experience. They dabbled in some languages and gravitated toward the one(s) they found most useful. Paraphrasing Guy Steele [1]: > It's important that when you design a language that does a familiar thing, that you do the familiar thing exactly... it's criminal that you can write 1/2 and get values…

Okay, I'll bite: how much of this is the responsibility of the language designers versus how much of it is the responsibility of the language user? If I had a junior programmer complain to me about this case, I'd simply tell them "you didn't RTFM", because RTFM'ing before you use a language is not only the professional thing to do, but vital to your accurate and correct use of the language. Sure, language designers s…

Having a full numeric tower and stuff like having 1/2 evaluate to 1/2 (like in Scheme) definitely is the language designer's responsibility.

Re: Ruby vs. Python comes down to the for loop (2021)

#88

Earlier quoted context omitted.

0 is also the behaviour of C and of pretty much any serious programming language.

I feel like everyone making comments along this line is completely missing his point. It's not wrong that 0 is the behaviour of C/Ruby, it's just that 1/2=0.5 is the expected result of much of Python's target audience.

But it's not. In second grade I was taught that 1/2 is 0 (with a remainder of 1). Fractions, real numbers, complex... are taught afterwards.

Re: Ruby vs. Python comes down to the for loop (2021)

#89

Hmm I'm no Python fan but I'd take it over Ruby any day, because it's so much easier to read a codebase. This is based on me trying to follow Gitlab's code. The problems with Ruby seem to be: * No static typing (I think there is Sorbet but apparently it's not very good and Gitlab doesn't use it). * The lack of "syntax" makes it hard to grep for things. For example you can't find where `foo` is called by searching for…

Since when does Python have proper static typing? Also, why grep in the age of lsp?

Re: Ruby vs. Python comes down to the for loop (2021)

#90
post #52

First impressions apply to languages too. A lot of mathematicians went into AI but didn't start out with any programming experience. They dabbled in some languages and gravitated toward the one(s) they found most useful. Paraphrasing Guy Steele [1]: > It's important that when you design a language that does a familiar thing, that you do the familiar thing exactly... it's criminal that you can write 1/2 and get values…

[deleted]
Post reply on HN