3 ms·
Tinygo is severely limited, e.g. it doesn't support encoding/json. Want to deal with any JSON API, or anything that indirectly uses JSON serialization? Forget a
by oefrha 6y ago
Tinygo is severely limited, e.g. it doesn't support encoding/json. Want to deal with any JSON API, or anything that indirectly uses JSON serialization? Forget about it.
A current side project of mine uses golang's wasm. Not a big codebase, but the wasm is 2.7MB brotli'ed. Certainly huge to me (I'm sure it's almost in the lean and mean camp compared to the average website today, though).
- gray_-_wolf 6y agoencoding/json sucks anyway, so using something 3rd party would likely be better option anyway
- wlll 6y agoHow so?
- gen220 6y agoI think it’s well demonstrated to be slow (ns/op) and wasteful (allocs/op) in benchmarks, especially in bigger payloads. The HTTP library is similar. Most 3rd party libs make some trade offs that are pretty reasonable to achieve superior perf, but it’s worth understanding them to make sure it’s best for your use case.
- gray_-_wolf 6y agoI've run into few issues: 1. Performance: lot of reflection and allocations, so not the fastest thing ever. 2. Case insensitivity: https://play.golang.org/p/LtwChO_tp0 https://play.golang.org/p/LtwChO_tp0 this can be pretty unpleasant when it bites you 3. Unicode: It replaces invalid utf8 with unicode questions marks (dunno how exactly is the replacement character called) but does not provide any API to detect that it happened. So that can lead to silent corruption of the data.
- wlll 6y ago3. in my mine makes it totally unusable, I didn't know that, glad I do now! 1. and 2. I could likely live with, but aren't great.
- gen220 6y agoYeah, tinygo was originally intended for embedded, so the good news is that many significant wasm binary size optimizations are still to come, I think. Today, there are ways to get the binary smaller, but they involve avoiding certain libraries or preferring certain implementations of common libraries over others. It’s definitely an art that requires conscientious practice these days. A run of the mill go application will not compile down to a tiny wasm with tinygo, without refactoring. But it’s possible. Like I said, it’s on the outskirts, not downtown. Still within reach at least.
- sagichmal 6y agoTinyGo will soon support encoding/json.