golang python_Golang即将取代python吗

golang python

In the world of web development, agility is a king. Businesses gain a competitive edge by having their websites and web applications developed faster with fewer expenses and resources involved. Moreover, not only do they want fast on-demand web development, the demand is also high for advanced usability and seamless user experience.

Web开发的世界中,敏捷是王者。 通过使网站和Web应用程序开发速度更快,所涉及的费用资源 更少 ,企业可以获得竞争优势。 此外,他们不仅需要快速的按需Web开发,而且对高级可用性和无缝用户体验的需求也很高。

Switching to a new language is always a big step, especially when there are less resources and more challenges.

切换到新语言始终是一大步,尤其是在资源较少且挑战更多的情况下。

Image for post

This blog focuses on benefits of Golang web development and compare Golang web programming to another highly popular language — Python.

该博客着重介绍Golang Web开发的好处,并将Golang Web编程与另一种非常流行的语言-Python进行比较。

Python (Python)

Python has been around since 1991, but only today it became extremely popular. In fact, it has been enjoying increasing popularity for 5 years in a row and is now among the most frequently used programming languages. In web development, it is mostly used for back-end programming, although it also applies to front-end tasks. Ultimately, the main reason why Python is big on the web development scene is that it helps developers to solve the pressing demand for agility.

Python自1991年以来一直存在,但直到今天它才变得非常流行。 实际上,它已经连续5年受到越来越多的欢迎,现在已经成为最常用的编程语言之一。 在Web开发中,尽管它也适用于前端任务,但主要用于后端编程。 归根结底,Python之所以成为Web开发领域的佼佼者,主要原因是它可以帮助开发人员解决对敏捷性的紧迫需求。

Python is among the six most used programming languages and also at №1 in the annual IEEE Spectrum ranking.

P ython是六种最常用的编程语言之一,在年度 IEEE Spectrum 排名中也排名 №1

Python trend is on the rise with +5.2% of the increase in usage stats.

Python使用率增长了5.2%,呈上升趋势。

高朗 (Golang)

Golang is now considered to be an alternative to Python, and there is an incessant discussion about Golang web development vs Python.

Golang现在被认为是Python的替代品 ,关于Golang Web开发与Python的讨论一直在不断进行。

Created by Google in 2007, Golang now has many purposes. Apart from Golang web development, you are most likely to hear about Golang Micro-Services, Golang ERP systems, Golang mobile development, etc. On top of that, Golang is the language behind Docker technology, which is gaining increasing popularity today and is the main driver behind DevOps movement.

Golang由Google于2007年创建,现在有许多用途。 除了Golang Web开发之外,您最可能会听到有关Golang Micro-Services,Golang ERP系统,Golang移动开发等的信息。最重要的是,Golang是Docker技术背后的语言,在今天, Docker技术日渐流行。 DevOps运动背后的主要驱动力。

According to a report published on GitHub, Go is the fastest growing language of the year 2019.

根据在GitHub上发布的一份报告, Go是 2019年 增长最快的语言

Golang web development industry has grown almost 7% overall with a 1.5% change from the previous quarter.

Golang网站开发行业总体增长了近7%,与上一季度相比增长了1.5%。

Golang与Python的比较 (Comparison of Golang with Python)

There’s an ongoing discussion in developer’s community about the pros and cons of both programming languages. If you are looking for powerful tools for web programming, mobile app development, micro-services and ERP systems — we believe, that are solid reasons why you should switch to Golang.

开发人员社区中正在进行有关两种编程语言的优缺点的讨论。 如果您正在寻找用于Web编程,移动应用程序开发,微服务和ERP系统的强大工具-我们相信,这就是您应该改用Golang的坚实原因。

Image for post
Image for post

1.简单性 (1. Simplicity)

If Python has been the easiest-to-learn programming language so far, Golang is even simpler. It is much faster to learn and beats Python in this respect. Some developers claim Golang is almost as easy as JavaScript.

如果到目前为止,Python一直是最容易学习的编程语言,那么Golang会更简单。 在这方面,学习起来要快得多,并且胜过Python。 一些开发人员声称Golang几乎和JavaScript一样容易。

2.并发性和更快的性能 (2. Concurrency and Faster Performance)

Image for post

Golang concurrency model ensures faster performance (improved since the 2d and 3d versions). To give them justice, most modern programming languages use concurrency, but Golang approaches it in a more resource efficient ways. Instead of resource-demanding Python threads, it uses isolated goroutines, which save the resources of CPU and memory. Ultimately, this approach results in considerably faster performance and helps reduce costs and resources. Compared to Python/Java, running a function on a goroutines require minimal boilerplate code. You simply prepend the function call with the keyword “go”:

Golang并发模型可确保更快的性能(自2d和3d版本以来已得到改进)。 为了使它们具有公义性,大多数现代编程语言都使用并发,但是Golang以更节省资源的方式来处理它。 它使用隔离的goroutines代替资源需求的Python线程,从而节省了CPU和内存的资源。 最终,这种方法可显着提高性能,并有助于降低成本和资源。 与Python / Java相比,在goroutines上运行函数需要最少的样板代码。 您只需在函数调用之前添加关键字“ go”即可:

package main
import (
"fmt"
"time"
)func say(s string) {
for i := 0; i < 5; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Println(s)
}
}
func main() {
go say("world")
say("hello")
}

Binary search

二进制搜索

We created lists of ints (from 1 to 100000) and then used binary search to find always the same number 729. The results are:

我们创建了一个整数列表(从1到100000),然后使用二进制搜索来查找始终相同的数字729。结果是:

Image for post

Bubble Sort

气泡排序

Again we generated a list of integers (this time random ones, 10000 elements long) and sorted those using bubble sort algorithms.

再次,我们生成了一个整数列表(这次是随机的,长10000个元素),并使用冒泡排序算法对其进行了排序。

Image for post

Read from File

从文件读取

Image for post

HTTP Request Handling

HTTP请求处理

Making an HTTP server is really easy, but we made an effort and did the analog one in Python. We checked how long would it take to respond with a simple “hello world!” message.

制作HTTP服务器确实很容易,但是我们付出了很多努力,并在Python中进行了模拟。 我们检查了用一个简单的“ hello world!”做出响应需要多长时间。 信息。

Image for post

3.快速编译时间 (3. Fast Compile Time)

Go’s fast compile time is a major productivity win compared to languages like Java and C++ which are famous for sluggish compilation speed. I like sword fighting, but it’s even nicer to get things done while I still remember what the code is supposed to do.

与以缓慢的编译速度而闻名的Java和C ++之类的语言相比,Go的快速编译时间是主要的生产力提高。 我喜欢剑术,但是在我还记得代码应该做什么的情况下完成工作会更好。

Image for post

4. AI /机器学习 (4. AI/ML)

You can start creating AI with any language you want. However, it all depends on which language is the best-suited and easiest to manage in terms of teaching machines. Python is the leading language of AI but Go is often mentioned as one of the alternatives. Python vs. Go battle in the area of machine learning leads to a few conclusions:

您可以开始使用所需的任何语言创建AI 。 但是,这完全取决于哪种语言在教学机器方面 适合最易于管理 。 Python是AI的领先语言,但Go经常被称为其中一种。 机器学习领域的Python与Go之战得出了一些结论:

  • Despite the fact that Golang is faster than Python, it does not offer such a rich support system. Python has many frameworks, specifically designed for using machine learning: PyTorch, Scikit-Learn, Keras, TensorFlow, and many more.

    尽管Golang比Python快,但它没有提供如此丰富的支持系统。 Python有很多框架,专门为使用机器学习设计: PyTorchScikit-了解KerasTensorFlow ,等等。

  • Specialists indicate that one of the reasons people are attracted to Golang is its performance. However, you won’t find much support for machine learning with Go. There are some projects, but they are not as advanced as the army of Python’s frameworks.

    专家指出,人们被Golang吸引的原因之一就是它的表现。 但是,您会发现Go对机器学习的支持不多。 有一些项目,但是它们不如Python框架之类的团队先进。
  • Although Go offers small libraries it is consistently growing thus, addressing a large range of AI purposes. Go libraries such as GoLearn (data handling), Goml (passing data), and Hector (binary classification problems) are some of the libraries that serve AI and its applications.

    尽管Go提供了小型库,但是它一直在不断增长,从而解决了许多AI目的。 Go库(例如GoLearn (数据处理), Goml (传递数据)和Hector (二进制分类问题))是为AI及其应用程序服务的一些库。

A short conclusion would be that Python is not defeated by Golang in terms of machine learning. For that to happen, Go needs to have more frameworks specifically-designed for this purpose since using raw code can seem too time-consuming. Unless you are curious and want to experiment.

一个简短的结论是,就机器学习而言,Python 没有被Golang 击败 。 为此,Go需要有更多专门为此目的设计的框架,因为使用原始代码似乎太耗时。 除非您好奇并想尝试。

5. Python v / s Golang库 (5. Python v/s Golang Libraries)

Python Requests => net/http

Python请求=> net / http

The built in net/httpprovides HTTP client and server implementations that is really great, and super easy to use.

内置的net/http提供了非常好的HTTP客户端和服务器实现,并且超级易于使用。

Flask + Jinja2=> Gin

Flask + Jinja2 =>杜松子酒

Gin is an HTTP web framework with a really simple API — parameters in path, upload files, grouping routes (/api/v1 ,/api/v2), custom log formats, serving static files, HTML rendering and really powerful custom middleware.

Gin是一个HTTP Web框架,具有非常简单的API-路径中的参数,上传文件,分组路由( /api/v1/api/v2 ),自定义日志格式,提供静态文件,HTML渲染和功能强大的自定义中间件。

CLI Creation=> Cobra

CLI创建=> Cobra

Cobra is both a library for creating powerful CLI applications as well as a program to generate applications and command files.Many of the most widely used Go projects are built using Cobra including Kubernetes, etcd and OpenShift.

Cobra既是用于创建功能强大的CLI应用程序的库,又是用于生成应用程序和命令文件的程序。许多使用最广泛的Go项目都是使用Cobra构建的,包括Kubernetes,etcd和OpenShift。

Some other libraries that I highly recommend are: Viper, Gonfig, and this awesome list — Awsome-Go.

我强烈推荐其他一些库: ViperGonfig和这个很棒的列表-Awsome -Go

6.工资 (6. Salary)

In terms of salary, Go vs. Python argument is won by Go. It is a more profitable language to learn since Go programmers are already the third highest-paid developers (making $80k per year). In the meantime, Python developers make $64k per year. Lastly, it is up to you to decide which language sounds more suitable for you.

在薪水方面,Go胜过Python之争。 这是一种更具盈利性的语言,因为Go程序员已经是第三高收入的开发人员(年收入8万美元)。 同时,Python开发人员每年可赚6.4万美元。 最后,由您决定哪种声音听起来更适合您。

Image for post
Image for post

结论 (Conclusion)

Image for post

It is difficult to draw conclusions in Go vs. Python because comparing a mature language with a relatively young one does not seem fair.

在Go vs. Python中很难下结论,因为将成熟的语言与相对年轻的语言进行比较似乎并不公平。

Python is the leading language not only in machine learning, data analysis, but web development as well. Golang has only been around for a decade, and it has not built a strong ecosystem or community yet.

Python不仅是机器学习,数据分析以及网络开发中的领先语言。 Golang仅仅存在了十年,还没有建立一个强大的生态系统或社区。

One clear advantage of Go is its speed. While Python bows down to Go in terms of code execution, Go admits defeat in the production speed.

Go的一个明显优势是它的速度 。 尽管Python在代码执行方面屈服于Go,但Go承认生产速度上的失败。

Overall, choosing Go means that you are looking at the future since Go was concluded to be the 13th most popular programming language in 2020. Meanwhile, Python proudly occupies the 3rd place on this list, but it took 25 years for Python to get there.

总体而言,选择Go意味着自从Go成为2020年第13大最受欢迎的编程语言以来,您正在展望未来。 同时,Python自豪地在该列表上排名第三,但是Python却花了25年的时间才到达该列表。

I am grateful for the time you have invested in reading. This blog will surely help you to choose for your next business product.

感谢您为阅读所付出的时间。 该博客肯定会帮助您选择下一个商业产品。

翻译自: https://medium.com/@praks.jain7/is-golang-going-to-replace-python-soon-f93b0f700322

golang python

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值