Programming language performance measurement, Go even better than Python?

作者 | Paul Dziubałka Sebastian Karasiewicz

Translator | Hong Technology

Produced | AI technology base camp (ID: rgznai100)

There are a lot of exciting the code on the Internet, which has become the basis for building various infrastructures. You are reading this same platform we are also committed to creating excellent code. Despite the general ordinary users will not notice this, but on the other hand, good developers are always looking to make their applications (as well as their code) there are better ways.

Excellent basis to write code that depends on the skills and the choice of the developer's language. This inevitably leads to conflicts between developers, but the conflict is not only about skill levels, and mainly related to their preferred language (and may even be an epic conflict). When you combine the two outstanding programming languages ​​(eg Golang (Go) and Python) put together, it is most likely to happen.

Now let's take a step back, eliminate personal prejudices and preferences, simply evaluate the two languages ​​in terms of advantages and features, expertly leveled the playing field. Now, we are left with only two good choices: Go vs Python. The question now becomes, what programming language is more suitable for you?

Python story

If you go ask some developers, you will hear are not worth mentioning before the birth of Python, Python and after are not worth mentioning also that kind of thing. Over the years, because it is a very good programming language, it has successfully won a huge concern. Full of cool applications using Python created on the Internet.

On life in terms of programming, Python considered a veteran. It was first conceptualized in 1991. With age, gradually have a certain advantage. It has a wide range of supporters, which means it is stable and rich document. In most cases, you will find almost all the contents of the library as well as any code examples in almost all can think of. For developers and businesses, which means using Python's choice will bring a wealth of experience and coding.

There are many uses Python as a basis for open source projects, so in most cases, you are not starting from scratch. It is well integrated into enterprise applications, and can be used in machine language and AI applications. But it does have drawbacks, on the one hand, it is not ideal for memory-intensive tasks of choice, in terms of execution for a little bit slow, on the other hand, it is not suitable for mobile application development.

Speaking Golang (Go)

Google Go language developed in 2009. Go intention is to solve practical problems. Its goal was to create a language in order to eliminate unnecessary burdens and all things found in the language such as C ++, which brought with it to enhance the performance and speed. In addition, most of the first contact developer Go does not appreciate the high threshold grammar, because Go inside the familiar elements and ease of use will be amazing.

This is not to say that in all cases the language is perfect. Despite the speed and elegance to a whole new level, but it does leave some areas for improvement. First, it does not extend library does not support inheritance. In addition, there is no GUI libraries or object-oriented programming support. It needs to do is create a lightweight thread (Goroutines), standard libraries of intelligent, powerful built-in security, and easy to use with minimal coding syntax.

Performance Testing

We can endlessly talk about the advantages and disadvantages Golang or Python, but when we consider the deployment of use, we expect them to have excellent performance. Therefore, we carried out some tests on Intel®Core ™ i7-9700KCPU @ 3.60GHz × 8-core test equipment. Https://github.com/sekarasiewicz/go-python-benchmark test code can be obtained from here.

1. binary search

We created a list of integers (from 1-100000), and then use binary search to find the same numbers always 729. The results are:

 

2. Bubble Sort

Again, we generated a list of integers (this is random, a total of 10,000 elements), and use bubble sort algorithm to sort.

 

3. File Read

Read simple test "lorem ipsum" text files.

 

4. HTTP request processing

HTTP server really easy to write, but we put a lot of effort for effective simulation in Python. We examined a simple "hello world!" Message in response to how long it takes.

Election Golang or Python ?

尽管Python一直是社区中的最爱,在2019年第一季度就成为GitHub上最快的编程语言排行榜上(按拉取请求数计算+17%)的第二名,但Golang并没有落后很多,位于紧随其后的第四位(+ 8%)。Golang与Python之间的选择变得更加模糊。无论如何,在选择哪一项适合你时都需要考虑一些事项。

1.可扩展性:Golang在创建时就考虑了可扩展性。它具有内置的并发性,可以同时处理多个任务。Python同样可以使用并发,但不是内置的。它通过线程实现并行性。这意味着,如果你要处理大型数据集,那么Golang似乎是一个更合适的选择。

2. 性能:众所周知,Python不是内存或CPU友好型的编程语言,但由于它拥有大量的库,Python可以有效执行基本的开发任务。Golang具有内置功能,它更适合于微服务软件体系结构。

3. 应用程序:Python非常适合编写用于人工智能、数据分析、深度学习和Web开发的代码。Golang已普遍用于系统编程,并且受到云计算和集群计算应用程序的开发人员的喜爱。

4. 社区和库:如前所述,Python的时代赋予了它一定的优势。其中之一是它拥有的库数量以及支持它的大型社区。另一方面,Golang虽然没有Python提供的大量库和社区支持,但仍是一种增长中的语言。我们不应该将Golang踢出局。它的增长和采用率令人难以置信,并且每天都在增长。

5. 执行性能:如果只关注速度,那么Golang肯定会赢。

考虑所有这些因素后,你的用例将成为采用哪种语言的决定因素。在你要建立开发团队来创建微服务的情况下,Golang将是更合理的选择,因为它既快速,易于编码,又可以很好地扩展。另一方面,Python更适合于AI、ML和数据分析。

因此,一对一地比较,在大多数情况下,Go会脱颖而出,被认为是使用Python的有效替代方案。开发人员需要选择一种编程语言,要考虑其开发项目的性质和规模以及所涉及人员的技能。

好消息是,无论选择哪种语言,两种语言都在不断发展。尽管在大多数情况下,Golang似乎是一个显而易见的选择,但Python社区不会闲坐而不采取任何行动。两种语言都在扩展和增长。这意味着将来我们将看到更多的功能和改进。

原文链接:

https://www.softkraft.co/golang-vs-python/

(*本文由AI科技大本营编译,转载请联系微信1092722531)

【end】

精彩推荐

推荐阅读

    你点的每个“在看”,我都认真当成了AI

发布了1327 篇原创文章 · 获赞 1万+ · 访问量 582万+

Guess you like

Origin blog.csdn.net/dQCFKyQDXYm3F8rB0/article/details/104368299