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

  • CodeFarmer@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 months ago

    Web Assembly handle strings as arrays of integers

    I’m afraid I may have some startling news.

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

      I’m really interested if you have some news about this very topic. Seriously!!! Handling strings was really a hassle in WASM and if there is now a better solution I’m really excited to this prospect.

      Do yo have any pointers?

      • CodeFarmer@alien.topB
        link
        fedilink
        English
        arrow-up
        1
        ·
        10 months ago

        Sorry, my news was slightly tongue in cheek. Any assembly-like solution ultimately treats strings that way.

          • Frere_de_la_Quote@alien.topOPB
            link
            fedilink
            English
            arrow-up
            1
            ·
            10 months 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.