Integrating External Programs with Our Code

We’ve been through the steps needed to publish your work on GitHub. Now we’ll look at how to include other people’s work in our projects. As an example, we’ll integrate the code from bitcask into our bertie project.

We’ll change bertie so that when it starts, it prints the number of times it has been started. So, for example, when it starts the tenth time, bertie will announce the following:

 
Bertie has been run 10 times

To achieve this, we’ll store the number of times bertie has been run in a bitcask database. In bitcask, keys and values must be binaries. We’ll choose the key to be the binary <<"n">> and the value to be term_to_binary(N), where N is the number of times bertie has been run. bertie.erl ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.