I have a C NIF in my Erlang project that has limitations, due to libraries that it relies on (unstable libraries, or libraries that I need that don't exist). I think that I can do what I want to do, in Go. Can Erlang interface to Go like this?
Asked
Active
Viewed 1,010 times
2
-
1I suppose no. But you can look [this answer](http://stackoverflow.com/questions/2910212/erlang-interfacing-with-xalan-port-driver-or-nif/2915090#2915090) and [this](http://stackoverflow.com/questions/29817331/converting-erlang-c-port-example-to-erlang-golang). – Oct 05 '16 at 00:45
-
Not an answer to your question but you could look into [Go-node](https://github.com/goerlang/node). It uses standard Erlang distributed messaging. – byaruhaf Oct 05 '16 at 02:07
1 Answers
1
Summarizing the above comments into an answer:
- There is no such thing as a simple Go NIF
- The standard Erlang approach to needing to make foreign calls of moderate weight is to write a port driver. There's an example of calling Go from Erlang in this answer.
- A more heavyweight solution is to implement the distribution interface and make a whole foreign node. There's some code to do this that might be interesting.
- If you really wanted to make a Go NIF, you'd want to write a C interface to Go, then call that C interface as your NIF.

Community
- 1
- 1

Nathaniel Waisbrot
- 23,261
- 7
- 71
- 99