←back to thread

153 points yar-kravtsov | 2 comments | | HN request time: 0s | source

I built a Vite plugin that lets you write Go code directly in .js files using a "use golang" directive. It compiles to WebAssembly automatically.
Show context
pjmlp ◴[] No.45718527[source]
Cool hack, just use JavaScript.
replies(2): >>45718573 #>>45718617 #
kitd ◴[] No.45718573[source]
The author explains why you might want to use Go instead at the end of the readme.
replies(1): >>45718644 #
onion2k ◴[] No.45718644[source]
I don't think any of the use cases suggested really make sense though. For a compute-intense task like audio or video processing, or for scientific computing where there's likely to be a requirement to fetch a ton of data, the browser is the wrong place to do that work. Build a frontend and make an API that runs on a server somewhere.

As for cryptography, trusting that the WASM build of your preferred library hasn't introduced any problems demonstrates a level of risk tolerance that far exceeds what most people working in cryptography would accept. Besides, browsers have quite good cryptographic APIs built in. :)

replies(2): >>45718737 #>>45718926 #
1. tgv ◴[] No.45718737[source]
> For a compute-intense task

The browser often runs on an immensely powerful computer. It's a waste to use that power only for a dumb terminal. As a matter of fact, my laptop is 6 years old by now, and considerably faster than the VPS on which our backend runs.

I let the browser do things such as data summarizing/charting, and image convolution (in Javascript!). I'm also considering harnassing it for video pre-processing.

replies(1): >>45718847 #
2. pjmlp ◴[] No.45718847[source]
You can take advantage of that power via WebGPU, or WebGL if the browser is not yet up to it.