The code and data behind xeiaso.net
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

pa'i: hello world (#121)

* deps.nix: bump

* blog: add post on pa'i

* blog/pahi: oops

* blog/pahi: rafsi

* blog/pahi: phrasing

* blog/pahi: explain speed

authored by

Christine Dodrill and committed by
GitHub
6adc88b1 29aa9a3a

+172 -2
+1
.gitignore
··· 4 4 .DS_Store 5 5 /result-* 6 6 /result 7 + .#*
+169
blog/pahi-hello-world-2020-02-22.markdown
··· 1 + --- 2 + title: "pa'i: hello world!" 3 + date: 2020-02-22 4 + series: olin 5 + tags: 6 + - rust 7 + - wasm 8 + - dhall 9 + --- 10 + 11 + # pa'i: hello world! 12 + 13 + It's been a while since I gave an update on the Olin ecosystem (which now 14 + exists, apparently). Not much has really gone on with it for the last few 15 + months. However, recently I've decided to tackle one of the core problems of 16 + Olin's implementation in Go: execution speed. 17 + 18 + Originally I was going to try and handle this with 19 + ["hyperjit"](https://innative.dev), but support for linking C++ programs into Go 20 + is always questionable at best. All of the WebAssembly compiling and 21 + running tooling has been written in Rust, and as far as I know I was the only 22 + holdout still using Go. This left me kinda stranded and on my own, seeing as the 23 + libraries that I was using were starting to die. 24 + 25 + I have been following the [wasmer][wasmer] project for a while and thanks to 26 + their recent [custom ABI sample][wasmercustomabisample], I was able to start 27 + re-implementing the Olin API in it. Wasmer uses a JIT for handling WebAssembly, 28 + so I'm able to completely destroy the original Go implementation in terms of 29 + performance. I call this newer, faster runtime pa'i (/pa.hi/, paw-hee), which 30 + is a [Lojban][lojban] [rafsi][rafsi] for the word prami which means love. 31 + 32 + [wasmer]: https://wasmer.io 33 + [wasmercustomabisample]: https://github.com/wasmerio/wasmer-rust-customabi-example 34 + [lojban]: https://mw.lojban.org/papri/Lojban 35 + [rafsi]: http://lojban.org/publications/cll/cll_v1.1_xhtml-section-chunks/section-rafsi.html 36 + 37 + [pa'i][pahi] is written in [Rust][rust]. It is built with [Nix][nix]. It 38 + requires a nightly version of Rust because the WebAssembly code it compiles 39 + requires it. However, because it is built with Nix, this quickly becomes a 40 + non-issue. You can build pa'i by doing the following: 41 + 42 + [pahi]: https://github.com/Xe/pahi 43 + [rust]: https://www.rust-lang.org 44 + [nix]: https://nixos.org/nix/ 45 + 46 + ```console 47 + $ git clone git@github.com:Xe/pahi 48 + $ cd pahi 49 + $ nix-build 50 + ``` 51 + 52 + and then `nix-build` will take care of: 53 + 54 + - downloading the pinned nightly version of the rust compiler 55 + - building the reference Olin interpreter 56 + - building the pa'i runtime 57 + - building a small suite of sample programs 58 + - building the documentation from [dhall][dhall] files 59 + - building a small test runner 60 + 61 + [dhall]: https://dhall-lang.org 62 + 63 + If you want to try this out in a more predictable environment, you can also 64 + `nix-build docker.nix`. This will create a Docker image as the result of the Nix 65 + build. This docker image includes [the pa'i composite package][pahidefaultnix], 66 + bash, coreutils and `dhall-to-json` (which is required by the test runner). 67 + 68 + [pahidefaultnix]: https://github.com/Xe/pahi/blob/master/default.nix 69 + 70 + I'm actually really proud of how the documentation generation works. The 71 + [cwa-spec folder in Olin][cwaspecolin] was done very ad-hoc and was only 72 + consistent because there was a template. This time functions, types, errors, 73 + namespaces and the underlying WebAssembly types they boil down to are all 74 + implemented as Dhall records. For example, here's the definition of a 75 + [namespace][cwans] [in Dhall][nsdhall]: 76 + 77 + [cwaspecolin]: https://github.com/Xe/olin/tree/master/docs/cwa-spec 78 + [cwans]: https://github.com/Xe/pahi/tree/master/olin-spec#namespaces 79 + [nsdhall]: https://github.com/Xe/pahi/blob/5ea1184c09df4e657524f9d5e77941cda5560d9a/olin-spec/types/ns.dhall 80 + 81 + ``` 82 + let func = ./func.dhall 83 + 84 + in { Type = { name : Text, desc : Text, funcs : List func.Type } 85 + , default = 86 + { name = "unknown" 87 + , desc = "please fill in the desc field" 88 + , funcs = [] : List func.Type 89 + } 90 + } 91 + ``` 92 + 93 + which gets rendered to [Markdown][markdown] using 94 + [`renderNSToMD.dhall`][shownsasmd]: 95 + 96 + [markdown]: https://github.github.com/gfm/ 97 + [shownsasmd]: https://github.com/Xe/pahi/blob/5ea1184c09df4e657524f9d5e77941cda5560d9a/olin-spec/types/renderNSToMD.dhall 98 + 99 + ``` 100 + let ns = ./ns.dhall 101 + 102 + let func = ./func.dhall 103 + 104 + let type = ./type.dhall 105 + 106 + let showFunc = ./renderFuncToMD.dhall 107 + 108 + let Prelude = ../Prelude.dhall 109 + 110 + let toList = Prelude.Text.concatMapSep "\n" func.Type showFunc 111 + 112 + let show 113 + : ns.Type → Text 114 + = λ(namespace : ns.Type) 115 + → '' 116 + # ${namespace.name} 117 + 118 + ${namespace.desc} 119 + 120 + ${toList namespace.funcs} 121 + '' 122 + 123 + in show 124 + ``` 125 + 126 + This would render [the logging namespace][logns] as [this markdown][lognsmd]. 127 + 128 + [logns]: https://github.com/Xe/pahi/blob/5ea1184c09df4e657524f9d5e77941cda5560d9a/olin-spec/ns/log.dhall 129 + [lognsmd]: https://github.com/Xe/pahi/blob/5ea1184c09df4e657524f9d5e77941cda5560d9a/olin-spec/ns/log.md 130 + 131 + It seems like overkill to document things like this (and at some level it is), 132 + but I plan to take advantage of this later when I need to do things like 133 + generate C/Rust/Go/TinyGo bindings for the entire specification at once. I also 134 + have always wanted to document something so precisely like this, and now I get 135 + the chance. 136 + 137 + pa'i is just over a week old at this point, and as such it is NOT 138 + [feature-complete with the reference Olin interpreter][compattodo]. I'm working 139 + on it though. I'm kinda burnt out from work, and even though working on this 140 + project helps me relax (don't ask me how, I don't understand either) I have 141 + limits and will take this slowly and carefully to ensure that it stays 142 + compatible with all of the code I have already written in Olin's repo. Thanks to 143 + [go-flag][goflags], I might actually be able to get it mostly flag-compatible. 144 + We'll see though. 145 + 146 + [compattodo]: https://github.com/Xe/pahi/issues/1 147 + [goflags]: https://crates.io/crates/go-flag 148 + 149 + I have also designed a placeholder logo for pa'i. Here it is: 150 + 151 + <center>![the logo for pa'i](/static/blog/pahi-logo.png)</center> 152 + 153 + It might be changed in the future, but this is what I am going with for now. The 154 + circuit traces all spell out messages of love (inspired from the Senzar runes of 155 + the [WingMakers][wingmakers]). The text on top of the microprocessor reads pa'i 156 + in [zbalermorna][zbalermorna], a constructed writing script for Lojban. The text 157 + on the side probably needs to be revised, but it says something along the lines 158 + of "a future after programs". 159 + 160 + [wingmakers]: https://www.wingmakers.us/wingmakersorig/wingmakers/ancient_arrow_project.shtml 161 + [zbalermorna]: https://mw.lojban.org/images/b/b3/ZLM4_Writeup_v2.pdf 162 + 163 + pa'i is chugging along. When I have closed the [compatibility todo 164 + list][compattodo] for all of the Olin API calls, I'll write more. For now, pa'i 165 + is a very complicated tool that lets you print "Hello, world" in new and 166 + exciting ways (this will change once I get resource calls into it), but it's 167 + getting there. 168 + 169 + I hope this was interesting. Be well.
+2 -2
deps.nix
··· 257 257 fetch = { 258 258 type = "git"; 259 259 url = "https://github.com/prometheus/client_golang"; 260 - rev = "v1.4.0"; 261 - sha256 = "102x5qvnja9y3qx9vyr85rp3y63imk0rk73r91xzyhpp6mrcqfbh"; 260 + rev = "v1.4.1"; 261 + sha256 = "1kx461i7kw6y8s98774d0aasagzjh60ijsg3ikzxrfcc6adjmhz2"; 262 262 }; 263 263 } 264 264 {
static/blog/pahi-logo.png

This is a binary file and will not be displayed.