Extending hoprd via WebAssembly (hoprd-ng :-)

hoprd is implemented in Typescript and runs using Nodejs. The choice of Typescript and Nodejs was made to be as flexible as possible in the future in terms of running hopr on mobile devices, embedded devices or a web browser.

However, the platform choice can be problematic for system server software like hoprd because of the constraints of both Typescript and Nodejs.

In comes WebAssembly which has become a widely supported standard, can be run in web browsers and Nodejs alike. That also means software which can be compiled into WebAssembly can be integrated with existing Typescript/Nodejs software. This opens up the opportunity to use other programming languages which might lend itself more towards implementing concurrent system software while retaining the ability to run within web browsers.

Such an integration can be a step-by-step process where parts of hoprd are gradually implemented in some other language while still running on Nodejs. Only at the end the whole of hoprd could then be switched off Typescript and Nodejs if desired.

Thus, I would like to open up a discussion for suggestions of programming languages, including pros and cons of their use for hoprd.

The main requirement is the ability to target WebAssembly.

Here is a good list of options: I want to… - WebAssembly

For suggestions please include specific pros/cons so we can compare suggestions appropriately.

Thank you

2 Likes

When I read WebAssembly (WASM), I smell Polkadot/Kusama.
And I am 100% convinced that this is where the music plays during the next years.
So a big thumbs up from my side!

1 Like

Thanks for the pointer. I am not familiar with Polkadot/Kusama in that context, could you elaborate on your thoughts?

1 Like

I am pretty amazed by Dotsama too. I think every step towards the internet of Blockchains is a good step…

1 Like

WebAssembly (Wasm) · Polkadot Wiki :slight_smile:

Thanks for the link. The description on that page is somewhat inconclusive, but I will dig some more and read up on it.

Proposal for using Golang to build components for hoprd.

Advantages

  • very simply language, easy to learn for newcomers
  • memory-safety at the core of the language
  • statically typed
  • great documentation
  • good standard library
  • includes basic concurrency features like Mutex, Queue, etc
  • gofmt
  • frequently used in the crypto space
  • lots of experienced Golang systems developers out there

Disadvantages

  • package management is Git-based and uses vendoring
    • this is mostly a subjective view though
    • hard to follow releases in deps
    • repositories get bloated easily
  • concurrency via goroutines (CSP) is useful, but quite a different model than traditional approaches and requires careful send/receive handling
  • large resulting binary sizes, which might not be as problematic for server applications like hoprd

What does Golang offer over Javascript/Typescript?

I believe Golang is superior in every aspect to JS/TS for the use-case of hopr. Its still fast to work with due to the simple language features but serves the server-oriented programming model better. Its simplicity might lead to more verbose code, but I don’t consider this a big drawback.

Links

Tour of Go (Interactive Language Tutorial)
Golang Blog