5 ms·
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
by lucasoshiro 2y ago
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 https://news.ycombinator.com/item?id=40763640
- Kwpolska 2y agoCreating a new thread is equally simple in Java: var thread = new Thread(() -> { // Thread code }); thread.start(); // ... thread.join();
- speleding 2y agoYes, 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.
- lucasoshiro 2y agoFair. 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.