onyxlang 简单试用

以前简单说过onyxlang 是一个基于webassembly 的新编程语言,以下是一个简单试用

安装

sh <(curl https://get.onyxlang.io -sSfL)

效果

注意安装完成之后需要配置环境变量(有提示)
包含的cli

 
Onyx toolchain version v0.1.8
Built on Wed Nov 29 01:49:11 2023
Runtime: wasmer
 
The toolchain for the Onyx programming language, created by Brendan Hansen.
 
Usage:
    onyx <subcommand>
 
Subcommands:
    help      Shows this help message. Use "onyx help <subcommand>".
    build     Compiles an Onyx program into an executable.
    run       Compiles and runs an Onyx program, all at once.
    check     Checks syntax and types of an Onyx program.
    package   Package manager
    version   Prints version information

使用

  • vs code 编辑器支持

以前也简单说过onyxlang包含了包管理,编辑器支持,比如我使用vs code 的

  • 简单代码
    app.onyx
 
use core { printf }
 
main :: () {
    // Inferred variable type
    x := 10;
 
    // Function with entirely inferred types.
    change_value :: x => x + 10;
 
    // Onyx figures out the types of `change_value` when you call it.
    printf("The value is {}.\n", change_value(x));
}
  • 构建
onyx build -V -r wasi -DWASIX -o site.wasm  app.onyx

  • 运行
    可以直接使用onyx 或者使用,wasmer runtime
    onyx 模式
 
onyx run app.onyx

wasmer runtime

 
wasmer site.wasm

说明

以上是一个简单的试用,实际上onyx 目前来看还是很强大的,而且支持c-ffi 进行c 库调用

参考资料

https://onyxlang.io/
https://github.com/onyx-lang/onyx
https://wasmer.io/
https://docs.onyxlang.io/book/Overview.html
https://github.com/wasmerio/wasmer

posted on   荣锋亮  阅读(6)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2023-01-09 dremio cloud 参考架构
2022-01-09 使用juicefs 做为dremio 的分布式存储
2021-01-09 graphjin 试用
2020-01-09 nodejs fork 子进程创建任务以及简单的prometheus 监控
2019-01-09 Singer 学习十三 发现模式
2019-01-09 Singer 学习十二 指南
2019-01-09 Singer 学习十一 配置以及状态管理

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示