Can write routines in golang, compile them to Javascript, and write the rest of the program in Javascript?

I asked a similar question on Stackoverflow, but I’ve realized that people there don’t know. People here know.

I have been working in Javascript for several years, and in Nodejs for about a year. Node seems to me fine for “quick and dirty” projects, but if you want something that can be maintained and extended by a group of programmers, it has too many dark corners. You want Go.

I am very attracted to Go’s channels, its good documentation, and for my particular case the ability to say “DumpRequest” and “DumpResponse.” But I need the deep list of packages available on Nodejs. In particular the payment processing modules that talk to every payment processing provider under the sun.

Can I write much of my code in Go, and compile it to Javascript using Gopher? Treat Javascript as “assembler” and Go as “C”. Write an assembler program, but have large swaths of it written in C and compiled to assembler.

Has anyone done this? Or thought about it? Regards, Rick

Hey @cubsno1,

I haven’t personally used this myself for anything, but I think you might be looking for something like gopherjs:

I’m a little nervous, because where the gopherjs folks talk about making system calls, they say this:

some programs may not behave as expected due to the fact that the current implementation blocks other goroutines during a syscall, which can lead to a deadlock in some situations. This is not considered a bug, as it is considered sufficient for most test cases (which is all Node.js should be used for).

I suspect that it might work, but I will spend several weekends elbow deep in Go code. :^)

Hmm. I’m starting to thing I should let Go run as Go, and pass messages back and forth to it. Using this facility built by Ryan Dahl, the author of Node.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.