After cloud computing, Go's next Battlefield: the game industry

Source: Internet
Author: User
Tags gopher
This is a creation in Article, where the information may have evolved or changed.


Since its inception, Go has been the focus and practice of developers due to its simple and efficient processing efficiency and excellent support for concurrency. And in 2013 with the birth and development of the heavy project Docker, gradually formed prairie fire in the field of cloud computing. Where will the next point of the Go when the cloud is occupied?



At the 10 anniversary of the Ecug Con, Qiniu CEO, Go chief Evangelist Xu Xiwei, gave his heart the answer: the game industry.



Here is a transcript of his presentation



As a technical CEO, I think the technical staff are very pure, data-oriented, rational judgment trend, so today I will stand in a rational perspective, to talk about the future trend of Go, the focus is in the game industry.



Use Go for game development







 we can see that Go on the development timeline of Mobile, starting from the beginning of 12, in fact, the initial focus of its not high, until the middle of 14, its activity has increased significantly.




although Go official mobile support is more than the web, but gopher the Web front-end support is far higher than mobile. Gopherjs's community activity has been high since August 13, and we can see that Gopher have a common dream with JavaScript programmers, using a language to unify the front and back.



Through the comparison of the above two graphs, it is very important to conclude that go on the desktop side of the development, that is, the use of the Go language to write desktop programs, of course, there are many people are trying, including two genres: general UI and vertical industry (game industry). The Go team's official response focused more on the latter, focusing on the vertical industry-the game industry.



Why is it a game industry? You can see the feasibility from the following two points:


    1. Market reason game market space is huge;
    2. Technical reasons game industry compared to other industries, desktop OS Standard controls are often deprecated, so demand is relatively convergent and easier to meet.


Next, explore the feasibility of using Go to write a game, for the GUI, the underlying support is OpenGL, which itself supports PC (WINDOWS/MAC/LINUX/FREEBSD), Mobile (Android/ios) and web (based on WebGL). For the game, the following points: PC game (PC), page tour (WEB), Hand-Tour (Mobile), these three items can be developed using go: the PC can be through OpenGL, hand-travel through the Go Mobile, page tour through the GOPHERJS (the code to compile the go JavaScript) Go page tour is very mature, the use of the technology stack is relatively small, only need to use WebGL and Gopherjs, you can also call the JavaScript framework, such as



WebGL (https://github.com/gopherjs/w ...,
JQuery (https://github.com/gopherjs/j ...,
Websocket (https://github.com/gopherjs/w ...



In general, go to the Web support is very mature, and its application surface is not limited to page tour, 3 is a copy of a React project "vecty", is the use of go to develop, from the figure we can see this project was launched in 15, the activity is also relatively considerable.





Use Go to do cross-platform games



Use go to do full platform game support compared to the WEB, the things that can be used are much more convergent, and many libraries like Javascript can no longer be used.



At this point I chose the technical solution: use Go to do cross-platform Scratch.



First talk about what is Scratch, which is a language for children's programming teaching, can teach children to write games, now its rankings have been squeezed into the top 20 of the engineering language rankings. Why use go to rewrite Scratch? One is out of my love for it, followed by Scratch there are still some flaws, I hope to be able to gradually improve.



2.X Version (HTTPS://GITHUB.COM/LLK/SCRATC ... Can only be written based on Flash and only run on the PC, and based on Google blockly + React written version 3.0 (HTTPS://GITHUB.COM/LLK/SCRATC ... Although it is already available, there are still problems with compatibility, such as incompatibility with 2.X in many places, but 2. The user population of x is very large. So there is a lot of room for improvement in Scratch, which is very well worth looking forward to.



Goals and challenges



It is because of the lack of Scratch, let me see the challenge. I set a goal for myself to be a Scratch script executor compatible with Scratch 2.X cross-PC, mobile, WEB multi-terminal platform. Here are a few of the challenges I face:



1. Script supports-json script
scratch2.x is a Json script that is not very difficult from a parser perspective, but the difficulty from the executor perspective is consistent with the difficulty of using other scripts. Second, its script is single-threaded pseudo-parallel, because the different Scratch scripts may share variables and Scratch does not have the mutex syntax, so true parallelism can cause system logic confusion. Simulating a single-threaded pseudo-parallel program in Go is relatively complex, so this is the first challenge I have faced.



2. Multi-line text layout and display
True Type font support, small typesetting system need to consider the line ban (for example: punctuation cannot be at the beginning of the line, English words can not be split into two lines display)



3. Audio playback
You need to support common audio formats, and to support mixing (you can play multiple sounds simultaneously, you should have more than one speaker at a time)



4.SVG format support
Scratch 2.X built-in sprites are in vector format, and SVG has a very complex instruction set based on SVG format, complete support equivalent to writing a set of GDI Canvas (the current go community does not have mature SVG rendering of the project)



5. Complex graphics


though seemingly simple, is more difficult to support, and of course, once SVG is supported, this is just an instruction for SVG.



6. Collision Detection
This is basically the most basic requirement of a game program: two sprites (sprite) Collision detection



Practical results



After half a month of actual development, but also because I was teaching my son to learn programming accumulation of 2 years of experience, let me precipitate a lot of material, now I write all Scratch tutorial basic can be normal execution, the following is my 2 years of accumulated some material examples:



1. Social class
Dialogue: WEATHER-CONVERSATION.SB2, including audio playback, multi-line text layout and display, there are many complex graphics, behind the script and so on.



2. Chess and Board class
Gobang: FIVE-CHESS.SB2; go: go-chess.sb2; Chess: CHESS.SB2, these look simple, but to be complete involves a complex process (the processing of shared global variables), complex scripts, and more.



3. Mini-Games
Eat cake: EAT-CAKE.SB2; This is written by my son, and the difficulty is in collision detection



Cross-platform contention: React vs.go



Scratch3.0 is done using React, and I use go to do a whole new challenge. Scratch3.0 did a lot of things, spent more than a year of time, the function is relatively perfect, but for me personally I just made an actuator, the difficulty is different, so finally I will do a comparison of the two, compare their pros and cons.



1.react+react Native
Advantage: The scene is more general, can be based on WebGL can also develop games;
Disadvantage: tend to move the Web to Native (mobile) technology stack complex, performance is relatively low, React framework on the difficulty of developing the game basically does not burden.



2.go+gopherjs
Advantages: The technology stack is very simple, easy to get started, excellent performance;
Disadvantage: relatively small crowd;
Scene: More vertical, more complete support for the game.



Summarize



Go Desktop side battlefield is just beginning, but the technology is relatively mature, although very early, but because of the development of go to improve the efficiency, to some extent eliminate due to the early cause of the lack of resources, so even if the front-end knowledge is not enough, but after years of development, go The rich resources of the community make up for this shortcoming.



Suggestions can be properly focused, choose the right time to enter the "battlefield." Enter the direction you can choose: one is to use go to write games, it can do full platform support, and the other is to use go to write WEB applications to replace React and other frameworks.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.