In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the five reasons for changing the project language from Python to Go. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Preface
Python is a very popular language. But in the corporate world, the go that can play does not give people any chance to survive.
If you understand the meaning of this sentence, you may have tried or seen the Go programming language. I think it is the simplest programming language and can be applied to any type of application development.
Right! You read it right. To me, go is easier to learn than JavaScript. I think this is the main reason why the go language has become so popular in a few years.
Let's compare Python with Go.
So what do we have before we use Go?
This is our Python technology stack:
Response .js of Dashboard front end
Django Python is used for dashboard backend + authentication service
Node.js for API services
PostgreSQL is used for databases and Cassandra for logging
Custom written Container Registration and Rust language
As you can see, the entire infrastructure is based entirely on micro-services, with most of the logic completely separated and even using different technologies.
This is the main reason we started thinking about merging API services and backends into a single project, as they have many similarities, but the code base is duplicated in many programming languages and technologies. But we need to do a lot of work to customize Django's API service, especially the JSON response.
Why use Go
As I said before, the Go language is the simplest language I have ever seen and used. But that's only the first thing that attracts me.
Here are five main reasons why we chose Go over Python Django
1. It is compiled into a single binary file
Golang is built as a compiled language, and Google developers have done a good job in this respect. Using static linking is actually combining all dependent libraries and modules into one binary file based on operating system type and architecture. This means that if you compile your back-end application with Linux X86 CPU on your laptop, you just need to upload the compiled binaries to the server and it will work without installing any dependencies there!
two。 Static type system
Type systems are important for large-scale applications. Python is a great and interesting language, but sometimes you encounter unusual exceptions because you try to use a variable as an integer, only to find that it is a string.
# Django will crash process because of this def some_view (request): user_id = request.POST.get ('id', 0) # If this post request has "id" parameter then # user_id would be a string, # but you really thinking it is integer User.objects.get (id=user_id)
Go will let you know about this problem as a compiler error at compile time. This is where you win your time.
3. Performance!
This may be surprising, but in most applications, Go is faster than Python (2 and 3).
In our case, Go performs better because of its concurrency model and CPU scalability. Whenever we need to process some internal requests, we use a separate Goroutine to handle it, which is 10 times cheaper than Python threads in terms of resources. As a result, we save a lot of resources (memory, CPU) because of the built-in features of the language.
4. You don't need a network framework.
This is the best thing about programming languages. The creators and communities of the Go language have built many tools supported by the language core, and in most cases, you really don't need any third-party libraries. For example, it has http, json, and html templates that are built in the native language, and you can build very complex API services without even having to look up libraries on Github!
But, of course, there are many libraries and frameworks built for Go, as well as building web applications using Go, but I recommend building web applications or API services without using any third-party libraries, because in most cases they are not easier than using native packages.
5. Great IDE support and debugging
IDE support is one of the most important things when you try to switch programming languages. A comfortable IDE saves an average of 80% of coding time. I found the Go plug-in for JetBrains IDEA, which also supports (Webstorm, PHPStorm, etc.). This plug-in provides everything you need for project development, and with the power of JetBrains, you can really promote development.
According to our code base statistics, after rewriting all the projects to run, we get 64% less code than before.
Go provides us with great flexibility, provides a single language for all use cases, and is very effective for all use cases. The performance of our back-end and API services has improved by 30%. Now we can process the log records in real time, transfer them to the database, and stream them from single or multiple services using Websocket! This is a good result of the Go language features.
The five reasons for changing the project language from Python to Go are shared here. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.