276 points iaaan 12 hours ago 38 comments
KingOfCoders 11 hours ago | parent
logicallee 11 hours ago | parent
KingOfCoders 11 hours ago | parent
logicallee 11 hours ago | parent
KingOfCoders 10 hours ago | parent
childintime 8 hours ago | parent
01HNNWZ0MV43FF 10 hours ago | parent
Yes, wasm can do that.
You can compile the code to wasm, then run it in a runtime like wasmer or wasmtime. Or you can ahead-of-time compile it with something like wasm2c, which generates C code.
actionfromafar 9 hours ago | parent
ncruces 5 hours ago | parent
nottorp 2 hours ago | parent
wffurr 9 hours ago | parent
GOOS=js GOARCH=wasm tinygo build -o wasm.wasm ./main.go
https://tinygo.org/docs/guides/webassembly/wasm/It relies on LLVM’s Wasm backend and some JS glue libraries for the browser.
rcarmo 9 hours ago | parent
shit_game 9 hours ago | parent
pjmlp 9 hours ago | parent
Congratulations to the team.
Are some of the improvements coming from TamaGo? I know there was supposed to exist a collaboration with other Go toolchains, if I remember correctly a issue that I saw fly by in the past.
dofm 9 hours ago | parent
I have some Go experience (a small utility used by some dozens of quite niche customers) and trivial experience of macOS development.
So far my two projects have been Go/Gin/goose etc. — a web app — and a small desktop Swift app. But there's GUI stuff for Go and web stuff for Swift. (I could have written my mac app exactly in Golang because there's a package that does what I need)
I had hoped I would find that one of these languages was clearly better than the other. Go is obviously better for the LLM, maybe a bit tiresome to see enormous reams of it for me. Swift is a little harder on the LLM (and it builds more slowly) but it's a bit easier on the eye; I've been very productive in it.
Here, again, it will be hard to separate TinyGo and Embedded Swift.
And there's WASM support for both.
shim__ 5 hours ago | parent
pjmlp 1 hour ago | parent
Chapter 5, https://gchandbook.org
"A Unified Theory of Garbage Collection"
https://web.eecs.umich.edu/~weimerw/2012-4610/reading/bacon-...
donatj 6 hours ago | parent
Way saner than the C pico projects I've helped my friend work on.
Maybe it's just me but I kind of wish there was more of a way to clearly differentiate a Go project from a Tiny Go project, like .tgo file extensions or like a "compiler tinygo" directive in go.mod or something.
gen2brain 6 hours ago | parent
worg 1 hour ago | parent
K0IN 4 hours ago | parent
ghoul2 5 hours ago | parent
neomantra 4 hours ago | parent
The TinyGo project is an intensely talented cadre of developers. They care deeply this alternative Go compiler/runtime. It was really neat to see them in action and how an already established project accelerated in a year.
It was interesting to see how they adopted LLMs (basically use them but you better know what's going on) and how they dealt with newcomers. The project's scaffolding has improved to keep pace.
While it was intended to get Golang on small devices, the same love makes it work well for WASM. Also it improves as LLVM improves.
I rather consistently get 50% size binaries that run 10% faster and use lower memory than Vanilla Go. The drawback is 5x slower build times. So I dev-loop with Vanilla go and then prod-loop with TinyGo.
Booba will help you embed your Golang in a browser, either Vanilla or TinyGo. There's still some go.mod friction, but the next BubbleTea release will fix that.
https://nimbleterminal.com/booba
Here's some TinyGo interactive graphics next to Vanilla:
https://nimblemarkets.github.io/ntcharts3d/?demo=gallery&com...
Pro-tip: use gc=boehm for JS/WASM targets
noselasd 4 hours ago | parent
wkjagt 3 hours ago | parent
justinclift 3 hours ago | parent
janderland 46 minutes ago | parent
theplumber 2 hours ago | parent
I know that in the standard Go compiler it is still “experimental”. What I mean by that is the program can hang due various issues with wind/unwind browser behaviour. The memory management seems to be another issue. You just can’t ship go-> wasm app in browser in production.
My hope is that once wasi 3 and a wasm-gc implementation will be released for Go then I will finally be able to actually use Go in the browser(via WASM). Until then it’s more or less a kind of java applets experience
aaron42net 1 hour ago | parent
To get the size down, I avoided including anything using reflection (including encoding/json and fmt) and left most of the runtime out, which means the WASM blob can't do concurrency or its own scheduling. The WASM blob is used basically as a set of function calls that take some input and return some output via a preallocated byte buffer shared between TypeScript and Go, with all of the timing, etc driven by the TS side.
This was a weird set of design tradeoffs, but the result is that thousands of lines of Go turn into 276k uncompressed (128k compressed) WASM blob that has 118k of minified JS (37k compressed) driving it that works pretty well. And I still got to make heavy use of Go's great fuzzing tools to chase down weird bugs in the drone logic.
Compared to "hello world" in normal Go being a few megabytes, this seemed pretty impressive, but you could certainly use more of the Go runtime and standard library if you weren't trying to optimize size as much.
mkarliner 3 hours ago | parent
onlyrealcuzzo 3 hours ago | parent
``` Non-goals:
* Be efficient while using zillions of goroutines. However, good goroutine support is certainly a goal.
* Be as fast as gc. However, LLVM will probably be better at optimizing certain things so TinyGo might actually turn out to be faster for number crunching.
* Be able to compile every Go program out there.
```
This could mean almost literally anything from - practically - it doesn't compile any existing commonly used Go packages, and is worse at concurrency than Java to it will compile almost anything except packages that are doing really weird, generally accepted terrible things and outside of rare p999 edge cases, it's competitive with Go.
rob74 2 hours ago | parent
onlyrealcuzzo 1 hour ago | parent
I get what it wants to do.
I have no idea what that costs.
ValentineC 2 hours ago | parent
kermatt 2 hours ago | parent
Is there a case for building CLIs with TinyGo meant to run on workstations, instead of the vanilla Go compiler?
flykespice 14 minutes ago | parent
First off let's not conflate mcu with Iots, that have built-in wireless support. They have more generous constraints than low grade mcus like Arduino Uno (2kb sram..).
Yet this one also says it targets arduino uno. Won't the GC runtime be too much for the small mcu strict memory constraints?