News for hackers. Stuff that matters.
Re:Ruby 3.3 by burlesona on Monday December 25, 2023 @10:49AM (#38763546)
Ruby is basically a less popular but more elegant Python. It’s a solid general purpose language, but especially good at shell scripting, data munging, etc.

If you’re fluent in Node and Python it should be quite easy to learn. The downside is it’s not going to do anything fundamentally new for you coming from those languages. The upside is mostly aesthetic, Ruby offers and encourages really beautiful ways of expressing code, and it’s neat to experience that.

Re:Ruby 3.3 by nerdponx on Monday December 25, 2023 @11:03AM (#38763663)
Having tried to use Ruby for text processing specifically, I'm not sure I agree it beats Python at that particular task. Maybe I'm just used to the Python way of doing things, but I found it difficult to work with the lack of first-class functions and iterators/generators, as well as the general iteration protocol.
Re:Ruby 3.3 by weaksauce on Monday December 25, 2023 @01:20PM (#38764772)
> lack of first-class functions and iterators/generators, as well as the general iteration protocol

can you elaborate on what you miss here? ruby has a robust enumerable suite of methods so i'm curious what you found lacking

Re:Ruby 3.3 by dragonwriter on Monday December 25, 2023 @01:30PM (#38764847)
> but I found it difficult to work with the lack of first-class functions and iterators/generators, as well as the general iteration protocol.

Ruby has iterators/generators. It doesn't have first-class functions because it doesn't have functions at all, but blocks/procs serve the same purposes.

Re:Ruby 3.3 by xdennis on Monday December 25, 2023 @09:42PM (#38768486)
I don't know Ruby, but it kinda sounds like Ruby just calls first-class functions blocks.
Re:Ruby 3.3 by thelibrarian on Monday December 25, 2023 @10:50PM (#38768760)
No, blocks are lambdas.
Re:Ruby 3.3 by dragonwriter on Tuesday December 26, 2023 @03:26AM (#38769872)
No, in Ruby lambdas are lambdas (and are a special type of proc); the longhand way to create a lambda is to call Kernel#lambda and pass it a block (though modern Ruby has a special shorthand syntax for lambdas, as well.)

Blocks are sort of like anonymous function literals that are not first class, one (but no more than one) of which may be attached to a function call.

Re:Ruby 3.3 by dragonwriter on Tuesday December 26, 2023 @03:23AM (#38769860)
No, blocks are not first class (procs are, and procs are the closest thing Ruby has to functions, and a method definition can bind convert the block passed to the function to a proc if a first-class value is needed.)

Blocks are a syntactically special single argument to a method that can either be yielded to (a Ruby construct similar to a function call but which only applies to the block passed to the current method) or converted to a proc (but the latter only as part of the method definition, since they aren't first class and thus cannot be manipulated or referred to directly.)

Re:Ruby 3.3 by bluerooibos on Monday December 25, 2023 @01:40PM (#38764915)
I find the opposite. Ruby has a longer list of String, Array and Hash methods/functions and they're also more useable.

Another issue I had was that Python's test frameworks like PyTest were just so weak compared to the likes of MiniTest and RSpec.

Re:Ruby 3.3 by e12e on Monday December 25, 2023 @02:56PM (#38765574)
> ... lack of first-class functions and iterators/generators, as well as the general iteration protocol.

I'd love to hear what makes you say this - none of it is meaningfully true (ruby doesn't have functions, but it has blocks and callables).

It has:

https://docs.ruby-lang.org/en/master/Enumerator.html

Re:Ruby 3.3 by djur on Monday December 25, 2023 @03:21PM (#38765759)
What is the distinction between a function and a proc? I would say that a proc is a (first-class) function.
Re:Ruby 3.3 by e12e on Monday December 25, 2023 @08:07PM (#38767968)
As I said, claiming that ruby doesn't have first-class functions isn't "meaningfully true". Ruby does not have functions, only methods. But that's mostly irrelevant.

https://en.m.wikipedia.org/wiki/First-class_function#Languag...

> The identifier of a regular "function" in Ruby (which is really a method) cannot be used as a value or passed. It must first be retrieved into a Method or Proc object to be used as first-class data. The syntax for calling such a function object differs from calling regular methods.

https://blog.appsignal.com/2018/09/04/ruby-magic-closures-in...

> Ruby doesn’t have first-class functions, but it does have closures in the form of blocks, procs and lambdas. Blocks are used for passing blocks of code to methods, and procs and lambda’s allow storing blocks of code in variables.

Re:Ruby 3.3 by thelibrarian on Monday December 25, 2023 @10:55PM (#38768787)
I think you may just be used to Python still relying on functions for string processing, where Ruby has methods on the String class for manipulating strings.

It seems to me that Python still has these holdovers from when it was not fully object-oriented, where a lot of string and data structure manipulation is done with language-level functions rather than methods on the objects, which can be quite confusing.

Re:Ruby 3.3 by gls2ro on Monday December 25, 2023 @11:43AM (#38763968)
> but especially good at shell scripting, data munging

Add to this also Shopify, Github, Gitlab, Basecamp and some others and you will see that Ruby can be use for more than shell scripting and data munging. Yes they are Rails but Rails is written in Ruby so they are Ruby.

Re:Ruby 3.3 by riffraff on Monday December 25, 2023 @12:05PM (#38764192)
Stripe is a big "ruby but not rails" shop, iirc.