What interfaces exist to tie Erlang with C++?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Anyone interested in the erlang/C++ integration aspect, may also want to check out this article: Rewriting Playdar: C++ to Erlang, massive savings:
To Zed's excellent answer, I would add
open_port()
. It lets you start an external program and communicate with it from Erlang using its standard in and out. You can use it like Unix pipes by giving the {line, L} option, or there's also the length-prefixed {packet, N} option which I find to be safer and more efficient.The advantage of this over NIFs and port drivers is that your Erlang code is totally insulated from the C code. The C program can smash its own stack, double-free blocks of memory, enter an infinite loop, whatever. None of this stops your Erlang code. At worst, you close the Erlang port and re-open it if things go pear-shaped.
Native implemented functions: available in the latest Erlang/OTP version, allows you to implement any of your functions in C.
Port drivers: you can link a C code to the Erlang VM, and access it using port_command.
C Nodes: With the ei library you can mimic a VM and talk to your Erlang VMs using the Erlang distribution format.
The closest thing I know for interfacing Erlang with C++ directly is EPAPI. Of course it relies on the tried and tested C
erl_interface
that comes standard with the Erlang distribution.