Re:Tinygo: LLVM-based Go compiler for microcontrollers, WASM...
by liftm on Monday June 06, 2022 @07:46AM
(#31639253)
Tinygo is neat, but the one time I tried to use it in practice, it failed me. The following program will panic when compiled to wasm:
package main
import "encoding/json"
func main() {
var parsed interface{}
json.Unmarshal([]byte(`{"test":42}`), &parsed)
}
(It's been a while, so I forgot the problem with it was.)I'm curious what kind of text parsing you do. I ended up rolling with valyala/fastjson, but that's very much not what I was imagining. Lots of existing libraries don't work either, and finding out what does and what doesn't is pain. Is there some trick to working with it?
Re:Tinygo: LLVM-based Go compiler for microcontrollers, WASM...
by maxmcd on Monday June 06, 2022 @12:17PM
(#31642361)
I don't think "encoding/json" is fully working yet.
Seems to be importable now, although tests are not passing. See supported packages here: https://tinygo.org/docs/reference/lang-support/stdlib/
Definitely still a ways to go before the full stdlib is usable.
Looks like your code still fails at runtime with the error:
panic: unimplemented: (reflect.Type).NumMethod()
Tested here: https://play.tinygo.org/
Re:Tinygo: LLVM-based Go compiler for microcontrollers, WASM...
by eek2121 on Monday June 06, 2022 @01:06AM
(#31637390)
Dunno bro, it doesn't work on the 6502, so... ;)
Re:Tinygo: LLVM-based Go compiler for microcontrollers, WASM...
by Joker_vD on Monday June 06, 2022 @11:14AM
(#31641549)
By today standards, 6502 is a nanocontroller... or maybe even a picocontroller. Go buy yourself a real microcontroller, y'hear me? /s
Re:Tinygo: LLVM-based Go compiler for microcontrollers, WASM...
by connicpu on Monday June 06, 2022 @12:40PM
(#31642696)
I mean in a world where a 32-bit microcontroller with flash in the 1-2MB range and a few hundred KiB RAM can cost less than $2 why make things harder on yourself :P
If you're using a chip without the bells and whistles for precise timing reasons, then you're probably gonna program it in assembly too anyways
With TinyGo + wasmer[1] I can build a library that is usable in Python, PHP, Javascript and C++. It has been a lot of fun for me. Lots of rough edges still exist when moving between WASM/calling language, but when you get it working it feels amazing.
[0] https://github.com/pion/explainer
[1] https://wasmer.io/