为 WebAssembly 而设计
AssemblyScript 是专门针对 WebAssembly 的特性而设计的,让开发者能够对代码进行底层控制。
熟悉的 TypeScript 语法
它与 TypeScript 的相似性使得开发者无需学习新语言,即可轻松编译为 WebAssembly。
触手可及
与现有的 Web 生态系统集成 - 无需设置繁重的工具链。只需 npm install 即可!
#!runtime=stub
/** Calculates the n-th Fibonacci number. */
export function fib(n: i32): i32 {
var a = 0, b = 1
if (n > 0) {
while (--n) {
let t = a + b
a = b
b = t
}
return b
}
return a
}
#!html
<textarea id="output" style="height: 100%; width: 100%" readonly></textarea>
<script type="module">
const exports = await instantiate(await compile(), { /* imports */ })
const output = document.getElementById('output')
for (let i = 0; i <= 10; ++i) {
output.value += `fib(${i}) = ${exports.fib(i)}\n`
}
</script>
AssemblyScript 是一款基于 Apache License 2.0 协议发布的免费开源软件,它基于 Binaryen 构建,并实现了 WebAssembly 规范。它由以下优秀的贡献者们呈献:
为什么选择 AssemblyScript?
“You are now able to write WebAssembly without learning a new language, and harness all these benefits WebAssembly might offer you. I think that is kind of powerful. AssemblyScript is absolutely usable, and very enjoyable!” – Surma, WebAssembly for Web Developers (Google I/O ’19)
“AssemblyScript is designed with WebAssembly and code size in mind. It's not an existing language that we are using for a new purpose but it's a language designed for WebAssembly. It has great wasm-opt integration, in fact it's built with it, and it's very easy to get good code size.” – Alon Zakai, Shipping Tiny WebAssembly Builds (WebAssembly Summit)
“I chose AssemblyScript because it has high-level readability and low-level control. It's like a high-level language but you get that low-level feeling and you can even directly write WebAssembly intrinsics if you want to.” – Peter Salomonsen, WebAssembly Music (WebAssembly Summit)
感谢我们的赞助商!
Most of the maintainers and contributors do this open source work in their free time. If you use AssemblyScript for a serious task or plan to do so, and you'd like us to invest more time on it, please donate to our OpenCollective. By sponsoring this project, your logo will show up below. Thank you so much for your support!
加入 Discord
If you have questions only a human can answer, would like to show others what you are working on or just want to hang out with other AssemblyScript folks, make sure to join our Discord server! There you'll find channels for #announcements, #help, and more.