README.md 5.1 KB
Newer Older
chai2010's avatar
chai2010 已提交
1 2 3
<div align="center">
<h1>🇨🇳 凹语言™ The Wa Programming Language</h1>

chai2010's avatar
chai2010 已提交
4
[主页](https://wa-lang.org) | [Playground](https://wa-lang.org/playground) | [目标](https://wa-lang.org/goals.html) | [路线](https://wa-lang.org/smalltalk/st0002.html) | [社区](https://wa-lang.org/community) | [日志](https://wa-lang.org/changelog.html) | [论坛](https://github.com/wa-lang/wa/discussions)
chai2010's avatar
chai2010 已提交
5

chai2010's avatar
chai2010 已提交
6 7 8
[Document](https://wa-lang.org) | [Playground](https://wa-lang.org/playground) | [Goals](https://wa-lang.org/goals.html) | [Roadmap](https://wa-lang.org/smalltalk/st0002.html) | [Community](https://wa-lang.org/community) | [Changelog](https://wa-lang.org/changelog.html) | [Discussions](https://github.com/wa-lang/wa/discussions)


chai2010's avatar
chai2010 已提交
9 10
</div>
<div align="center">
3
3dgen 已提交
11

chai2010's avatar
chai2010 已提交
12 13
[![Build Status](https://github.com/wa-lang/wa/actions/workflows/wa.yml/badge.svg)](https://github.com/wa-lang/wa/actions/workflows/wa.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/wa-lang/wa)](https://goreportcard.com/report/github.com/wa-lang/wa)
chai2010's avatar
chai2010 已提交
14
[![Coverage Status](https://coveralls.io/repos/github/wa-lang/wa/badge.svg)](https://coveralls.io/github/wa-lang/wa)
chai2010's avatar
chai2010 已提交
15
[![GitHub release](https://img.shields.io/github/v/tag/wa-lang/wa.svg?label=release)](https://github.com/wa-lang/wa/releases)
chai2010's avatar
chai2010 已提交
16
[![Go Reference](https://pkg.go.dev/badge/github.com/wa-lang/wa.svg)](https://pkg.go.dev/github.com/wa-lang/wa)
chai2010's avatar
chai2010 已提交
17
[![license](https://img.shields.io/github/license/wa-lang/wa.svg)](https://github.com/wa-lang/wa/blob/master/LICENSE)
chai2010's avatar
chai2010 已提交
18

chai2010's avatar
chai2010 已提交
19 20
</div>

chai2010's avatar
chai2010 已提交
21
凹语言™(凹读音“Wa”)是 针对 WASM 平台设计的通用编程语言,同时支持 Linux、macOS 和 Windows 等主流操作系统和 Chrome 等浏览器环境,同时也支持作为独立Shell脚本和被嵌入脚本模式执行。
chai2010's avatar
chai2010 已提交
22 23 24

Wa is a general-purpose programming language designed for developing robustness and maintainability WebAssembly software.
Instead of requiring complex toolchains to set up, you can simply go install it - or run it in a browser.
chai2010's avatar
chai2010 已提交
25

chai2010's avatar
chai2010 已提交
26 27
![](docs/images/logo/logo-animate1-blue.svg)

chai2010's avatar
chai2010 已提交
28
- 主页 (Homepage): [https://wa-lang.org](https://wa-lang.org)
chai2010's avatar
chai2010 已提交
29 30
- 代码仓库 (Github): [https://github.com/wa-lang/wa](https://github.com/wa-lang/wa)
- 代码仓库 (Gitee):  [https://gitee.com/wa-lang/wa](https://gitee.com/wa-lang/wa)
chai2010's avatar
chai2010 已提交
31
- Go 参考文档: [https://pkg.go.dev/github.com/wa-lang/wa](https://pkg.go.dev/github.com/wa-lang/wa)
chai2010's avatar
chai2010 已提交
32
- 开发工具 (Develop Tools): [Playground](https://wa-lang.org/playground), [VSCode 插件](https://marketplace.visualstudio.com/items?itemName=xxxDeveloper.vscode-wa), [Fleet 插件](https://github.com/wa-lang/fleet-wa), [Vim 插件](https://github.com/wa-lang/vim-wa)
chai2010's avatar
chai2010 已提交
33
- 开发组 (Core Team): [柴树杉(chai2010)](https://github.com/chai2010)[丁尔男(Ending)](https://github.com/3dgen)[史斌(Benshi)](https://github.com/benshi001)[扈梦明(xxxDeveloper)](https://github.com/xxxDeveloper)[刘云峰(leaftree)](https://github.com/leaftree)[宋汝阳(ShiinaOrez)](https://github.com/ShiinaOrez)
34

chai2010's avatar
chai2010 已提交
35 36 37 38 39 40 41 42
## Playground 在线预览

[https://wa-lang.org/playground](https://wa-lang.org/playground)

![[![](https://wa-lang.org/smalltalk/images/st0011-01.png)](https://wa-lang.org/playground)](https://wa-lang.org/static/images/playground.gif)


## 本地安装和测试 (Install and Run):
chai2010's avatar
chai2010 已提交
43

44 45 46
1. `go install github.com/wa-lang/wa@latest`
2. `wa init -name=_examples/hi`
3. `wa run _examples/hi`
chai2010's avatar
chai2010 已提交
47

chai2010's avatar
chai2010 已提交
48
> 项目尚处于原型开源阶段,如果有共建和PR需求请参考 [如何贡献代码](https://wa-lang.org/community/contribute.html)。
chai2010's avatar
chai2010 已提交
49

chai2010's avatar
chai2010 已提交
50
> The Wa project is still in very early stage. If you want to submit PR, please read the [Contribution Guide(Chinese)](https://wa-lang.org/community/contribute.html).
chai2010's avatar
chai2010 已提交
51

chai2010's avatar
chai2010 已提交
52
## 例子: 凹语言 (Example: Print 凹语言)
3
3dgen 已提交
53

chai2010's avatar
chai2010 已提交
54
打印字符和调用函数(Print rune and call function):
chai2010's avatar
chai2010 已提交
55 56

```
57
fn main {
chai2010's avatar
chai2010 已提交
58
	println("你好,凹语言!")
chai2010's avatar
chai2010 已提交
59 60 61 62 63 64 65 66
	println(add(40, 2))
}

fn add(a: i32, b: i32) => i32 {
	return a+b
}
```

chai2010's avatar
chai2010 已提交
67
运行并输出结果 (Execute the program):
chai2010's avatar
chai2010 已提交
68 69 70

```
$ go run main.go hello.wa 
chai2010's avatar
chai2010 已提交
71
你好,凹语言!
chai2010's avatar
chai2010 已提交
72 73 74
42
```

chai2010's avatar
chai2010 已提交
75
## 例子: 打印素数 (Example: Print Prime)
3
zz  
3dgen 已提交
76

chai2010's avatar
chai2010 已提交
77
打印 30 以内的素数 (Print prime numbers up to 30):
3
3dgen 已提交
78 79

```
chai2010's avatar
chai2010 已提交
80
# 版权 @2021 凹语言™ 作者。保留所有权利。
3
3dgen 已提交
81

82
fn main {
3
3dgen 已提交
83
	for n := 2; n <= 30; n = n + 1 {
84
		var isPrime int = 1
3
3dgen 已提交
85 86 87 88 89 90 91 92 93 94 95 96
		for i := 2; i*i <= n; i = i + 1 {
			if x := n % i; x == 0 {
				isPrime = 0
			}
		}
		if isPrime != 0 {
			println(n)
		}
	}
}
```

chai2010's avatar
chai2010 已提交
97
运行并输出结果 (Execute the program):
chai2010's avatar
chai2010 已提交
98 99

```
chai2010's avatar
chai2010 已提交
100
$ go run main.go run _examples/prime
chai2010's avatar
chai2010 已提交
101 102 103 104 105 106 107 108 109 110 111 112
2
3
5
7
11
13
17
19
23
29
```

chai2010's avatar
chai2010 已提交
113
更多例子 (More examples) [_examples](_examples)
3
3dgen 已提交
114

chai2010's avatar
chai2010 已提交
115
## 作为脚本执行 (Execut as a script)
chai2010's avatar
chai2010 已提交
116

chai2010's avatar
chai2010 已提交
117
凹语言本身也可以像 Lua 语言被嵌入 Go 宿主语言环境执行 (The Wa language itself can also be executed like the Lua language embedded in the Go host locale):
chai2010's avatar
chai2010 已提交
118

chai2010's avatar
chai2010 已提交
119
```
chai2010's avatar
chai2010 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132
package main

import (
	"fmt"
	"github.com/wa-lang/wa/api"
)

func main() {
	output, err := api.RunCode("hello.wa", "fn main() { println(40+2) }")
	fmt.Print(string(output), err)
}
```

chai2010's avatar
chai2010 已提交
133
注:作为脚本执行目前只支持本地环境。(Note: Executing as a script currently only supports native environments.)
3
3dgen 已提交
134

chai2010's avatar
chai2010 已提交
135
## 版权(License)
3
zz  
3dgen 已提交
136

chai2010's avatar
chai2010 已提交
137
版权 @2019-2022 凹语言™ 作者。保留所有权利。(Copyrighe @2019-2022 The Wa author. All rights reserved.)