2

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?

HotBlanket
  • 97
  • 8
  • 1
    I 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 Answers1

1

Summarizing the above comments into an answer:

  1. There is no such thing as a simple Go NIF
  2. 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.
  3. 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.
  4. 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