{"id":21223751,"url":"https://github.com/zmh-program/kylin-go","last_synced_at":"2025-07-10T14:30:48.540Z","repository":{"id":179398309,"uuid":"656671660","full_name":"zmh-program/kylin-go","owner":"zmh-program","description":"Kylin Go 是一款基于 Golang 的跨平台高效的编程语言，面相过程，动态脚本语言。Kylin Go is a cross-platform efficient programming language based on Golang (Go interpreter). Can be programmed in Chinese and other languages. Faceted process, direct translation programming language.","archived":true,"fork":false,"pushed_at":"2023-07-17T23:55:58.000Z","size":88,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T01:35:10.486Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zmh-program.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-21T12:02:18.000Z","updated_at":"2024-11-13T17:42:55.000Z","dependencies_parsed_at":"2023-07-19T09:03:03.161Z","dependency_job_id":null,"html_url":"https://github.com/zmh-program/kylin-go","commit_stats":null,"previous_names":["zmh-program/kylin-go"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zmh-program/kylin-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmh-program%2Fkylin-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmh-program%2Fkylin-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmh-program%2Fkylin-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmh-program%2Fkylin-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zmh-program","download_url":"https://codeload.github.com/zmh-program/kylin-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmh-program%2Fkylin-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264590772,"owners_count":23633638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T22:53:18.764Z","updated_at":"2025-07-10T14:30:48.536Z","avatar_url":"https://github.com/zmh-program.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# ⚡  kylin-go\nKylin Go,  一款基于 Golang 的跨平台简洁高效轻量的编程语言\n\n![Last Commit](https://img.shields.io/github/last-commit/zmh-program/kylin-go)\n![Status](https://img.shields.io/github/actions/workflow/status/zmh-program/kylin-go/build.yaml?branch=main)\n![Dependence](https://img.shields.io/badge/dependencies-0-blue)\n![License](https://img.shields.io/github/license/zmh-program/kylin-go)\n\n[» Kylin Jvm »](https://github.com/Linwin-Cloud/Kylin-Language)\n\n\u003c/div\u003e\n\n## 语言特性\n- ✨ 语法简单，易学易用\n- ⚡ 语法高效，编译速度快\n- 📦 内存占用小\n- 🎃 跨平台编译\n- 🎈 国际化支持 （英，中文）\n\n## [发行版](https://github.com/zmh-program/kylin-go/releases)\n- [x] Windows\n- [x] Linux Ubuntu\n- [x] MacOS\n\n## 语言示例\n\n```kylin\nfn main() {\n    print(\"Hello, World!\")\n}\n\nmain()\n```\n\n## 国际化\n```kylin\nuse 'chinese'\n\n遍历 变量 在 范围(2) {\n    输出(变量, \"hi\")\n     尝试 {\n        输出(变量位置, \"hi\")\n    } 捕获 {\n        输出(\"报错：\", error)\n    }\n}\n\n```\n\n\u003e ```shell\n\u003e 0 hi\n\u003e 报错： ReferenceError(type=\"ReferenceError\", message=\"Variable 变量位置 not defined\", line=7, column=15)\n\u003e 1 hi\n\u003e 报错： ReferenceError(type=\"ReferenceError\", message=\"Variable 变量位置 not defined\", line=7, column=15)\n\u003e 2 hi\n\u003e 报错： ReferenceError(type=\"ReferenceError\", message=\"Variable 变量位置 not defined\", line=7, column=15)\n\u003e ```\n\n## 语言规范\n#### 1. 赋值计算\n```kylin\na = 1024\na += 2\na -= 4\na *= 8\na **= 12\na /= 16\n\nb = a + 1\n```\n\n#### 2. 函数\n```kylin\nfn add(a, b) {\n    return a + b\n}\n\nfn main() {\n    print(\"Hello, World!\")\n    return add(1, 2)\n}\n```\n\n#### 3. 条件判断\n```kylin\nif val \u003e 10 {\n    print(\"val \u003e 10\")\n} elif val \u003c 10 {\n    print(\"val \u003c 10\")\n} else {\n    print(\"val = 10\")\n}\n\nif condition {\n    print(\"condition\")\n}\n\nif n + 1 != 0 \u0026\u0026 n {\n    print(\"n \u0026 (n + 1) != 0\")\n}\n```\n\n#### 4. 循环\n```kylin\nfor i in range(0, 10) {\n    print(i)\n}\n```\n```kylin\nn = 0\nwhile n \u003c 10 {\n    print(n)\n    n += 1\n}\n```\n\n#### 5. 数组\n```kylin\narr = [1, 2, 3, 4, 5]\n\nfor i in arr {\n  ...\n}\n\nfor i in [\"hello\", \"world\"] {\n  print(i)\n}\n```\n\n#### 6. 异常截获\n```\nfor i in range(1,10,2) {\n    try {\n        print(id)\n    } catch {\n        print(\"a\", error, \"b\")\n    }\n}\n```\n\u003e ```shell\n\u003e $ kylin test.ky\n\u003e a ReferenceError(message=\"Variable id not defined\", type=\"ReferenceError\",\n\u003e  line=3, column=22) b\n\u003e a ReferenceError(message=\"Variable id not defined\", type=\"ReferenceError\",\n\u003e  line=3, column=22) b\n\u003e a ReferenceError(message=\"Variable id not defined\", type=\"ReferenceError\",\n\u003e  line=3, column=22) b\n\u003e a ReferenceError(message=\"Variable id not defined\", type=\"ReferenceError\",\n\u003e  line=3, column=22) b\n\u003e a ReferenceError(message=\"Variable id not defined\", type=\"ReferenceError\",\n\u003e  line=3, column=22) b\n\u003e a ReferenceError(message=\"Variable id not defined\", type=\"ReferenceError\",\n\u003e  line=3, column=22) b\n\u003e ```\n\n## 运行\n```shell\nkylin main.ky\n```\n\u003e .ky 后缀可省略\n\u003e ```shell\n\u003e kylin server\n\u003e ```\n\n\n## 关键字\n- `fn` 函数\n- `if` 条件判断\n- `else` 条件判断\n- `for` 循环\n- `in` 循环\n- `while` 循环\n- `return` 返回\n- `true` 真\n- `false` 假\n- `null` 空\n- `try` 异常截获\n- `catch` 异常截获\n- `break` 跳出循环\n- `continue` 跳过本次循环\n- `import` 导入\n- `use` 国际化导入语言包\n\n## 内置函数\n- `print` 打印\n- `input` 输入\n- `str` 字符串\n- `int` 整数\n- `float` 浮点数\n- `bool` 布尔值\n- `array` 数组\n- `range` 范围\n- `len` 长度\n- `sum` 求和\n- `max` 最大值\n- `min` 最小值\n- `abs` 绝对值\n- `all` 全部为真\n- `any` 任意为真\n- `join` 连接字符串\n- `split` 分割字符串\n- `type` 类型\n- `time` 时间 (ms)\n- `sleep` 阻塞等待 (ms)\n- `timenano` CPU 时间 (ns)\n- `read` 读取文件\n- `write` 写入文件\n- `shell` 执行 shell 命令\n- `exit` 退出程序\n\n## 语言设计\n#### 1. 词法分析\n- Lexer 编译 AST 语法树\n- 词法分析器使用递归下降进行语法分析\n\n#### 2. 语言解释\n- 动态解释器\n\n#### 3. 语言编译\n- 编译器使用 Golang SSA 进行编译\n\n\n## 基准测试\n\n#### 性能测试\n```kylin\nn = 0\nval = 2345\nt = time()\nwhile n \u003c 9999999 {\n    n += 1\n    val **= 1289\n    val = n * 999\n}\n\nprint(time() - t, \"ms\")\n```\n1. C (GCC) `891.9ms`\n2. Golang `1012.5ms`\n3. NodeJS `1170.0ms`\n4. **Kylin Go** `1751.2ms`\n5. Python `4681.8ms`\n\n#### 内存占用 （整体）\n```kylin\nn = 0\nwhile n \u003c 1000000 {\n    n += 1\n    print('hello world')\n}\n```\n1. C (GCC) `0.9 MB`\n2. Golang `3.2 MB`\n3. **Kylin Go** `8 MB`\n4. Node `10 MB`\n5. Python `14MB`\n6. Kylin JVM `84MB`\n\n#### 内存溢出测试\n1. C ❌\n2. Golang ❌\n3. **Kylin Go** ❌\n4. NodeJS ❌\n5. Python ❌\n6. Kylin JVM ✔\n\n#### 风格对比\nC 语言\n```c\n#include \u003cstdio.h\u003e\n\nint main() {\n    int n = 0;\n    \n    while (n \u003c 1000000) {\n        n++;\n        printf(\"hello world\\n\");\n    }\n    \n    return 0;\n}\n```\nGolang \n```go\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tn := 0\n\tfor n \u003c 1000000 {\n\t\tn++\n\t\tfmt.Println(\"hello world\")\n\t}\n}\n```\n**Kylin Go**\n```kylin\nn = 0\nwhile n \u003c 1000000 {\n    n += 1\n    print('hello world')\n}\n```\n**Kylin JVM**\n```kylin\nvar n = 0\nwhile n \u003c 1000000 {\n    n = \u003cn + 1\u003e\n    out('hello world')\n}\n```\nNodeJS\n```js\nlet n = 0;\nwhile (n \u003c 1000000) {\n    n++;\n    console.log('hello world');\n}\n```\nPython\n```python\nn = 0\nwhile n \u003c 1000000:\n    n += 1\n    print('hello world')\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmh-program%2Fkylin-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzmh-program%2Fkylin-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmh-program%2Fkylin-go/lists"}