Chapter 12. Integrating with foreign code using ports and NIFs

 

This chapter covers

  • Ports, linked-in drivers, and natively implemented functions (NIFs)
  • Integrating a third-party C library
  • Integrating the C library using NIFs

At this point, the cache does a number of interesting things, such as log its actions, distribute across multiple nodes, and automatically connect to the cluster. It also has a RESTful HTTP interface for storing binary data, as well as a simpler text-based TCP interface for storing Erlang terms in general. Overall, the Erlware people are happy. But it would be nice if the clients who use the HTTP interface were able to store structured data in a standard way, and without doing their own marshalling and unmarshalling. The Erlware people would like you to modify the RESTful API to use the JavaScript Object Notation (JSON) format for storing and retrieving data. (See www.json.org for details. Note that in this chapter, we’ll refer to JSON objects as maps, to be consistent with the terminology used by YAJL.)

12.1. Ports and NIFs

12.2. Integrating with the parser through a port

12.3. Making a linked-in driver

12.4. Implementing the parser as a NIF

12.5. Summary