When you implement your own programming language, one of the problems is to implement a GUI to play with it. If you compile with WASM, you can solve this issue and a as a bonus you will be able to demonstrate your language across the Internet quite easily.

However, there are some real issues. One is that Web Assembly handle strings as arrays of integers.

If you are interested, I compiled my own language: LispE as a WASM library.

I have written a few blogs about how to do it: https://github.com/naver/lispe/wiki/6.18-Handling-strings-in-WASM-without-burning-yourself

Here is also a guide on how to use this library: https://github.com/naver/lispe/wiki/6.17-A-WebAssembly-version-of-LispE

    • Frere_de_la_Quote@alien.topOPB
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      Not exactly. Javascript strings are encoded as UTF-16 characters. Each element in this array of integers is a UTF-16 code point… So basically most characters are encoded on int16_t, except for very large codes, such as emojis, which are usually implemented on two int16_t.