5 ms·
Great article! I attempted something very similar and wrote about it here: https://matthewphillips.info/programming/wasm-golang-ce.html https://matthewphillips.
by MatthewPhillips 8y ago
Great article! I attempted something very similar and wrote about it here: https://matthewphillips.info/programming/wasm-golang-ce.html https://matthewphillips.info/programming/wasm-golang-ce.html
Like the author I'm pretty enthusiastic about using Go for web development. The interop story is quite strong.
My biggest concern is the binary size. 1.3mb for what is essentially a hello world. Given that Go needs to include garbage collection I'm a tad worried they won't be able to cut down the size enough to make it worthwhile to use.
- bketelsen 8y agoNeat! That was my original hope, to move down the component path, but I got nerd-sniped by how well everything worked and started playing with making existing gopherjs apps work. Great article.
- erikpukinskis 8y agoSadly, 1mb is not that big for web pages lately. So that could be competitive with a js stack for some apps.
- solarkraft 8y agoI think some very simple (tens of loc) Go programs I wrote ended up compiling to Linux binaries of about 5mb.
- axaxs 8y agoThis can be the case, depending on imports(looking at you, fmt). But it doesn't scale that way, I assure you. So you may hit 5 to 8mb early on in building a basic 100loc webserver. Then at 100k loc you can be looking at 10mb. I've found most of our rather large webservers unoptimized, to be in the 10 to 15mb range.
- GijsjanB 8y agoThis is changing, I (think|hope). Two years ago I was building 1MB+ sites (because: SPA). Now I am down to 500KB, due to SSR and code splitting. Performance is back on the menu.
- snarfy 8y agolibc is not tiny either. Try compiling helloworld.c using gcc with -static option. You get a similar size. I don't use Go much but I recall comparing binaries and a Go binary was about 200k larger than a binary from gcc compiling C.
- mahkoh 8y agoglibc cannot be linked statically.[1] Compile hello world against musl libc with -static and you get an 8kb binary. [1] https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked...
- dottrap 8y agoHere's another link which compares musl, uClibc, dietlibc, and glibc sizes, features, and performance. http://www.etalabs.net/compare_libcs.html http://www.etalabs.net/compare_libcs.html It says musl's smallest static C program can be 1.8k as opposed to glibc's 662k, showing libc doesn't always have to be big and bloated.
- skolemtotem 8y agoThere have been talks of adding a GC to WASM for a long time, so there's hope yet
- remus 8y agoI believe there's been some debate within the go team as to how well a non-go GC would work with go, as the current GC is pretty tuned to the quirks of go (go routine stacks etc.)
- remus 8y agoWorth bearing in mind that hopefully a lot of that will be runtime overhead, so it won't scale linearly with the size of your program.
- MatthewPhillips 8y agoThat's great, but 1.3mb as a baseline is just too big for most common DOM manipulation type of use cases. You want your UI drawn within a couple of seconds or the experience becomes bad. Even if they were able to cut it in half I'm not sure I'd be comfortable using it. I'd really want to profile and see how fast you can get to interactive using something like this. Now for heavier applications like graphics or video editing, this would be fine to use.
- PretzelFisch 8y agoI don't know, if your making a LOB app. It's a one time hit just like installing an app. It might not be that big of a deal. If you us it for your mobile website, big trouble.
- PretzelFisch 8y agoWill webassembly allow for shared code so, a framework might be cacheable and each app does not need to package the whole thing? Did I just ask for dll hell...