DEV Community 👩‍💻👨‍💻

Discussion on: Please stop using Ruby

kyegupov profile image

Not really. Ruby has been always inferior to Python technically and practically. Python had cleaner C bindings (which enabled Numpy, Cython and numerous other libraries). Python code is easier to debug and maintain: more explicit, less metaprogramming, fails early, better documentation.

Python also had "threading" library for ages. And its Unicode support was much better than Ruby's even in the days of Python 2.

I find it's hard to take seriously OP's arguments about Rails being "the only tool" in 2008 (I remember writing easily maintainable MVC websites in Python around 2006-2007) and Rubygems being the only package library (PyPI appeared 2 years earlier).

It always seemed to me that the only reason to love Ruby is to know nothing about Python.

northbear profile image
northbear • Edited on

Actually I don't care what comes early or later. The point is what more or less comfortable to use in practice. It's absolutely subjective.
By example I am eager with Ruby for ability to write one-liners like:

ruby -e "Dir[\"./**/*.*\"].map{|i| File.dirname(i)+' '+File.extname(i)}.inject( {|h,a| h[a]+=1;h}.sort_by{|k| k[0]}.each {|k,s| puts \"#{k} => #{s}\"}"

This one for example calculates how many files of what types exist in current directory and it subdirectories. I write similar one-liners in bash CLI without editor. How to write similar things things in python, I have no idea.
I know Python pretty well. I use it everyday for ALM automation for already 3 years. But anyway there still is wondering things in Ruby for me.
Rails is "the only tool ruby need for" mostly for people that usually far anough from ruby community. It's just popular internet mem that far from actual state.

Thread Thread
kyegupov profile image
kyegupov • Edited on

I don't envy any person that would support such "one liners", but here's the Python version:

python3 -c 'from pathlib import Path; from collections import Counter; from os.path import splitext,dirname; c=Counter(); c.update(dirname(x)+" "+splitext(x)[1] for x in Path(".").glob("**/*")); import pprint; pprint.pprint(c)'

which one is easier to read, what do you think?

Your claim that you know Python "pretty well" seems dubious.

Good engineering is about writing a code which is reliable and easy to maintain. In my experience, Ruby's track record is abysmal on both counts.

P.S. Since I'm in the golfing mood, here's an one-liner in a statically typed language, which would be OBVIOUSLY not as elegant as the wonderful Ruby, right?

echo 'package main; import "os"; import "fmt"; import "path/filepath"; func main() { c := make(map[string]int); filepath.Walk(".", func(f string, _ os.FileInfo, _ error) error {c[filepath.Dir(f)+" "+filepath.Ext(f)]+=1; return nil}); for k,v := range c {fmt.Println(k, v)}}' > /tmp/a.go && go run /tmp/a.go
Thread Thread
northbear profile image
northbear • Edited on

To talk about "easiness to read", you should learn more about functional programming and Ruby, of course. It's difficult for everyone to understand text or code if language it's written by is not known well.

I'm impressed that you reach an insight that not all prog.languages looks the same good in different applications.
So you still need only couple of steps to reach things that I talk about in beginning. And everyday exercises is very good habits. So You are definitely on the right way. Good job!

But your way to discuss here is boring me. I don't see any point to continue talk in this style. Good luck!