News for hackers. Stuff that matters.
Re:Ruby 3.4.0 by lucasoshiro on Wednesday December 25, 2024 @08:02AM (#42508596)
I see some people saying that Ruby is too much "magic", while what is magic is Rails. Ruby itself can have its high useful work / LoC ratio thanks to its syntax. For example, you can spawn a thread with:

thread = Thread.new do # thread code end

...

thread.join

In this example we can see that it's not magic, only concise.

I wrote more about it here: https://news.ycombinator.com/item?id=40763640

Re:Ruby 3.4.0 by Kwpolska on Thursday December 26, 2024 @04:16AM (#42514081)
Creating a new thread is equally simple in Java:

    var thread = new Thread(() -> {
      // Thread code
    });
    thread.start();
    // ...
    thread.join();
Re:Ruby 3.4.0 by speleding on Thursday December 26, 2024 @05:06AM (#42514242)
Yes, but it's a good example of how Java is about twice as verbose to do the same work. The Ruby version of that can be written as simply:

Thread.new{ ... thread code ...}.join

The extra verboseness quickly adds up if every statement takes twice as much code.

Re:Ruby 3.4.0 by lucasoshiro on Thursday December 26, 2024 @07:40AM (#42514842)
Fair. I must admit that I'm not aware of the recent features of Java. Last time I really needed it was the time that we needed to instance an anonymous class for callbacks. I still find the block syntax in Ruby cleaner though.

Kotlin is another language that has this Ruby-style blocks for callbacks.