Live data from Hacker News

Ruby 3.2.0 is from another dimension

tomaszs2.medium.com

111–120 of 341 posts

Re: Ruby 3.2.0 is from another dimension

#111
post #85

Earlier quoted context omitted.

It's a convention, quite a nice one, but not all libraries are consistent and it does have different meanings too (! is sometimes used for "raise an error instead of returning a boolean"). In the Python case, `list.sort()` operates on the object, so you can kind of expect it to do mutation (but there's no convention / guarantee). Though it only makes sense as a function that the list object itself implements. `sorted…

> it does have different meanings too the meaning is the same high level: it has side effects, being it a destructive update, an in place operation or throwing an exception. > `sorted` is a general function that gives you a sorted list from any iterable iterable in Python is a very loose concept though. And it's not very consistent too sorted("gheliabciou") ['a', 'b', 'c', 'e', 'g', 'h', 'i', 'i', 'l', 'o', 'u'] you…

You can use emoji in HN comments? Emojis get automatically removed from mine.

Edit: ok, some do and some don’t. 🈶 is allowed but :laugh_with_tears: isn’t. I guess there’s a specific list of emojis that are getting stripped.

Re: Ruby 3.2.0 is from another dimension

#113
post #85

Earlier quoted context omitted.

It's a convention, quite a nice one, but not all libraries are consistent and it does have different meanings too (! is sometimes used for "raise an error instead of returning a boolean"). In the Python case, `list.sort()` operates on the object, so you can kind of expect it to do mutation (but there's no convention / guarantee). Though it only makes sense as a function that the list object itself implements. `sorted…

> it does have different meanings too the meaning is the same high level: it has side effects, being it a destructive update, an in place operation or throwing an exception. > `sorted` is a general function that gives you a sorted list from any iterable iterable in Python is a very loose concept though. And it's not very consistent too sorted("gheliabciou") ['a', 'b', 'c', 'e', 'g', 'h', 'i', 'i', 'l', 'o', 'u'] you…

[deleted]

Re: Ruby 3.2.0 is from another dimension

#114

Earlier quoted context omitted.

Map/filter are considered inferior in Python to list comprehensions. res = [x**2 for x in range(10) if x != 5]

Before Ruby introduced filter_map: res = (1..10).select { |x| x != 5 }.map { |x| x ** 2 } With filter_map: res = (1..10).filter_map { |x| x ** 2 if x != 5 } In both cases, I think the Ruby solution is more readable. Python list comprehensions invert the subject (data) and the verb (action). You see what will be done before you see what the subject is. I would argue that showing the subject first allows easier code re…

> In both cases, I think the Ruby solution is more readable.

Nope.

Re: Ruby 3.2.0 is from another dimension

#115

Earlier quoted context omitted.

Map/filter are considered inferior in Python to list comprehensions. res = [x**2 for x in range(10) if x != 5]

Before Ruby introduced filter_map: res = (1..10).select { |x| x != 5 }.map { |x| x ** 2 } With filter_map: res = (1..10).filter_map { |x| x ** 2 if x != 5 } In both cases, I think the Ruby solution is more readable. Python list comprehensions invert the subject (data) and the verb (action). You see what will be done before you see what the subject is. I would argue that showing the subject first allows easier code re…

The Python one looks fine to me, although I am a Pythonish person.

It uses what people already know: the for something in somethings syntax of the for loop, and the if syntax. Also it's nice that this works in dictionaries, generators and lists.

It also has the same narrative flow of Haskell's list comprehensions, which I think come from set theory:

  [x^2 | x 
As for your Ruby examples: I think you could argue that the filter_map version is very readable, but not necessarily more so, but the select one looks pretty painful.

Re: Ruby 3.2.0 is from another dimension

#116
post #62

Earlier quoted context omitted.

When I looked at Python vs Ruby many years ago, I found the opposite: Why does Python have (special) functions like len() and map(), instead of 'properly' supporting both OOP (len should just be a method on objects) and/or FP (support multi-line lambdas so I can actually use map/filter etc). I never understood how this can be considered consistent at all, and those IMHO language design warts made me look into Ruby at…

Those functions take any object that supports the iteration protocol. There’s no need for adding say, len, to every object that needs a len function. I’d argue that is consistent. Sure, multi line lambdas might be nice, but equally you can define functions wherever you need them so it’s not really all that different.

> There’s no need for adding say, len, to every object that needs a len function. I’d argue that is consistent.

Python's len works by calling the __len__ method, which must be added to every class that needs a len function.

Since you're already defining a method with a standard name on every class that needs it, Ruby just has you call that method directly as opposed to the absurdity of intentionally obfuscating the method name with underscores so that people use a global helper function instead.

Even C++, with all its warts and its 1980s design got this right in the std lib with the size method.

Honestly, I find some of these defenses of Python quite humorous.

Re: Ruby 3.2.0 is from another dimension

#117
post #42

Ruby is my favorite language, and often it is a joy to use because of its combined attributes of brevity, expressive power, and feature consistency. It's disappointing that there are so many more jobs for another popular language - one that lacks the elegance and consistency but which has a larger ecosystem. As far as I know, the only well known reason for a company to choose Ruby is if they want Rails (and obviously…

> reason for a company to choose Ruby is if they want Rails And that there, is the whole "Problem" of Ruby. Ruby is a beauty. Rails isn't. It's nice, productive (for certain niches) and has a long track-record. But Rails is also often the root of problems such as maintainability, long-term-productiveness, hosting (performance, scaling), and lock-in. There are far better solutions for simple CRUD-apps today than writi…

I've used Ruby since 2005, and I've disliked Rails pretty much from day one, and really wish the two were not so intertwined. At the same time I've used Ruby professionally almost as long while only rarely needing to touch Rails so I disagree it loses its usefulness though Rails fading from popularity certainly has an effect.

Re: Ruby 3.2.0 is from another dimension

#118
post #87

Earlier quoted context omitted.

> But that other language also has a popular (and comparatively clumsy) web framework Django is today more elegant, more complete, and better documented than Rails ever was. 10 years ago you would have been correct. 5 years ago they were about evenly matched. Today it's not even close. Python is eating the world, and web frameworks are no exception.

Django might be better but Ruby as a language is way better thought out than Python. Python feels like it's cobbled together compared to Ruby. There is a certain elegance with the language, that is hard to find elsewhere.

I disagree. I perceive no difference in elegance between the two languages nor a particular “cobbled together” aspect to Python.

Re: Ruby 3.2.0 is from another dimension

#119

Earlier quoted context omitted.

So, how do you reconcile this opinion with the fact that Ruby can't even do a proper REPL on Windows? It just starts showing weird output, overwriting lines and doubling up other ones... that other language just works. And look, I LOVE Ruby. I come from twentyish years of Perl, and I really like the way Ruby feels when banging out a script but these days, time is in short supply, and I just don't have time to screw a…

If anyone reading this is thinking “why does Windows even matter for development?” then congratulations because you’ve discovered you’re in a filter bubble. Surveys, such as StackOverflow’s ( https://survey.stackoverflow.co/2022/#section-most-popular-t... ) consistently find that > Windows is the most popular operating system for developers, across both personal and professional use. If it makes anyone feel better, I…

Well, I'm programming on windows for about 6 months now, comming from using Linux for the last 5 years. I have to admit I was forced as my new notebook BIOS has a wrong VBT configuration and that makes the Linux kernel to not recognize my HDMI port.

And I can acomplish any other task a regular developer can do (and I was doing) programming in Java (with sdkman), using docker containers, git on the command line, Big Data tools (flink, iceberg, haddop, etc) and even some bash scripts (nothing too fancy).

The only things that bothers me are the CRLF x LF and sometimes the windows defender making the fans go crazy, but thats is a minimum and I can do some workarounds, the same way I did with bluetooth and audio on Linux.

Re: Ruby 3.2.0 is from another dimension

#120
post #94

Earlier quoted context omitted.

That's a fairly Silicone Valley focused argument. I don't subscribe to the theory at all that Google closed internal use of Python was instrumental in its adoption. Django was released in 2005 and RoR in 2004. I suspect my journey was similar around then (late 2005), I had used PHP, classic ASP and a little Perl. I was looking for something better, read the tutorials for both Django and RoR. Had a look at what deskto…

Had a similar journey, started with ASP in the 2000s, then PHP around 2003, then worked with both RoR and Django professionally for a few years. As much as I liked RoR for its scaffolding and easiness of bootstrapping new CRUD projects, over time with larger codebases and teams it just starts to be a mess. Ruby programmers love the terseness of the language and write some of the most ungrokable code I've encountered…

> most ungrokable code I've encountered (second only to some Scala

Perl!

Post reply on HN