DEV Community

Discussion on: Please stop using Ruby

Collapse
 
northbear profile image
northbear • Edited

I didn't see any reason to stop using ruby in my private automation tasks. Using ruby in the company productions is usually question of managers that keep in mind a lot of reasons that sometimes is not technical related.

  1. GIL does not cause any problem for python to grow up. So why should it be problem for ruby?
  2. Ruby concurrency (don't mess it with multi-threading) actually works pretty well via fibers. This approach is pretty popular in other scripting language. For instance Python has a lot of libs that implements of actor model: Pykka, Thespian. Asyncio is included in stdlib of Python 3.4 and so on.
  3. Ruby is not Rails. Yes, rails helps a lot to ruby to rise up. But now rails is big problem for ecosystem of ruby itself. In ruby community there is term "rails programmer" that much differs from ruby programmer. There is a lot of rails programmers but the knowledge of ruby outside of rails of most of them is lack pretty much.

So, It is totally your solution to stop programming in ruby. Ruby get losing its positions in competition with python, it's the fact. And I feel sick of it. I suppose it happens mostly because of marketing reason, not technical. Guido living in America has much more ability to promote python in Hi-Tech than Matz living in Japan. Plus Matz is pretty introvert guy. So...

Collapse
 
kyegupov profile image
kyegupov

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.

Collapse
 
northbear profile image
northbear • Edited

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(Hash.new(0)) {|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

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

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!