DEV Community

Discussion on: Getting Cozy with Ruby

Collapse
 
tadman profile image
Scott Tadman • Edited

I haven't used Scala enough to comment on how it feels, but Ruby is able to straddle the intersection between procedural, object-oriented, and functional depending on how you use it.

This is increasingly true for a lot of languages, even Swift, Rust and Python, where functional approaches to problem solving have helped simplify things. Once you get lambdas it's inevitable that will happen. Maybe we'll even see more of that in C++.

Within Ruby there's a lot of push towards a more functional style as it's anticipated this will help resolve some of the major concurrency problems Ruby has. The Ruby core team seems to be opposed to threads as a general-purpose solution, instead steering towards approaches like Guilds, similar to how JavaScript has WebWorkers, but there's opportunities to parallelize things like map if you have clean, functional code to work with.

Here's hoping there's a concurrent version of things like map in future versions of Ruby!

Thread Thread
 
rhymes profile image
rhymes

This is increasingly true for a lot of languages, even Swift, Rust and Python, where functional approaches to problem solving have helped simplify things.

True that! My Python code is increasingly more functional and I think the natural namespace of file boundary in Python helps with that. Well, also having functions whereas Ruby has only methods. I don't use custom classes that much anymore in Python. Pass state between functions, inject dependencies, rinse, repeat.

It's also so much easier to test when you have side effects contained in a small amount of business logic.

Thread Thread
 
deciduously profile image
Ben Lovy

Rusts' Iterator trait definitely comes to mind, but I believe Ruby provides a greater set of methods, and I've definitely noticed a functional-forward trend in C++11 (and up).

I am not complaining :)

Thread Thread
 
tadman profile image
Scott Tadman

If someone ported Enumerable to Rust and/or JavaScript in all of its glory that would be amazing.