O'Reilly logo

Building Web Applications with Erlang by Zachary Kessin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. Interfacing with Ruby and Python

So you’ve been reading this book and thinking that Erlang sounds amazingly cool. You already have a web infrastructure in PHP, Python, or Ruby but you would love to be able to build some structure in Erlang. There are several ways you can do this. You could use something like RabbitMQ to couple different parts of an application with queues. You could also create a web service in Erlang and access it from another language, or send data over a socket. However, what would be really nice is being able to have native communications between Erlang and some other language.

This is actually fairly simple to do. As we know by now, Erlang processes can communicate over a wire protocol. When you send a message from process A to process B, all the data is serialized in some way and sent across to the other process to receive. Knowing that, you might think it would be pretty easy to create a package in another language that can speak that protocol and work with it, and of course you would be right. There are packages for Ruby and Python (and others) that can do that quite well. (Sending Erlang functions to other languages probably won’t work.)

These interfaces can be used to mate a frontend in Python or Ruby to an Erlang backend or vice versa. They can also be used when porting some code to Erlang for testing. If you have a module that has been well tested in Ruby, for example, you could use QuickCheck to try a large number of test cases on both the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required