Live data from Hacker News

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

softwaredoug.com

31–40 of 193 posts

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

#31

This is because Ruby inherits it's approach to flow control from Smalltalk, while Python comes from a C/Algol-like heritage. In fact, Smalltalk takes this much further, such that basically all flow control (including if-then-else) is handled as message sends (e.g. if-then is just a message sent to the Boolean object taking a block as it's argument). The downside is the syntax can feel a tad clunky. The upside is incr…

[flagged]

> I feel like each new language absolutely needs to reinvent existing standards that have proven effective, just so that it feels unique. I don't have any experience with Ruby in particular, but every time a tool does some basic thing like a for loop "in a new, innovative way"

You're talking about a 25 year old decision.

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

#32
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?

You can explore Rubys ecosystem at ruby-toolbox.com

I’d say Ruby is a joy to use, there is this gem (package) for gui development called glimmer, you shoukd check it out.

Though, if you are going to focus on the scientific field, I think Python is more suitable.

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

#33
post #29

What I like in Ruby: Every expression returns a value. In Python my_list.sort() will return `none`. So if I do `sorted_list = my_list.sort()`, my `sorted_list` will be `none`. And I have been shooting a lot in my foot in the beginning. - I love Python now, but not because I find it aesthetically appealing (I prefer Lisps or functional languages) but because it is ubiquitously available, the ecosystem is phantastic, a…

end, curly braces, same same. The deviation is IMHO Python with its intention oriented block creation. Which is a debate on its own ;).

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

#34
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 `foo(` or `.foo` like you can in Python.

* It seems to encourage highly dynamic code where even identifiers are dynamically created, so often you'll find an identifier, and try to search for its definition but get zero results.

Maybe it's elegant and nice to write, but it's definitely awful to read.

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

#35
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?

Glimmer is a award winning GUI Toolkit for ruby which supports every major platform (gtk, qt, wxwidgets, swt, swing, java fx, etc), it can also output as SVG or CSS: https://github.com/AndyObtiva/glimmer Glimmer has been around for a while and is in active development.

Here is a extensive list about NLP in ruby: https://github.com/arbox/nlp-with-ruby.

If you want a fast running and fast starting GUI you should take a look at GraalVM from oracle and its Ruby implementation called TruffleRuby, it translates Ruby code to native code and optimizes C and Ruby code at compile and runtime to make it faster: https://www.graalvm.org/ruby/

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

#36
post #33
post #29

What I like in Ruby: Every expression returns a value. In Python my_list.sort() will return `none`. So if I do `sorted_list = my_list.sort()`, my `sorted_list` will be `none`. And I have been shooting a lot in my foot in the beginning. - I love Python now, but not because I find it aesthetically appealing (I prefer Lisps or functional languages) but because it is ubiquitously available, the ecosystem is phantastic, a…

end, curly braces, same same. The deviation is IMHO Python with its intention oriented block creation. Which is a debate on its own ;).

I love the indents now with modern editors being able to deal with them ;) Zen mode. Super clean. No end delimiters.

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

#37
post #29

What I like in Ruby: Every expression returns a value. In Python my_list.sort() will return `none`. So if I do `sorted_list = my_list.sort()`, my `sorted_list` will be `none`. And I have been shooting a lot in my foot in the beginning. - I love Python now, but not because I find it aesthetically appealing (I prefer Lisps or functional languages) but because it is ubiquitously available, the ecosystem is phantastic, a…

it's a meme (image), so i can't copy it here: https://twitter.com/stylewarning/status/1772795474589987226

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

#38
post #29

What I like in Ruby: Every expression returns a value. In Python my_list.sort() will return `none`. So if I do `sorted_list = my_list.sort()`, my `sorted_list` will be `none`. And I have been shooting a lot in my foot in the beginning. - I love Python now, but not because I find it aesthetically appealing (I prefer Lisps or functional languages) but because it is ubiquitously available, the ecosystem is phantastic, a…

Python has a `sorted` function which will return a new sorted list. I agree with you about the general inconsistency though.

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

#39
post #37
post #29

What I like in Ruby: Every expression returns a value. In Python my_list.sort() will return `none`. So if I do `sorted_list = my_list.sort()`, my `sorted_list` will be `none`. And I have been shooting a lot in my foot in the beginning. - I love Python now, but not because I find it aesthetically appealing (I prefer Lisps or functional languages) but because it is ubiquitously available, the ecosystem is phantastic, a…

it's a meme (image), so i can't copy it here: https://twitter.com/stylewarning/status/1772795474589987226

That's a good one :) So I'm a non-typical hacker, because I use paredit in Emacs so I don't have any issues with parentheses :D

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

#40

This is because Ruby inherits it's approach to flow control from Smalltalk, while Python comes from a C/Algol-like heritage. In fact, Smalltalk takes this much further, such that basically all flow control (including if-then-else) is handled as message sends (e.g. if-then is just a message sent to the Boolean object taking a block as it's argument). The downside is the syntax can feel a tad clunky. The upside is incr…

[flagged]

I think you’re mistaking C-style syntax for what modern C languages have adopted and become.

How many C style context even really exist today? The block separation by single characters is ok. Using (), [] and {} to separate things makes things easier on the compiler, but it’s probably down to personal preference whether you like that syntax or not. I certainly vastly prefer the more simplistic approach where you don’t have to wrap everything in brackets. Like a loop… why does it really have to be inside a () denotion? Similarly I prefer Pythons indent to {}’s. Which can technically make your code harder to read, but if your Python code is hard to read it’s likely bad. Not always, but most of the time. I guess {} is better than BEGIN END, but maybe not in terms of readability.

The end of line character, ; is also sort of unnecessary for the most parts. Again it’s mostly a relic which helps the compiler, and some people like it while others don’t.

Modern loops look nothing like they did in C. Neither does variables or properties.

The use of English for a lot of things, or the use of western character sets, is also sort of bad in the modern world. Which is part of the reason behind the huge popularity of Go in Asia. Not that it’s so bad as it’s just how it is and everyone has adopted.

Anyway. Modern C style syntax like you’ll finds in C# or Java is rather cumbersome in my opinion. Rust sort of falls into this category but at least with Rust it’s very easy to define ownership of your stored data as you pass it around in your code. But almost all of it is exactly that… modern. Almost none of it is from C and a lot of it would not have existed without languages like Ruby.

You also have to keep in mind that Ruby predates the modern C syntax. As others have mentioned it’s been influential on the modern C syntax, but it was also made in a world where they modern syntax simply didn’t exist.

Post reply on HN