a web assembly programming language
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!
extern console_log(message)
pub fn main(){
console_log("Hello World!")
}
Wasp depends on git and rust. Make sure you have them installed before beginning.
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.
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
Wasp is an extremely basic language and standard library.
cons(42,nil) // returns the memory location of cons
head(cons(42,nil)) // return the head value 42
tail(cons(42,nil)) // returns the memory location of tail
cons(1,cons(2,cons(3,nil))) // returns a linked list
Structs are dictionaries
struct point { :x :y }
pub fn create_point(){
foo = malloc(size_of(point))
set(foo,:x,1)
set(foo,:y,1)
foo
}
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.
No open issues yet, or sync has not completed.