当前位置:网站首页>Go+ language
Go+ language
2022-07-24 22:06:00 【True · skysys】
Go+ The core positioning of , Integrated with engineering development Go、 In the field of data science Python、 In the field of programming teaching Scratch, therefore Go+ Yes Go The heart Python Type , Easier to use , Programming Oriented Education 、 Engineering development and data science .
2020 Static language born in , It's mainly Qi niuyun who is pushing .
GO+ vision Vision: compatible Go; compatible Scratch Design ability of ; compatible Python;
Go+ Playground: Online experience
Official website Tutorials: link~
Open source repo:gop
Language introduction















Go+ Source code , Through the scanner Scanner Turn into a Go+ Of Token, Through one more parser become Go+ Abstract syntax tree , That's what common languages do .Go+ The abstract syntax tree of has two branches after transformation , A generation Go So that it can Static compilation , Another branch generates Bytecode parsing execution , The polymorphism of branches is through the introduction of a called Perform specification (exec.spec) Things that are , In fact, it is an abstract interface .

Go+ Implement the part of the specification , It's actually an abstract SAX Interface , That is based on Event driven , An event is sent to the receiver , The receiving party handles this event according to its own needs , This is common in text processing .
Before Go+ The interface designed by the compiler basically uses event driven mode to connect different components . The compiler parses the abstract syntax tree and sends out some events , These events are received by two code generated modules , Work according to your own needs . This pattern code is still a bit hard to understand , In particular, some complicated things are done in the compiler , Make the code difficult to understand . Type derivation in Go It's complicated inside ,Go+ The complexity of compilers is also largely caused by Type derivation As a result of .
at present Go+ Improving implementation logic for implementing specifications , Make the implementation specification part no longer an abstract interface , It's a standard implementation DOM, This DOM It contains the ability of type derivation , So the compiler is relatively simple .

【 So so far , The script engine doesn't seem to be ready yet ?】
【 evaluation 】 Yes Go Ecosystem benefits , It is conducive to simplifying entry Go The difficulty of ecosystem ( That is, the first language is Go+).
【 view 】 In the absence of python If there is an era go+ Of course it's very good , There are already python Under the circumstances ,go+ How to highlight the advantages of ? in addition go+ Won't there be any loss in the performance of the scripting engine ? How about the performance of the final script execution ? This road is difficult to commercialize , Whether Qi niuyun can persist in this matter for a long time also needs to be considered . Looking forward to seeing the future Go+ There are more heavy projects in ecology , At present, it is still very preliminary .
【 view 2】go The design philosophy of language is preciseness , Even if the trouble , For example, you can't have unused variable,type Sure inference But there's no need to , need programmer explicit declaration, He doesn't want to learn py/js That kind of weak type,go+ Another compromise has been made on this , Follow py I feel more like .
Development experience
Win10 install Go+
Be careful : Need authority , Administrator mode on power shell
git clone https://github.com/goplus/gop.git
cd gop
all.bat

Remember to add environment variables , I am here D:\tmp\go\bin
gop run // function go+ Code
gop repl // stay repl/ Run in console mode go+
gop go [-test] // take go+ Package conversion go software package , If specified test, He will test relevant software packages
gop fmt // format go+ software package ( and go fmt be similar )
gop export // export go package
VSCode GO+ plug-in unit

hello,world
If not in GOPATH Under the new Go+ engineering , You need to use Go Model To handle dependencies , So here we will execute it under the project directory Go Model Initialization command of : here gop It's the name of the project , Be free to .
go mod init gop

main.gop
package main
func main() {
println("hello")
}

and Go The code of is very similar , however Go The output needs to use fmt package , stay Go+ There's no need to . Actually, here run Yes. go Code ,gop Yes gop The code is translated .
Go+ Grammatical features
multitype slice
stay Go In addition to interface Out of type , A slice can only store one type .Go+ Support for multiple .eg.
func main() {
a := [1, "abc", 2.3]
println(a)
}

List resolution expressions
func main() {
a := [1, 2.3, 45]
println([item*2 for item <- a])
}
Error handling
go+ The writing is similar to swift.
expr! // panic if err
expr? // return if err
expr?:defval // use defval if err
func ToInt(in string) int {
return strconv.Atoi(in)?:0
}
go The error handling of is troublesome
func ToInt(in string) int {
res, err := strconv.Atoi(in)
if err != nil {
return 0
} else {
return res
}
}
Here are some representative grammatical features , For more features, please refer to the official website doc perhaps Ref.4 Examples in . thank you .
Reference
边栏推荐
- Image processing notes (1) image enhancement
- RISC0:Towards a Unified Compilation Framework for Zero Knowledge
- SVM——针对线性可分(下)
- 陈春花与莫言,都有苦难言
- How much does it cost to build your own personal server
- Web3安全 Go+Security
- Kubernetes v1.24 is deployed based on containerd
- 在机器人行业的专业人士眼里,机器人行业目前的情况如何?
- Ue5 reports an error using the plug-in quixel Bridge
- How to output position synchronization of motion control
猜你喜欢

Gradle学习集合整合

String matching (Huawei)

运动控制卡应用开发教程之调用激光振镜控制
![[icml2022] climate change and machine learning: opportunities, challenges and considerations, 121 ppt](/img/be/6a3f53070c2ffc9610a77d4e910f91.png)
[icml2022] climate change and machine learning: opportunities, challenges and considerations, 121 ppt
![[e-commerce operation] teach you these tips to bid farewell to invalid preset replies](/img/5b/6682c613305deb3dc15401077d38a0.png)
[e-commerce operation] teach you these tips to bid farewell to invalid preset replies

一键编译安装redis6.2.4

RISC0:Towards a Unified Compilation Framework for Zero Knowledge

Kubernetes v1.24 is deployed based on containerd
![Cell special issue | application and future prediction of AI in protein structure, precision medicine, antibody therapy [review]](/img/2e/7f3cbae33c8a994b38e3bf4f9f13cb.png)
Cell special issue | application and future prediction of AI in protein structure, precision medicine, antibody therapy [review]

运动控制如何位置同步输出
随机推荐
What are the most problematic database accounts in DTS?
Huawei Router: basic principle and configuration of Isis (including experiment)
一键编译安装redis6.2.4
2022 Niuke multi school 7.23
Huawei cloud data governance production line dataarts, let "data 'wisdom' speak"
【Pyspark基础】行转列和列转行(超多列时)
Maixll dock QR code recognition
2022 Tsinghua summer school notes L2_ 2 basic introduction of CNN and RNN
How much does it cost to build your own personal server
Function default parameter pit avoidance Guide
Calling Laser Galvanometer control in the application and development tutorial of motion control card
Dialogue with celebrities: where are the opportunities and challenges in the second half when brands gather at the shuzang track?
运动控制如何位置同步输出
Ue5 reports an error using the plug-in quixel Bridge
day10:声明式事务控制
Kubernetes v1.24 is deployed based on containerd
Both Chen Chunhua and Mo Yan have words of suffering
Deep understanding of affairs
【二分好题】
[combination of classes (define a class in a class)]