Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Further discussion on the Application Prospect of Go language in the Front end

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

On December 23, Mr. Xu Shiwei, founder of Qiniuyun CEO & ECUG community, brought you a content sharing with the theme of "talking about the Application Prospect of Go language in the Front end" at the ECUG Con 2018 scene.

This article is a record of the content of the speech.

Cdn.xitu.io/2019/1/3/1681193686d202cb?w=1024&h=683&f=jpeg&s=527028 ">

This is the 11th year of ECUG Con, and what I talked about before is basically the development practice on the server side. Since last year, I've been talking about the front end instead of the back end. Of course, last year I didn't say why I focused on the front end. Before we talk about the application of the Go language in the front end today, let me briefly talk about the train of thought and why I pay attention to the front end today.

The evolution of the front end

In the earliest PC period, the most common devices were desktops and notebooks. These two types of devices are the mainstream devices in the PC era, using three mainstream operating systems, namely, Mac, Linux and Windows. The market share of the first two is very small, basically Windows dominates the world. In the early days, browsers were mainly IE because of the popularity of Windows, but today Chrome has a very high market share. In addition, there are Safari, Firefox, everyone is also familiar with.

Since Apple released iPhone as a symbol, we began to enter the mobile era. The devices in this period are mainly mobile phones and tablets, mainly mobile phones. The operating systems are basically Android and iOS, with very few operating systems such as Windows Mobile. Browsers are not desktop browsers like Chrome, but have been mobile browsers since WeChat Mini Programs. There are many kinds of Mini Program in China, including Mini Program, Toutiao Mini Program and so on. I think this is really the beginning of the mobile browser war.

What's strange is why the battle over mobile browsers didn't start in the United States, but in China, which is also interesting. Mini Program-related technology, whether Google or other companies, are also pondering, of course, I may be ill-informed, I do not see any signs of mobile browsers abroad. Why I say Chrome these are not mobile browsers, because the feel of the operation is very different. WeChat Mini Programs is the first time to try to make the application of BS structure feel the same as Native application, which is a very important attempt.

I also thought about the future. There are few devices in the mobile period, and laptops, mobile phones and tablets are the most mainstream devices. Desktops are not available today, but notebooks are often used by people. ECUG started in 2007, around the time Apple released the first iPhone. At that time, I made a judgment that the future is a strong server plus a diversified terminal, which is actually the front end. But today, in my opinion, front-end diversification has not really emerged.

In the 11th year of ECUG, we can see that this trend of diversification has become more and more realistic, including the next front battlefield after mobile phones, in my opinion, cars. The car is very hot. Of course, there will be more devices, and many people will think that the next era is the so-called Internet of things. We don't have to talk about such abstract terms to predict that the trend of the front end in the future will be very diversified. This diversity is very different from the PC era and the mobile era, because screen size plays a key role in the front-end interaction. Besides cars, there are also a lot of watches today, but the popularity may not be as high as that of mobile phones and tablets. A watch is a very special thing, it is very difficult to play with the front end on such a small screen. What will the future operating system look like? Today is still unknown.

The evolution of the front end is closely related to the evolution of the device. So the evolution of the front end has its ups and downs, which is very different from the server side. The development of the server side is very sound. The operating system is dominated by Unix, which is still the case today and does not change drastically. However, the evolution of the operating system is very drastic due to the change of the terminal in the front end.

The Evolution of Cloud Computing

The evolution of cloud computing, I am divided into three stages: the first stage, represented by Amazon's EC2, I call the machine computing stage. The whole architecture is built on the basis of virtual machine (VM). There is no difference between a virtual machine and a physical machine. Now we can't touch a virtual machine, but there is little difference between a virtual machine and a physical machine in terms of operating a virtual machine.

Today, we see a lot of differences, because containers have sprung up, and the typical sign from 2014 to today is that Kubernetes unifies the container operating system. On this basis, we can see that cloud computing has evolved to the second stage. The computing in the container computing period is different from that in the machine computing period. The container will pay more and more attention to the automation of operation and maintenance and related basic support, and its ultimate goal is to make the server basically tend to be free of operation and maintenance. In the future, when we do business, we basically don't have to care too much about the server.

This also raises another question: where will cloud computing go in the next phase? In my opinion, it's applied computing. Because the cloud has become more and more standard with the development of container technology, the next stage of cloud computing should focus on the business, and do more and more integration with the business, no longer just focus on the infrastructure, but on the business architecture of the application itself. In the application business architecture, the end accounts for a very large component. Cloud computing and the end are not separate.

Evolution trend of Cloud + end

In my opinion, cloud computing will make the back-end technology stack more and more standardized. Most of the technical challenges at the back end can be solved by standardization. Every company has an infrastructure department, and cloud computing is to move the technical architecture department from within the company to the outside. This standardization occurs naturally. Because of this, the difficulties and challenges of the business will move forward more and more. The server side is not much of a challenge. From the point of view of supporting the business, the challenges of the server are getting less and less. However, from the server-side system, the focus may be more and more inclined to the standardization of the business operation system, that is, BI (business intelligence). But it's harder to standardize than the front end.

Why am I talking about the front end today? At the moment, we are still working very hard to standardize the back-end technology, but in my opinion, this matter will be solved in a few years that can be expected, and the energy will be spent on the front end in the further future.

Many people know that Qiniuyun is very closely related to the Go language. I probably made a presumptuous prediction in 2012 that the Go language will definitely be at the top of the language list. I set it for about 10 years. It is almost the seventh year since 2012. Go is a very dedicated language, people who use Go basically focus on the back-end development, and prefer the back-end API-level development, Web accounts for a relatively small proportion. Go's focus makes it basically occupy the entire field of cloud computing today. The proportion of Go in the technology stack of many cloud computing companies will be higher and higher. This focus has also made Go a milestone in the top 10 this year.

The Evolution of Go language

There is no way to make Go number one by focusing on back-end development. The reason is simple: after the back-end development, especially cloud computing, leads to more and more standardization of the back-end technology, there will be less and less opportunity for the Go language to display its talents, because the complexity of many problems has been solved by cloud computing companies. Most companies just do their own business, and there is no need to care about the complexity of servers with high concurrency and high availability. The challenges on the server side will weaken with the impact of cloud computing. In this way, the position of Go language today, if it is a company, should have a sense of crisis and break through the next battlefield. In my opinion, it will definitely enter the front end, and it will also make the Go language more common, and the domain will become more and more extensive. Such a change can make Go the number one language in the real sense.

Why is the Go language suitable for the front end?

The front end has the greatest demand.

The front end is the type of work with the largest number of developers and the most demand, and the requirement for language must be that the threshold for entry is relatively low and the mental burden is the least. And this is perfect for Go. When I launched Go in 2011, most people didn't know much about Go, but today the audience of Go language is very wide, and there is a great consensus that the entry threshold for Go language is very low, and the mental burden is relatively low. The basic program is written and compiled, and there is no problem with the high probability. This feature makes it very suitable for the front end.

The front end needs a stronger engineering language.

The front-end business is very large, so the front-end code is much more than the back-end. The front end is responsible for dealing with users, and things that deal with people are the most complex and easy to change. Today this knowledge may be better, tomorrow may be a new kind of knowledge, especially I mentioned earlier the end of the change. Screen sizes vary from PC to laptops to mobile phones, and from keyboards to touch screens in the past to watches or cars in the future. Why do many companies pay attention to voice interaction? because of devices such as cars and watches, voice interaction is a better means. But there is a lot of uncertainty. The change in the front end is drastic, and the feel of the interaction and the efforts that programmers have to make to make users comfortable and cool will also be very great. The front end must have the largest amount of code.

The front end is in great need of a language with strong engineering ability. Today we see that the largest amount of code on the front end must be JavaScript, but JavaScript has almost no engineering support. It is called Script because it is small, similar to WeChat Mini Programs. If you think about it, Mini Program must be not small. In such a big thing, or in an application with more code, the engineering language needs to be stronger. The reason why JavaScript is popular is its "monopoly position". There is a trend that has taken place, but it is not particularly strong today, that is, more and more languages will move into the front end, and Go will only be one of them. This is determined by the demand, and I think Go is one of the most promising ones.

I talked about why I am talking about the front end of ECUG Con. What I am talking about today may not have much impact on you, because the front end of Go is still very rudimentary, but ECUG Con I hope it is a meeting of forward-looking trend exploration. I do not tend to think that it must be very practical. It does not need to talk to you today, and it will be used in engineering tomorrow. I do not have such a definition of it. I hope that ECUG itself is a community with foresight for the future.

The Progress of Go in the Front end

Looking back at the progress of Go at the front end, GopherJS is the first progress that has really made a difference. There were a lot of people doing front-end related things before GopherJS. Google has also launched a framework called GXUI,GXUI that is not very maintainable today.

Many people will try to build a cross-platform framework, but in fact, the most promising cross-platform framework must be the browser. Because browsers are cross-platform frameworks. In my opinion, things like QT, including Google's GXUI, are relatively limited. But GopherJS, I think it's the first really tenable attempt at the front end. He's just doing what I just said, so that Go programmers can write the front end. How to write? It makes a compiler that translates Go code into JavaScript code, and naturally Go can write the front end. It is a machine language that uses JavaScript as the front end, because the position of JavaScript can not be bypassed.

But it's not really impossible to get around it. The front-end machine language is definitely JavaScript by today's standard, but we also see another thing called WebAssembly, which, as its name implies, sees itself as the assembly language of Web. But in fact, this WebAssembly is binary, I think it is the assembly language of Web, rather than the machine language of Web. The coverage of WebAssembly is wider than you think, and all major browsers support it today. There has been some change in JavaScript's "monopoly position", and it will not remain so forever. You may have heard that Go already supports WebAssembly, and it is built-in language support, which is also very important for Go.

The second major milestone of Go's progress at the front end is Go's built-in support for WebAssembly (https://github.com/golang/go/wiki/WebAssembly). Starting with version 1.11 of Go. This is Go's official introduction to WebAssembly Go support. The compilation process is to define the GOOS environment variable as js and select wasm as the schema, so that you can compile the wasm file instead of the local executable program. Here are some DEMO, WebAssembly samples written by people in some communities in Go.

The DEMO sample shows:

Https://stdiopt.github.io/gowasm-experiments/

Https://justinclift.github.io/wasmGraph2/

Https://stdiopt.github.io/gowasm-experiments/splashy/

The effect of this demonstration is achieved by the later source code. It may seem like nothing, but this support is crucial. Go supports Web front-end development from the beginning of the built-in language. Although it is still an empirical version of the state today, it is also a very important milestone. The people who do this are the same people who did GopherJS before. There's a bunch of people who are trying to push Go to the front.

The first two if you pay attention to the Go language should be known to many people, but the next thing most people should not know. There is a new thing called TinyGo, which runs Go on embedded devices. It is a tailored version of Go (https://github.com/aykevl/tinygo). Because Go is mainly for server-side development, people don't care how big the executable file compiled by Go is, but if you pay attention to it, you will know that it is very large. TinyGo tries to make the compiled files small enough because disk space and memory are precious on embedded devices. It also supports WebAssembly and can do Web development, although it cuts out a lot of Go features. I don't know how it evolves later, because the project is still very new, less than a year old. We can only pay attention to the new things, and there is no way to really apply them to any projects.

The Go 2D Game Development engine (https://github.com/hajimehoshi/ebiten), which is actually available in 3D, is not listed today. This game engine is made by the Japanese and has been used to develop a variety of mobile games. It is a commercial engine. Support for a wide range of platforms, games made with this game engine can support PC operating systems such as Windows, Mac, Linux, FreeBSD, but also support mobile operating systems Android, iOS, but also support Web development such as GopherJS, WebAssembly. It is a production engine. DEMO, which I demonstrated last year, wrote a parser for the children's programming language Scratch in Go, which is made using this 2D game development engine.

The next interesting thing is Go's front-end code hosting (https://github.com/dave/jsgo). JavaScript has a lot of open front-end code hosting, but here there is Go front-end code hosting. Just throw it here and go straight to the cloud. It may seem like a niche, but some people do these things.

There are also some DEMO:

This is a game of spelling numbers.

Https://jsgo.io/hajimehoshi/ebiten/examples/2048

This is Tetris.

Https://jsgo.io/hajimehoshi/ebiten/examples/blocks

This is a game, and the version you've seen before is a bird, not a marmot.

Https://jsgo.io/hajimehoshi/ebiten/examples/flappy

This is a Web application of the To do list class. Add it just to show that Go can also do a standard front-end development.

Https://jsgo.io/dave/todomvc

Jsgo.io supports both GopherJS and WebAssembly. The game we just saw is not a js file, but many. In the source code, Go will import some Go standard libraries, such as the string conversion library strconv. The string conversion Go standard library is compiled directly into a separate js file. The advantage of this approach is that the first time is a little slower, but the later load will be very fast (because there is little need to change it). After a large front-end application is disassembled in this way, it will load faster in the long run. It supports sub-module loading, and we do not have to make any effort for sub-module loading, Go reference will eventually become a module reference, corresponding to js is also a module. This kind of programming will be very cool. In the front-end JavaScript language, this kind of modular programming is not built-in to the language.

At present, Jsgo.io 's support for WebAssembly is not perfect. Unlike GopherJS, it cannot be referenced by package at present. What it compiles is a large wasm file. But this is only a temporary state, because the support for this piece has only just begun.

As I said earlier, many people are trying Go's universal card platform gui library, but all of them have failed. This is not caused by Go, but because cross-platform solutions such as QT are not in line with the trend. The most promising cross-platform solution is browser technology, based on HTML5 and Mini Program, which are truly production-level cross-platform solutions. Especially with the emergence of Mini Program, we can see many cross-platform libraries today, such as the applications made by React are still stiff, but WeChat Mini Programs is the first to try to make the Web experience consistent with the Native experience.

The Development Prospect of Go in the Front end

Go cross-platform game engine, has been basically close to the production level, it is a very important breakthrough.

In my opinion, Go's first breakthrough in the front end must have started in the game field. Its significance for Go is a historic breakthrough of 0 to 1. If no commercial company uses it, this thing is a toy. But Go's game engine will not be a toy, because more and more commercial companies will use it. Not necessarily this game engine, maybe someone will do something better, but this is a reliable direction. For Go, just as Go, the popular representative of Docker and Kubernetes, has occupied the cloud. Go also needs a killer mace at the front end, which is the game engine.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report