Home>Article>Backend Development> Can go language be used to write the Internet of Things?

Can go language be used to write the Internet of Things?

青灯夜游
青灯夜游 Original
2022-12-28 16:46:44 5325browse

can be written. In the field of Internet of Things, Golang can be used to efficiently access and manage millions of devices; and use Golang's various cutting-edge technologies to analyze data in real time and create data reports. The reasons for using Golang to develop the Internet of Things platform: 1. The three authors of Go are highly capable; 2. The performance of Go is second only to C/C; 3. Getting started is very fast, and most programmers can get started in 1-2 weeks; 4. It has good concurrency characteristics; 5. It is compatible with a large number of hardware devices; 6. It has good community support; 7. It can help developers speed up with clean code.

Can go language be used to write the Internet of Things?

The operating environment of this tutorial: Windows 7 system, GO version 1.18, Dell G3 computer.

If your budget is relatively small, you may want to consider using Golang first. Golang's concurrency features and excellent performance can make full use of existing hardware, unlike Java and Python, which will cause a certain amount of waste and require you to spend more money.

In the field of Internet of Things, Golang can be used to efficiently access and manage millions of devices. And use Golang's various cutting-edge technologies to analyze data in real time and create data reports.

The following are the reasons why we chose Golang to develop the ThingsPanel IoT system:

Founder

Three authors of Go They are: Rob Pike, Ken Thompson and Robert Griesemer.

Rob Pike: Was a member of the Unix team at Bell Labs and the Plan 9 operating system project. He worked with Thompson for many years and co-created the widely used UTF-8 character encoding.

Ken Thompson: Mainly the author of B and C languages and the father of Unix. Winner of the 1983 Turing Award and the 1998 National Medal of Technology. He and Dennis Ritchie are the original creators of Unix. Thompson also invented the B programming language that later derived from the C language.

Robert Griesemer: Before developing Go, he was a major contributor to Google V8, Chubby and HotSpot JVM.

Performance is second only to C/C

GoLang is a compiled language that can be compiled into machine code, and the compiled binary file can Deploy directly to the target machine without additional dependencies. Performance is better than those of interpreted languages.

The picture below is a test. It seems that the speed of Golang is still very powerful.

Can go language be used to write the Internet of Things?

Performance comparison of common languages(Picture author: I don’t want to farm)

If there is a higher Requirements, it is also possible to embed C code in Go programs so that many powerful C tool libraries can be used.

#Getting started is very fast, and most programmers can get started in 1-2 weeks.

If PHP programmers switch to Golang, they can start correcting bugs in 2 days. After a few weeks, you can start working more normally.

When communicating with various technical staff, ask them how long it will take for you to switch from PHP or Java to Golang. Most of the answers are 1-2 weeks, which is also true.

Concurrency Features

This is probably the most praised feature of GoLang. It can take full advantage of multi-core capabilities. GoLang uses goroutines to achieve concurrency, and it provides a very elegant goroutine scheduler system that can easily generate millions of goroutines. Stack usage can also be expanded/shrunk dynamically, which makes memory usage smarter. This is different from Java threads, which typically only allow the creation of thousands of threads.

Compatible with a large number of hardware devices.

Various CPU architectures are supported. Whether it is an X86 server or an ARM edge device, it can be directly compiled into machine code, and the deployment is completed by throwing in a file.

A 52PHP user said on his cnblogs blog: Through super simple cross-compilation, you only need to change the environment variables. (It took me two days to compile an imagemagick to the arm platform).

If you have a lot of edge devices, Golang is a good choice.

Of course, some people say that Java and PHP are also available. The problem is that you can also deliver food while riding a donkey. The problem is how slow it is!

Good community support.

Without expert preaching, novices will not have a master to lead them in. Without sharing, learning becomes even more difficult. Golang has good community support.

Programming language popularity on Stack Overflow, the world's largest technical question and answer website:

Can go language be used to write the Internet of Things?

##Quoted from: 2021 Programming Language Ranking, Author : Xiaoxin takes you to learn programming

You can look up information, ask questions, and someone will answer you. This is very important in development.

Help developers speed up with clean code.

"Clean architecture" is a concept proposed by Robert C. Martin (Uncle Bob) (About, Robert C. Martin Robert C. Martin's work (16)) in 2012 when he summarized the existing system architecture. .

In the article, the clean architecture he proposed is like this:

  • Independent of the framework. The architecture does not rely on the existence of some feature-rich software library. This allows you to use a wide variety of frameworks as tools.
  • Testable. Business rules can be tested without a UI, database, web server, or any other external elements (such as third-party RPC services).
  • Independent of the user interface. The user interface can be easily changed without having to change other parts of the system. For example, the web user interface can be replaced with a console interface without having to change business rules.
  • Independent of the database. You can swap Oracle or SQL Server for Mongo, BigTable, CouchDB
    or something else. Your business rules are not bound to the database.

Independent of any external agency (outer layer in the image below). In fact, your business rules don't know anything about the outside world.

Can go language be used to write the Internet of Things?

#The general idea in the diagram is that the direction of dependence can only be from outside to inside. In other words, the outer circle depends on the inner circle, and the inner circle cannot depend on the outside. Naming and data formatting in the outer layer cannot affect the inner layer.

These simple rules and conventions ensure that the system is always easy to understand, easy to develop, and easy to maintain.

The case is convincing

In addition to the famous Docker, it is completely implemented with GO. Kubernetes, the industry's most popular container orchestration management system, is completely implemented in GO. The subsequent Docker Swarm was completely implemented in GO. In addition, there are various famous projects, such as etcd/consul/flannel, Qiniu Cloud Storage, etc., all implemented using GO. Some people say that the reason why GO language is famous is that it has caught up with the cloud era. But why not put it another way? It is also the GO language that promotes the development of the cloud.

In addition to cloud projects, there are also companies like Toutiao and UBER, which have also used GO language to completely reconstruct their businesses.

【Related recommendations:Go video tutorial,Programming teaching

The above is the detailed content of Can go language be used to write the Internet of Things?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn