百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

wasp

> 编程语言
开源

Web 组件编程语言

324 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Web 组件编程语言

Wasp

a programming language for extremely concise web assembly modules

warning: this compiler is very alpha and error messages aren't the best, but it works and language is simple!

rust
extern console_log(message)

pub fn main(){
  console_log("Hello World!")
}

Features

  • encourages immutability
  • immutable c-strings, memory manipulation, global variables, imported functions, 1st class functions
  • optional standard library runtime
  • functions with inline web assembly
  • test framework support
  • easy project dependency management
  • self hosting

Quickstart

Wasp depends on git and rust. Make sure you have them installed before beginning.

bash
cargo install wasp
wasp init myproject
cd myproject
wasp build
python3 -m http.server

Open up http://localhost:8000 and look in console. At this point we will have a web assembly module that has access to the standard libraries functions. More to come in this area!

If you don't have need for the standard library (or want to write your own!). This is also an option.

bash
wasp init myproject --no-std

At this point we will have a web assembly module with a single exported main function and nothing else.

If you think your standard library is out of date, just run wasp vendor

Simple Data Structures

Wasp is an extremely basic language and standard library.

Linked List

rust
cons(42,nil) // returns the memory location of cons
rust
head(cons(42,nil)) // return the head value 42
rust
tail(cons(42,nil)) // returns the memory location of tail
rust
cons(1,cons(2,cons(3,nil))) // returns a linked list

Structs

Structs are dictionaries

rust
struct point { :x :y }

pub fn create_point(){
  foo = malloc(size_of(point))
  set(foo,:x,1)
  set(foo,:y,1)
  foo
}

Drawing

Using web-dom we can easily draw something to screen. Loops in wasp work differently than other languages, observe how this example uses recursion to rebind variables.

…

rust pub test_addition(){ assert(4,(2+2),"2 + 2 should be 4") assert(7,(3+4),"3 + 4 should be 7") }

See it working [here](https://wasplang.github.io/wasp/examples/testing/index.html)

## Why so few functions?
Wasp prefers to keep as little in the core functionality as possible, letting the [standard library](https://github.com/wasplang/std) evolve faster and more independent community driven manner. This project currently follows a principle that if a feature can be implemented with our primitive functions, don't include it in the core compiled language and let the standard library implement it. Also that no heap based concepts be added to the core language.

## Notes

* all functions (including extern functions) return a value, if no obvious return, it returns ()
* Web assembly global 0 is initialized to the end of the static data section (which might also be the start of a heap for a memory allocator). This value is immutable.
* Web assembly global lobal 1 also is initialized to the end of the static data section. This value is mutable and might be used to represent the end of your heap. Check out the [simple allocator example](https://github.com/richardanaya/wasp/blob/master/examples/malloc/main.w).
* Literal strings create initialize data of a c-string at the front of your memory, and can be passed around as pointers to the very start in memory to your text. A \0 is automatically added at compile time, letting you easily have a marker to denote the end of your text.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言