I want to refute "Ruby is not cool here"

When I talk about programming with Pythonista at work, I'm all taken to the flow of Ruby Diss.

Why do you hate it so much?

TMTOWTDI is evil

TMTOWTDI is an acronym for "There's More Than One Way To Do It." And is Perl's motto, which means "there is more than one way."

In Ruby, I don't know if it's because it inherits that idea, but many methods of built-in classes have aliases defined.

For example Enumerable#map,find,inject,select,include? Array#count Object#to_enum It is a place like that.

According to Pythonista, this creates nothing but confusion and learning costs.

Yup ** Maybe you're right ... **

I agree with the variety of solutions,

python


### a-Generate a random 8-character string consisting of z

# 1
str = ""
alphabet = ('a'..'z').to_a
8.times do
  str << alphabet.delete(alphabet.sample)
end

# 2
('a'..'z').to_a.shuffle.take(8).join

# 3
('a'..'z').sort_by{rand}[0..7].join

Providing an alias for a method with the same function feels like a way to increase the wrong choices.

It doesn't say "Is it possible to get the size even with Array # length?" I sometimes wonder, "Why is there no fold because Enumerable has inject and reduce?"

Proc # call is good

You need to call it when you run Proc. Therefore, it seems that it is not possible to handle the function transparently as a first class object.

If Proc's calling syntax is aligned with the method, the simplicity of calling the method without () is lost.

python


constant = proc{42}
constant #=>Is constant a call or a reference to Proc?

Proc requires (), and special treatment such as is delicate, so I think this is fine.

require is not cool

According to Pythonista, I don't like the fact that the name is expanded to the top level when I require it in Ruby.

In Python, the filename becomes a module when imported and the global namespace is not polluted. You can also use from to specify a name to load to the top level.

There is no noise about this.


Well, I think I was saying something else ...

Recommended Posts

I want to refute "Ruby is not cool here"
I want to say that there is data preprocessing ~
I want to solve Sudoku (Sudoku)
I want to initialize if the value is empty (python)
I want to understand systemd roughly
When I try to use pip, SSL module is not available.
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
I want to specify a file that is not a character string for logrotate, but is it impossible?
I want to display the number of num_boost_rounds when early_stopping is applied using XGBoost callback (not achieved)
I want to get angry with my mom when my memory is tight
I tried to implement deep learning that is not deep with only NumPy
I made an AI to judge whether it is alcohol or not!
I want to identify the alert email. --Is that x a wildcard? ---
I want to pin Spyder to the taskbar
I want to detect objects with OpenCV
I want to output to the console coolly
I want to print in a comprehension
I want to scrape them all together.
I want to handle the rhyme part1
I want to blog with Jupyter Notebook
I want to handle the rhyme part3
I want to use jar from python
I want to build a Python environment
I want to use Linux on mac
I want to pip install with PythonAnywhere
I want to analyze logs with Python
I want to play with aws with python
I want to use IPython Qt Console
I want to display the progress bar
I want to make an automation program!
I want to embed Matplotlib in PySimpleGUI
I want to handle the rhyme part2
I want to develop Android apps on Android
I want CAPTCHA to say HIWAI words
I want to handle the rhyme part5
I want to handle the rhyme part4
I want to get the path of the directory where the running file is stored.
[Linux] You do not have root privileges. But I want to yum install.
Python program is slow! I want to speed up! In such a case ...
I want to be notified when the command operation is completed on linux!
I want to make matplotlib a dark theme
I want to connect to PostgreSQL from various languages
I want to have recursion come to my mind
I want to easily create a Noise Model
I want to use MATLAB feval with python
I want to pin Datetime.now in Django tests
I want to INSERT a DataFrame into MSSQL
I want to memoize including Python keyword arguments
I want to create a window in Python
Anyway, I want to check JSON data easily
I want to email from Gmail using Python.
[Python] I want to manage 7DaysToDie from Discord! 1/3
I want to perform SageMaker inference from PHP
I want to mock datetime.datetime.now () even with pytest!
I want to display multiple images with matplotlib.
I want to knock 100 data sciences with Colaboratory
I want to make a game with Python
I want to visualize csv files using Vega-Lite!