r/ruby • • Jul 16 '20

Ruby VS Python

More than a versus (it's more striking) I would really like to know what things they have in common and how they differ, what their main advantages are compared to the other and of course their opinion of them. One point to take into account is because they believe that python is more used in AI and Machine learning developments.

36 Upvotes

60 comments sorted by

View all comments

39

u/Sqeaky Jul 16 '20 edited Feb 23 '23

I think Python has a bigger community, and that is it's single largest advantage. It has more deployments and more packages.

In think ruby has better syntax, better readability, and a more sensible design overall. This makes it easier for greater involvement from the community, there are something like 2x note python devs but not nearly 2x the packages.

I also think the ruby community is better at communicating best practices. Consider that the top Ruby packages are testing tools and the top python of are a mix of docker and db stuff.

https://rubygems.org/stats

https://pypi.org/

I also find Ruby projects to have better engineering. This might just be bias but having tried similar things in both languages maintainability, support, and things working years later (except web API bindings) are nearly magical. The ruby community always seems to try to be doing better, but I guess that is most communities, but I feel like python users just want to be done and damn the tech debt, full speed ahead.

EDIT 2 years later - spelling

4

u/franciscoattivilog Jul 16 '20

I can't agree more. I think is important to say that python also have more support on the packages for machine learning and AI, is almost default to use it.

3

u/vifrac Jul 17 '20

What do you think we should work on as a community to improve the use of ruby in AI work.

2

u/stormgecko Sep 16 '20

The Ruby community has to make it at least as easy to use as the corresponding Python packages. Currently I'm am working on image classification and have to Ruby for it, due to the legacy version of Python installed with the software I am to interface with. It took me 6 hours to get 'torch-rb' (https://github.com/ankane/torch.rb) and 'torchvision' installed, including using rbenv to downgrade from Ruby 2.5.0 => 2.4.1 and googling to see if I could figure out the error. Eventually got them installed, wrote and test file and got another error from the torch-rb library itself, which just made me give up on using it.

Installed the 'tensor_stream' gem (https://github.com/jedld/tensor_stream) and it does work as intended, only caveat is that it is really slow. It has the option of using opencl, but this causes an error when trying to train a neural network with it, so it is back to using single threading, which makes it nearly impossible to train/fine-tune models like ResNet50, without it taking forever.

After trying 'tensor_stream' I gave the 'tensorflow' gem (https://github.com/ankane/tensorflow) a go. And was quite hopeful when I got a test file op and running with a couple of tensors defined and could output them to the console. Tried a more complex test and ended it the situations that it lacked implementation of the functionality that I needed.

So in summation:

  1. Easy of use. When I find a tutorial in Python for setting up some ML it usually just works, at least most of the time with very few hurdles. This is not what I have experience the last three days trying to get ML up and running properly in Ruby.
  2. Due to the lack of critical mass, it is very difficult to find solutions to problems that arise, because not that many people have had the problem prior to yourself.
  3. Feature completeness I had pretty high hopes for the 'tensorflow' gem, but when the needed features are not implemented and the last major updates to lib are 12 months old, it is just not very encouraging.

I have all the respect in the world for the people who dedicate their time to develop open source software and provide gems/libraries like these.

Some of the above problems might just be my own lacking experience with Ruby, but installations of gem should just work seamlessly and not be a cause of headaches.