当前位置:网站首页>Go language introduction detailed tutorial (I): go language in the era
Go language introduction detailed tutorial (I): go language in the era
2022-07-05 23:29:00 【Look, the future】
List of articles
The previous article is relatively general , But I did go through the knowledge points quickly , Mixed with a familiar face . But I still suggest that whether there is a basic partner or not , I've been through this series of tutorials for getting started , Because it is difficult for us to grasp some internal things of language when we get started quickly .
Go Language core development team
Go glottogony 2007 year , And in 2009 Officially released in . It is from 2009 year 9 month 21 As a Google company on the th 20% Part-time project , That is, relevant employees use 20% Spare time to participate in Go Language research and development . The three leaders of the project are all famous IT The engineer :Robert Griesemer, Participation in development Java HotSpot virtual machine ;Rob Pike,Go Head of language project , Bell LABS Unix Team members , Participating projects include Plan 9,Inferno Operating system and Limbo programing language ;Ken Thompson, Bell LABS Unix Team members ,C Language 、Unix and Plan 9 One of the founders of , And Rob Pike Jointly developed UTF-8 Character set specification . since 2008 year 1 Month begins ,Ken Thompson We began to develop a product with C Language as the target result of the compiler to expand Go The design idea of language .
This is a field by computer “ The father of invention ” The golden team , Their understanding of system programming languages , Operating system and parallelism have very deep insights
Why should I put such a paragraph at the beginning of the series ?
I don't know how many people have thought about it like me : If there is a language , It has C++ Stability and speed , Yes python The concise , also Java The garbage collection mechanism of . How awesome that must be !!!
Now? , With .
Under the times go Language
1、 just as “21 Century's C Language ” What this sentence says ,Go Language is not made out of thin air , But and C++、Java and C# It belongs to C system . More Than This , The designers also absorbed the essence of other programming languages into Go In language .
2、 In terms of declaration and package design ,Go Language affected Pascal、Modula and Oberon The influence of language ; In the design of concurrency principle ,Go Language is also affected by Tony Hoare Of CSP( Communication sequence process Communicating Squential Processes) Theoretically influenced Limbo and Newsqueak Some experience has been learned from the practice of , And used and Erlang Similar mechanism .
3、 This is a completely open source programming language , Because it uses BSD licensing , So anyone can develop commercial software without paying any fees .
4、 Although in order to enable the current mainstream developers to Go Class in language C The grammar of the language feels very friendly and easy to transform , But it greatly simplifies these grammars , Make them better than C/C++ The grammar of is more concise and clean . meanwhile ,Go Language also has some characteristics of dynamic language , This enables the use of Python and Ruby Developers are using Go It feels very easy to use language .
Why create go Language ?
1、C/C++ The development speed of can't keep up with the pace of computer development , For more than ten years, there has not been a mainstream system programming language in line with the times , Therefore, people need a new system programming language to fill this gap , Especially in the computer information age .
2、 Compared with the improvement of computer performance , The field of software development is not considered to be growing fast enough or more successful than hardware ( Many projects have failed ), At the same time, the volume of the application is always expanding , This urgently requires a low-level language with higher-level concepts to break through the current situation .
3、 stay Go Before language , Developers are always faced with very difficult choices , It's a language that runs fast but doesn't compile well ( Such as :C++), Or use a language that compiles faster but performs poorly ( Such as :.NET、Java), Or a dynamic language with low development difficulty but low execution speed ? obviously ,Go The language is here 3 The best balance is achieved between the conditions : Quick compilation , Efficient execution , Easy to develop .
go Language development goals
1、Go The main goal of language is to combine the security and efficiency of static language with the ease of development of dynamic language , Reach the perfect balance , It makes programming more fun , Instead of making painful choices .
therefore ,Go Language is a type safe and memory safe programming language . although Go There are still pointers in the language , But pointer operations are not allowed .
2、Go Another goal of language is for network communication 、 Excellent support for concurrent and parallel programming , So as to make better use of a large number of distributed and multi-core computers , This is very important for Google's internal use . The designer passed goroutine This concept of lightweight threads to achieve this goal , And then through channel To achieve each goroutine Communication between . They achieved segmented stack growth and goroutine Automation of multiplexing technology based on threads .
This feature is obviously Go The most powerful part of language , It not only supports the increasingly important multicore and multiprocessor computers , It also makes up for the shortcomings of existing programming languages in this regard .
3、Go Another very important feature of the language is its construction speed ( The speed of compiling and linking to machine code ), In general, it takes only hundreds of milliseconds to a few seconds to build a program . As a mass use C++ To build infrastructure for Google , There is no doubt that it has fundamentally got rid of C++ A nightmare that is not ideal in terms of construction speed . This not only greatly improves the productivity of developers , At the same time, it also makes the code testing link in the software development process more compact , Instead of wasting a lot of time waiting for the program to be built .
4、 Dependency management is an important part of software development nowadays , however C In language “ The header file ” As a result, more and more large-scale projects need several hours to build due to dependencies . People increasingly need a strict 、 Concise dependency analysis system, which can quickly compile the programming language . That's exactly what it is. Go The fundamental reason why the language adopts the package model , This model accelerates program construction through strict dependency checking mechanism , It provides very good scalability .
Whole Go The compilation time of language standard library is generally 20 Within seconds , Other regular projects only need half a second to complete the compilation . This lightning fast compilation is even faster than compilation C Language or Fortran Faster , This makes compilation no longer a problem that puzzles developers in software development . before this , Dynamic language takes fast compilation as its highlight , image C++ Such static languages generally have a very long compilation and linking work . And also as a static language Go Language , Through its own excellent construction mechanism , Successfully removed this drawback , Make the construction process of the program trivial , Have the ability of efficient development like script language and dynamic language .
5、 in addition ,Go Language can also be compared with C/C++ par .
6、 Due to memory problems ( It is often called a memory leak ) It has been accompanied by C++ Developers of ,Go Language designers believe that memory management should not be a consideration for developers . So even though Go Language executes local code like other static languages , But it still runs a virtual machine in a sense , In order to achieve efficient and fast garbage collection ( A simple tag is used - Clear algorithm ).
Although garbage collection is not easy to achieve , But consider that this will be an important part of the development of concurrent applications in the future ,Go The designers of the language still completed this difficult task .
7、Go The language can also perform reflection related operations at runtime .
8、 Use go install It is easy to deploy third-party packages .
Besides ,Go The language also supports calling by C Massive library files written in , Thus, the software developed in the past can be quickly migrated .
go Characteristics of language
Go Language is essentially ( Procedural and structural aspects ) To achieve concurrent programming . because Go Language has no concept of class and inheritance , So it's connected to Java or C++ It doesn't look the same . But it's through the interface (interface) To achieve polymorphism .Go Language has a clear and easy to understand lightweight type system , There is no hierarchy between types . So it can be said that this is a mixed language .
In traditional object-oriented languages , Using object-oriented programming technology is very bloated , They always build huge type hierarchies through complex patterns , This goes against the purpose that programming languages should improve productivity .
Go The language uses static types , So it's a type safe language , Plus by building into native code , The execution speed of the program is also very fast .
As a strongly typed language , Implicit type conversions are not allowed , Remember a principle : Make everything explicit .
Go The language supports cross compilation , For example, you can run Linux The system is developed and run on the computer Windows Applications running under . This is the first door to fully support UTF-8 Programming language , It's not just that it can handle the use of UTF-8 Encoded string , Even its source file format is used UTF-8 code .Go Language is truly international !
About missing features
Many features that can be used in most object-oriented languages Go Languages are not supported , But some of them may be supported in the future .
To simplify the design , Function overloading and operator overloading are not supported
In order to avoid C/C++ Some in development Bug And chaos , Implicit conversion is not supported
Go Language implements object-oriented design in another way to give up the inheritance of classes and types
Dynamic loading of code is not supported
Dynamic link libraries are not supported
Generics are not supported
adopt recover and panic To replace the exception mechanism
Static variables are not supported
边栏推荐
- Realize reverse proxy client IP transparent transmission
- Solution to the packaging problem of asyncsocket long connecting rod
- Southeast Asia e-commerce guide, how do sellers layout the Southeast Asia market?
- The maximum happiness of the party
- Hainan Nuanshen tea recruits warmhearted people: recruitment of the product experience recommender of Nuanshen multi bubble honey orchid single cluster
- Comparison of parameters between TVs tube and zener diode
- VS2010编写动态链接库DLL和单元测试,转让DLL测试的正确性
- Rethinking about MySQL query optimization
- Judge whether the binary tree is a complete binary tree
- How to design API return code (error code)?
猜你喜欢
Sum of two numbers, sum of three numbers (sort + double pointer)
动态规划 之 打家劫舍
Neural structured learning - Part 2: training with natural graphs
Alibaba Tianchi SQL training camp task4 learning notes
98. 验证二叉搜索树 ●●
2022 R2 mobile pressure vessel filling review simulation examination and R2 mobile pressure vessel filling examination questions
《牛客刷verilog》Part III Verilog企业真题
数学公式截图识别神器Mathpix无限使用教程
无刷驱动设计——浅谈MOS驱动电路
Southeast Asia e-commerce guide, how do sellers layout the Southeast Asia market?
随机推荐
Common static methods of math class
(4)UART应用设计及仿真验证2 —— RX模块设计(无状态机)
Media query: importing resources
TVS管和ESD管的技术指标和选型指南-嘉立创推荐
Week 17 homework
Leecode learning notes
Multi view 3D reconstruction
Commonly used probability distributions: Bernoulli distribution, binomial distribution, polynomial distribution, Gaussian distribution, exponential distribution, Laplace distribution and Dirac delta d
《牛客刷verilog》Part III Verilog企业真题
Déterminer si un arbre binaire est un arbre binaire complet
Basic knowledge of database (interview)
Spécifications techniques et lignes directrices pour la sélection des tubes TVS et ESD - Recommandation de jialichuang
MySQL (2) -- simple query, conditional query
6-axis and 9-axis IMU attitude estimation
Registration and skills of hoisting machinery command examination in 2022
What is the process of building a website
Getting started stm32--gpio (running lantern) (nanny level)
Debian 10 installation configuration
Go language implementation principle -- lock implementation principle
Krypton Factor-紫书第七章暴力求解