hack-pad / hackpad

The in-browser IDE for Go
https://hackpad.org
Apache License 2.0
531 stars 37 forks source link

Tinygo #8

Open gedw99 opened 3 years ago

gedw99 commented 3 years ago

I was playing with the code

the way gs and indexdb is used is really impressive and highly useful

I am thinking that tinygo might be mature enough to deal with this code now .

the main thing was to avoid reflection ( like the standard golang json encoder ). The solution was generally to use flatbuffers. Flatbuffers is nature now and very useable .

Anyways your project is really awesome . Just wanted to add my thoughts about strategies for using tinygo :)

if you need examples of what I am referring to above just yell

gedw99 commented 3 years ago

What about a separate branch so others can help port code to tinygo ?

JohnStarich commented 3 years ago

Hey again @gedw99! 🙂 That would be interesting.

I think I'd first need to understand the differences between Go's and TinyGo's Wasm syscalls setup. Go Wasm may be able to accommodate another runtime if they're compatible. I see some mentions of Wasm in the tinygo repo, but I didn't find the "js implementation of syscalls" right away. Are you familiar with tinygo's runtime?

gedw99 commented 3 years ago

Yes I am using tinygo and there are tons of examples of other gophers using it.

syscalls example: https://github.com/jerson/openpgp-mobile/blob/flatbuffers/Makefile.wasm

This uses flatbuffers for serialisation.


Tinygo standard lib is a good doc !

https://tinygo.org/docs/reference/lang-support/

https://tinygo.org/docs/reference/lang-support/stdlib/

Reflection and net ( http ) are not yet supported. But PR’s are merging in every few days for it. They generally copy the official golang code in and then just clean it up so it works with tinygo.

For the reflection problem just use the golang json lib that genji and others use. https://github.com/genjidb/genji/blob/main/go.mod#L6

TO compile using tinygo: https://github.com/genjidb/genji.js https://github.com/genjidb/genji.js/blob/master/scripts/buildgo.sh#L27


There are many many projects using tinygo for WASI also but more for servers of course

if you want more examples or whatever just yell :)

gedw99 commented 3 years ago

Hmm this ? https://github.com/tinygo-org/playground/blob/master/runner.js

JohnStarich commented 3 years ago

Hey @gedw99, FYI Go Wasm is now Hackpad!

I may be splitting things into new even more repos in the coming weeks, possibly including the runtime and the Go installation system. We may take another look at tinygo with all these changes 🙂

gedw99 commented 3 years ago

thanks @JohnStarich for letting me know.

I will kick the tires....