Why I chose Python

Hello. This time, I chose the programming language "Python" that I'm studying now, and while touching other peripheral material, I'll write it instead of a memo for myself.

What is Python?

In the first place, "Python" is a general-purpose script programming language used in various fields. In the first place, programming languages are divided into script languages that can be executed immediately by writing in a text editor and compiler languages that are activated only by converting to machine language. (Details omitted because it is difficult) I was looking for a scripting language that was relatively easy to learn, and a general-purpose language that could be used on the Web (server). As a major language that applies, "Perl" that has been used for bulletin boards and blogs for a long time, "PHP" that boasts a considerable speed on the Web by incorporating it in HTML, and completely object-oriented and easy to understand made by Japanese people Popular in Japan "Ruby", and sad "Python" that is not popular in Japan even though it is quite major in the world (laughs) It seems that Python was not popular because Ruby is popular in Japan. Thanks to that, it is hard to find materials and Q & A.

So why did you choose Python?

Perl, Ruby, and Python The three are often compared, and one programmer compares them to the programmer's three great virtues.

From "Python as a Foreign Language" by Perl hacker Dan Kogai.

"Laziness" is that if you repeat the same thing 100 times, you can easily write a program in 10 steps. I think Perl is the strongest in this field.

Next is "Impatience". This means that the computer becomes "quick". As I said, "I have a high-speed CPU, but I'm not doing anything," I think that Ruby is the best match for the willingness to use computers. For example, in Ruby, there is a style of expanding character strings and numerical values at hand. You can do it without waiting so much. As a result, Ruby on Rails came out, and Ruby was broken by this.

"Hubris" is "excessive self-esteem that punishes people" and "the temperament to write and maintain programs that are not embarrassing to people." This is still Python. "

He said Python is an arrogant language. What does that mean? Python's policy is "a program that is not embarrassing to people", and Python basically (to varying degrees) does not change the length of the code very much depending on the programming skill. It felt like I had a bit of a bite, and Python was more about readability than code length. There are regular expressions, but it's better to write them in an easy-to-understand and redundant manner if the visibility is sacrificed. I think there are also such characteristics. ** Python is readability-a language that emphasizes "readability". ** **

One of its readability features is the easy-to-read expression technique by indentation. In Python, while, for, if.def (function), class (object), etc., you have to add: at the end of the line and open an 8-byte indent from the next line. Because it doesn't use parentheses, it has less parentheses than other languages, and indentation is added to give it a unique readability. (But I use parentheses in functions, lists, dictionaries, etc.)

Its readability directly leads to maintainability. For maintainability, it's important that the code is easy to find and rewrite, even if you or others see it long after you create it. Python is easy to read, supports object orientation, and comments are highly recommended, so it is relatively maintainable.

Also, in Python, you can always see your own ideas with a single command. ("Zen of Python") "Zen" is a concise summary of the attitudes Python programmers should have in Japanese Zen.

$ python

>> import this

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Beautiful is better than ugly.

Explicit is better than implicit.
It is better to clarify than to imply.

Simple is better than complex.
It's better to be plain than complicated.

Complex is better than complicated.
Still, it's better to be complicated than complicated.

Flat is better than nested.
The nest should be shallow.

Sparse is better than dense.
It's better to have a gap than to be crowded.

Readability counts.
Easy to read is good.

Special cases aren't special enough to break the rules.
Being special is not a reason to break the rules.

Although practicality beats purity.
However, when seeking practicality, nature may be lost.

Errors should never pass silently.
Don't hide the error, don't ignore it.

Unless explicitly silenced.
However, if it is hidden on purpose, don't miss it.

In the face of ambiguity, refuse the temptation to guess.
If you come across something ambiguous, don't guess what it means.

There should be one -- and preferably only one --obvious way to do it.
There must be only one smart way to do it.

Although that way may not be obvious at first unless you're Dutch.
The method may be difficult to understand at first glance. It may be easy to understand only for Dutch people.

Now is better than never.
Do it now, rather than not doing it all the time.

Although never is often better than *right* now.
But now"soon"It's often better not to do it than to do it.

If the implementation is hard to explain, it's a bad idea.
If it's hard to explain what the code is, it's a bad implementation.

If the implementation is easy to explain, it may be a good idea.
If you can easily explain the content of the code, it's probably a good implementation.

Namespaces are one honking great idea -- let's do more of those!
Namespaces are a great idea and should be actively used.

I think this convention should be followed by all programmers, not just Python programmers.

Of course, Perl, Ruby, and PHP have their own good points, but I think Python is a language that is relatively easy to learn as a language to learn for the first time, and that can understand the implicit discipline and common sense as a programmer. Speed and shortness of code are important, but I think readability is more important than that. I'm still studying, but it's very simple and fun to write. However, it is a pity that there are few Japanese materials and documents compared to others. I think it will grow in Japan as well.

Recommended Posts

Why I chose Python
Why can't I install matplotlib in python! !!
I tried Python> autopep8
Relearn Python (Algorithm I)
I tried Python> decorator
I compared Python more-itertools 2.5 → 2.6
I tried fp-growth with python
I tried scraping with Python
I wrote python in Japanese
[Python] Why pserve doesn't work
curl -I python one liner
I made blackjack with python!
I compared Java and Python!
5 reasons I got into Python
I tried Python C extension
[Python] I tried using OpenPose
I made a python text
I ran python on windows
I tried gRPC with Python
I understand Python in Japanese!
I made blackjack with Python.
What I learned in Python
I learned Python basic grammar
I made wordcloud with Python.
I downloaded the python source
Why can I use the module by importing with python?
I made a Line-bot using Python!
I tried to touch Python (installation)
Python
I can't install python3 with pyenv-vertualenv
I checked Mac Python environment construction
I tried web scraping with python.
I can't remember Python regular expressions
I made my own Python library
[Python] I implemented peripheral Gibbs sampling
I made a fortune with Python.
I sent an SMS with Python
I wrote Fizz Buzz in Python
I took Progete's Python Learning Course I
I took a closer look at why Python self is needed
I tried using Thonny (Python / IDE)
I tried Grumpy (Go running Python).
I liked the tweet with python. ..
I learned about processes in Python
I can't install scikit-learn in Python
I played with PyQt5 and Python3
I wrote the queue in Python
I calculated "Levenshtein distance" using Python
I tried running prolog with python 3.8.2.
I tried Line notification in Python
I tried SMTP communication with Python
[Python] I tried using YOLO v3
I wrote the stack in Python
I put Python 2.7 in Sakura VPS 1GB.
I tried to summarize Python exception handling
I tried to implement PLSA in Python
I compared python3 standard argparse and python-fire
Wrangle x Python book I tried it [2]
I made Othello to teach Python3 to children (4)
I made a payroll program in Python!
I made a character counter with Python