github.com/goplus/gop@v1.2.6/README.md (about) 1 <div align="center"> 2 <p></p> 3 <p> 4 <img width="80" src="https://goplus.org/favicon.svg"> 5 </p> 6 <h1>The Go+ Programming Language</h1> 7 8 [goplus.org](https://goplus.org) | [Docs](doc/docs.md) | [Go+ vs. Go](doc/goplus-vs-go.md) | [Tutorials](https://tutorial.goplus.org/) | [Playground](https://play.goplus.org) | [iGo+ Playground](https://repl.goplus.org/) | [Contributing & compiler design](doc/contributing.md) 9 10 </div> 11 12 <div align="center"> 13 <!-- 14 [![VSCode](https://img.shields.io/badge/vscode-Go+-teal.svg)](https://github.com/gopcode/vscode-goplus) 15 [![Discord](https://img.shields.io/discord/983646982100897802?label=Discord&logo=discord&logoColor=white)](https://discord.gg/mYjWCJDcAr) 16 [![Interpreter](https://img.shields.io/badge/interpreter-iGo+-seagreen.svg)](https://github.com/goplus/igop) 17 --> 18 19 [![Build Status](https://github.com/goplus/gop/actions/workflows/go.yml/badge.svg)](https://github.com/goplus/gop/actions/workflows/go.yml) 20 [![Go Report Card](https://goreportcard.com/badge/github.com/goplus/gop)](https://goreportcard.com/report/github.com/goplus/gop) 21 [![Coverage Status](https://codecov.io/gh/goplus/gop/branch/main/graph/badge.svg)](https://codecov.io/gh/goplus/gop) 22 [![GitHub release](https://img.shields.io/github/v/tag/goplus/gop.svg?label=release)](https://github.com/goplus/gop/releases) 23 [![Discord](https://img.shields.io/badge/Discord-online-success.svg?logo=discord&logoColor=white)](https://discord.com/invite/mYjWCJDcAr) 24 25 </div> 26 27 Our vision is to **enable everyone to create production-level applications**. 28 29 #### Easy to learn 30 31 * Simple and easy to understand 32 * Smaller syntax set than Python in best practices 33 34 #### Ready for large projects 35 36 * Derived from Go and easy to build large projects from its good engineering foundation 37 38 The Go+ programming language is designed for engineering, STEM education, and data science. 39 40 * **For engineering**: working in the simplest language that can be mastered by children. 41 * **For STEM education**: studying an engineering language that can be used for work in the future. 42 * **For data science**: communicating with engineers in the same language. 43 44 For more details, see [Quick Start](doc/docs.md). 45 46 47 ## Command Style Code 48 49 Different from the function call style of most languages, Go+ recommends command style code: 50 51 ```coffee 52 println "Hello world" 53 ``` 54 55 To emphasize our preference for command style, we introduce `echo` as an alias for `println`: 56 57 ```coffee 58 echo "Hello world" 59 ``` 60 61 For more discussion on coding style, see https://tutorial.goplus.org/hello-world. 62 63 64 ## Go+ Classfiles 65 66 ``` 67 One language can change the whole world. 68 Go+ is a "DSL" for all domains. 69 ``` 70 71 Rob Pike once said that if he could only introduce one feature to Go, he would choose `interface` instead of `goroutine`. `classfile` is as important to Go+ as `interface` is to Go. 72 73 In the design philosophy of Go+, we do not recommend `DSL` (Domain Specific Language). But `SDF` (Specific Domain Friendliness) is very important. The Go+ philosophy about `SDF` is: 74 75 ``` 76 Don't define a language for specific domain. 77 Abstract domain knowledge for it. 78 ``` 79 80 Go+ introduces `classfile` to abstract domain knowledge. 81 82 * [What's Classfile?](doc/classfile.md#whats-classfile) 83 * [Dive into Go+ Classfiles](doc/classfile.md) 84 85 Sound a bit abstract? Let's see some Go+ classfiles. 86 87 * Unit Test: [classfile: Unit Test](https://github.com/goplus/gop/blob/main/doc/classfile.md#classfile-unit-test) 88 * DevOps: [gsh: Go+ DevOps Tools](https://github.com/qiniu/x/tree/main/gsh) 89 * Web Programming: [yap: Yet Another HTTP Web Framework](https://github.com/goplus/yap) 90 * Web Programming: [yaptest: HTTP Test Framework](https://github.com/goplus/yap/tree/main/ytest) 91 * Web Programming: [ydb: Database Framework](https://github.com/goplus/yap/tree/main/ydb) 92 * STEM Education: [spx: A Go+ 2D Game Engine](https://github.com/goplus/spx) 93 94 95 ### yap: Yet Another HTTP Web Framework 96 97 This classfile has the file suffix `.yap`. 98 99 Create a file named [get.yap](https://github.com/goplus/yap/blob/main/demo/classfile2_hello/get.yap) with the following content: 100 101 ```go 102 html `<html><body>Hello, YAP!</body></html>` 103 ``` 104 105 Execute the following commands: 106 107 ```sh 108 gop mod init hello 109 gop get github.com/goplus/yap@latest 110 gop mod tidy 111 gop run . 112 ``` 113 114 A simplest web program is running now. At this time, if you visit http://localhost:8080, you will get: 115 116 ``` 117 Hello, YAP! 118 ``` 119 120 YAP uses filenames to define routes. `get.yap`'s route is `get "/"` (GET homepage), and `get_p_#id.yap`'s route is `get "/p/:id"` (In fact, the filename can also be `get_p_:id.yap`, but it is not recommended because `:` is not allowed to exist in filenames under Windows). 121 122 Let's create a file named [get_p_#id.yap](https://github.com/goplus/yap/blob/main/demo/classfile2_hello/get_p_%23id.yap) with the following content: 123 124 ```coffee 125 json { 126 "id": ${id}, 127 } 128 ``` 129 130 Execute `gop run .` and visit http://localhost:8080/p/123, you will get: 131 132 ``` 133 {"id": "123"} 134 ``` 135 136 See [yap: Yet Another HTTP Web Framework](https://github.com/goplus/yap) for more details. 137 138 139 ### spx: A Go+ 2D Game Engine 140 141 ![Screen Shot1](https://github.com/goplus/spx/blob/main/tutorial/01-Weather/1.jpg) ![Screen Shot2](https://github.com/goplus/spx/blob/main/tutorial/01-Weather/2.jpg) 142 143 Through this example you can learn how to implement dialogues between multiple actors. 144 145 Here are some codes in [Kai.spx](https://github.com/goplus/spx/blob/main/tutorial/01-Weather/Kai.spx): 146 147 ```coffee 148 onStart => { 149 say "Where do you come from?", 2 150 broadcast "1" 151 } 152 153 onMsg "2", => { 154 say "What's the climate like in your country?", 3 155 broadcast "3" 156 } 157 ``` 158 159 We call `onStart` and `onMsg` to listen events. `onStart` is called when the program is started. And `onMsg` is called when someone calls `broadcast` to broadcast a message. 160 161 When the program starts, Kai says `Where do you come from?`, and then broadcasts the message `1`. Who will recieve this message? Let's see codes in [Jaime.spx](https://github.com/goplus/spx/blob/main/tutorial/01-Weather/Jaime.spx): 162 163 ```coffee 164 onMsg "1", => { 165 say "I come from England.", 2 166 broadcast "2" 167 } 168 ``` 169 170 Yes, Jaime recieves the message `1` and says `I come from England.`. Then he broadcasts the message `2`. Kai recieves it and says `What's the climate like in your country?`. 171 172 The following procedures are very similar. In this way you can implement dialogues between multiple actors. 173 174 See [spx: A Go+ 2D Game Engine](https://github.com/goplus/spx) for more details. 175 176 177 ### gsh: Go+ DevOps Tools 178 179 Yes, now you can write `shell script` in Go+. It supports all shell commands. 180 181 Let's create a file named [example.gsh](https://github.com/qiniu/x/blob/main/gsh/demo/hello/example.gsh) and write the following code: 182 183 ```coffee 184 mkdir "testgsh" 185 ``` 186 187 Don't need a `go.mod` file, just enter `gop run ./example.gsh` directly to run. 188 189 See [gsh: Go+ DevOps Tools](https://github.com/qiniu/x/tree/main/gsh) for more details. 190 191 192 ## Key Features of Go+ 193 194 * A static typed language. 195 * The simplest engineering language that can be mastered by children (script-like style). 196 * Performance: as fast as Go (Go+'s main backend compiles to human-readable Go). 197 * Fully compatible with [Go](https://github.com/golang/go) and can mix Go/Go+ code in the same package (see [Go/Go+ hybrid programming](doc/docs.md#gogo-hybrid-programming)). 198 * No DSL (Domain Specific Language) support, but SDF ([Specific Domain Friendliness](doc/classfile.md)). 199 * Support Go code generation (main backend) and [bytecode backend](https://github.com/goplus/igop) (REPL: see [iGo+](https://repl.goplus.org/)). 200 * [Simplest way to interaction with C](doc/docs.md#calling-c-from-go) (cgo is supported but not recommended). 201 * [Powerful built-in data processing capabilities](doc/docs.md#data-processing). 202 203 204 ## How to install 205 206 ### on Windows 207 208 ```sh 209 winget install goplus.gop 210 ``` 211 212 ### on Debian/Ubuntu 213 214 ```sh 215 sudo bash -c ' echo "deb [trusted=yes] https://pkgs.goplus.org/apt/ /" > /etc/apt/sources.list.d/goplus.list' 216 sudo apt update 217 sudo apt install gop 218 ``` 219 220 ### on RedHat/CentOS/Fedora 221 222 ```sh 223 sudo bash -c 'echo -e "[goplus]\nname=Go+ Repo\nbaseurl=https://pkgs.goplus.org/yum/\nenabled=1\ngpgcheck=0" > /etc/yum.repos.d/goplus.repo' 224 sudo yum install gop 225 ``` 226 227 ### on macOS/Linux (Homebrew) 228 229 Install via [brew](https://brew.sh/) 230 231 ```sh 232 $ brew install goplus 233 ``` 234 235 ### from source code 236 237 Note: Requires go1.18 or later 238 239 ```bash 240 git clone https://github.com/goplus/gop.git 241 cd gop 242 243 # On mac/linux run: 244 ./all.bash 245 # On Windows run: 246 all.bat 247 ``` 248 249 ## Go+ Applications 250 251 ### 2D Games powered by Go+ 252 253 * [A Go+ 2D Game Engine for STEM education](https://github.com/goplus/spx) 254 * [Aircraft War](https://github.com/goplus/AircraftWar) 255 * [Flappy Bird](https://github.com/goplus/FlappyCalf) 256 * [Maze Play](https://github.com/goplus/MazePlay) 257 * [BetaGo](https://github.com/xushiwei/BetaGo) 258 * [Gobang](https://github.com/xushiwei/Gobang) 259 * [Dinosaur](https://github.com/xushiwei/Dinosaur) 260 261 ### Web Programming 262 263 * [yap: Yet Another HTTP Web Framework](https://github.com/goplus/yap) 264 * [yaptest: HTTP Test Framework](https://github.com/goplus/yap/tree/main/ytest) 265 * [ydb: Database Framework](https://github.com/goplus/yap#ydb-database-framework) 266 267 ### DevOps Tools 268 269 * [gsh: Go+ DevOps Tools](https://github.com/qiniu/x/tree/main/gsh) 270 271 ### Data Processing 272 273 * [hdq: HTML DOM Query Language for Go+](https://github.com/goplus/hdq) 274 275 276 ## IDE Plugins 277 278 * vscode: [Go/Go+ for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=goplus.gop) 279 280 281 ## Contributing 282 283 The Go+ project welcomes all contributors. We appreciate your help! 284 285 For more details, see [Contributing & compiler design](doc/contributing.md). 286 287 288 ## Give a Star! ⭐ 289 290 If you like or are using Go+ to learn or start your projects, please give it a star. Thanks!