phasm/README.md
Johan B.W. de Vries 2039d11e19 Some repo cleanup
2022-08-20 18:14:28 +02:00

70 lines
1.8 KiB
Markdown

phasm
=====
Elevator pitch
--------------
A programming language, that looks like Python, handles like Haskell,
and compiles directly to WebAssembly.
Name origin
-----------
- p from python
- ha from Haskell
- asm from WebAssembly
Example
-------
For more examples, see the examples directory.
```py
def helper(n: u64, a: u64, b: u64) -> u64:
if n < 1:
return a + b
return helper(n - 1, a + b, a)
@exported
def fib(n: u64) -> u64:
if n == 0:
return 0
if n == 1:
return 1
return helper(n - 1, 0, 1)
```
Gotcha's
--------
- When importing and exporting unsigned values to WebAssembly, they will become
signed, as WebAssembly has no native unsigned type. You may need to cast
or reinterpret them.
Contributing
------------
At this time, I'm mostly looking for use cases for WebAssembly, other than to
compile existing C code and running them in the browser. The goal of WebAssembly
is to enable high-performance applications on web pages[5]. Though most people
seem to use it to have existing code run in the browser.
If you have a situation where WebAssembly would be useful for it's speed, I'm
interested to see what you want to use it for.
Also, if you are trying out Phasm, and you're running into a limitation, I'm
interested in a minimal test case that shows what you want to achieve and how
Phasm currently fails you.
Additional required tools
-------------------------
At the moment, the compiler outputs WebAssembly text format. To actually
get a binary, you will need the wat2wasm tool[6].
.
References
----------
[1] https://www.python.org/
[2] https://www.haskell.org/
[3] https://webassembly.org/
[4] https://www.w3.org/TR/wasm-core-1/
[5] https://en.wikipedia.org/w/index.php?title=WebAssembly&oldid=1103639883
[6] https://github.com/WebAssembly/wabt