2020年2月2日日曜日

If Python4 doesn't solve the problem of global interpreter locks. 2020.02.02 Current solution. Masahiro Ishizuka (aon CEO)

As of 2020.02.02,
Python 2 & 3 does not solve the problem of global interpreter locks.

As an alternative,
Use Go lang to develop websites, intranets, LINE apps, etc.
I think that the development of AI and machine learning uses Python, and Go lang solves the problem by using a website + AI (API library for Go lang) + AI (machine learning) DATA.

Related information:

Goodbye Python, Hi Go

Quote source:

Summary of the goodness or lack of Go compared to Python by the writer who recently started writing tasks in Go, which was previously written in Python.

Original text
Goodbye Python. Hello Go. (English)
Translation requester
D98ee74ffe0fafbdc83b23907dda3665 Df3136f800e7ed9931ed5f9f1afad935
translator
Df3136f800e7ed9931ed5f9f1afad935 mtsk
Translation reviewer
D98ee74ffe0fafbdc83b23907dda3665 doublemarket
Translation report to original author
Edited 502 days ago with comment on original text
 




I use the Go language for a lot of processing that I used to write in Python before. For example, the following processing is possible.
  • Handling Cloudfront logs stored in Amazon S3
  • The process of moving huge (terabyte class) files into and out of S3
  • Matching of synchronized files between database and S3
This is almost always a one-time process, so it is ideal to write it in a scripting language. The program needs to be written quickly and is likely to be discarded soon. Since these tasks are always new and unique, the code you can reuse is minimal.
Here are the advantages of using Go instead of Python.

Good to have a compiler

I regularly make boring mistakes in Python. Mistakes in variable name / function name or passing wrong argument. Development tools can find them, but these tools often require special initialization. I still haven't been able to easily set up pylint, and I don't like full-fledged IDEs that require it.
The worst case is that variable mistypes are hidden behind conditional branches. The script causes an error after running for several hours. And after everything is messed up, you need to re-run.
Unit testing can find many of these issues. However, 100% coverage is difficult and I don't want to spend time on unit tests for one-off scripts.
Compiled languages ​​solve all of these problems. The compiler will catch these mistakes. For this reason, I like the Go language to handle more than a few hundred rows of data.

Development speed

The disadvantage of the compiler language is that the development speed is slow. This is especially true for C / C ++ and Java.
Go is simple enough when you know that development speed is kept to a minimum. I still speed up Python, but the productivity of the go language is about 85% compared to writing in python.
85% is not bad. That's because using a compiler greatly reduces minor mistakes.

Advantage in parallel processing

As you know, Go was originally created for parallel processing.
Our team often needs parallel processing programs to process large amounts of data in S3 and databases.
If the task is IO intensive, Python threads can help. However, for tasks that are CPU intensive, Python is difficult in terms of global interpreter locks.
I enjoy the simple way that multithreaded Go works without any special effort. Did you have any problems using Ctrl-C with multithreaded Python?

Easy deployment

I like working with single binaries. I often run code on EC2. This is to make the communication path between the script and the S3 / database closer. If you do it in Python, you need to make sure that all the required packages are installed on the remote machine, and do not conflict with anything installed by other colleagues.
Virtualenv solves most of this problem, but the Go language is easier.
Most of the time, you just need to cross-compile your Mac's go code for Linux, copy it to a remote machine and run it. All dependencies are contained in the binary.

Consistent style (formatting)

At first, I got frustrated with the gofmt tool. In particular, it's hard to use tab indents instead of spaces. I thought it was not normal.
However, while using it, it became dependent on gofmt . By being automatically formatted without any consideration, you are freed from formatting. All my code is always in a consistent format style, no matter what project I work on. Formatting is a feature of the standard Go language tools.
In Python, a similar effect (consistent format) is more expensive. I have to set up pylint correctly and check that it is consistent pylint all projects.

Advantage in tools

One example of this is just gofmt . All the good Go extensions are available in any of the editors I use (VSCode, vim, Sublime Text). This is the advantage of the Go language providing tools as a standard feature.
The result is a Java-like intellisense without using an IDE. In Python, I've never approached this feature before.

Missing part

Whenever I see criticism of the Go language, it is due to missing features (like Generics) in Go. I've never run into major problems because of the lack of generics. (You'll be surprised to see how much you can do with maps and slices.) But I faced many other problems.

Go language is too assertive

The Go language is the language that I have claimed, even among the languages ​​I have written so far. gofmt with forcing tabs instead of spaces (assuming you're using gofmt ), using a specific directory structure, and building code in the GOPATH environment variable. Many of these Go language features are not easily changed.
One of the reasons for the low learning cost of Go is that these features cannot be changed. If you don't want to make names that start with uppercase letters (functions, variables, etc.) public, then it's not very good. Fortunately, these aren't bothers to me, but I understood anything else.
Python is much more flexible.

Few things provided by the library

It is not fair to compare Python and Go in this regard. Go is much newer. But when I find a feature that Go doesn't support, I'm confused. You'll be even more confused when code that should be a built-in function is posted on StackOverflow, and everyone behaves like copying and pasting that code into your project.
Two examples (those that come to mind in recent years):
  • Sorting slices (fortunately provided since Go1.8)
  • Math.round can only handle integers and not float variables (for example, if you want to round to .5). And before Go1.10, there wasn't even Math.round.
Yes, some of these are due to the lack of generics in Go, and also because Go developers follow a strategy of adding only what is absolutely necessary to the standard library.
I understand the two points above. However, if you come across a small feature that you have to implement yourself, it's annoying.
I hope these annoyances will decrease as the Go language evolves.

〒197-0828
5-3-11 Akidome, Akiruno-shi, Tokyo
5-3-11 Akiru Akiruno-City Tokyo Japan
aon CEO
Masahiro Ishizuka
(MASAHRIO ISHIZUKA)
TEL: 042-559-8638
iPhone: 070-3861-5011
FREE CALL PHONE

+81 50 5532 0868

Skype
live: cloud9slack
http://aon.tokyo
http://aon.co.jp Under preparation
cloud9slack@gmail.com

0 コメント:

コメントを投稿