Futures in Rust

Writing an Async Web API Wrapper - An excercise in learning Rust

I stumbled upon Rust a few months ago but didn’t really bother to learn it. The ecosystem was tiny, the language seemed to be of little practical use and it was bothersome to get my head around its quirks like borrowing and lifetimes.

But things have changed. With growing interest and a fast-evolving ecosystem, the language is impossible to ignore. Go’s goroutines and Scala’s Futures had really spoiled me and I really needed something similar. Then I stumbled upon futures, a zero-cost futures and streams Rust library. And I thought of making a simple async web API wrapper as my first Rust project and a blog post to go along as a tutorial.

[Read More]

Wrapping a C library in C++

Why, When, How

Lots of libraries offer interfaces in C mainly to be universally callable from any programming language. This is absolutely fantastic! It lets any language with a FFI (Foreign Function Interface) to hook into and use a large number of C libraries. But the downsides? The code is verbose, memory needs to be manually managed and it’s really easy to forget the crucial bits.

C++, being extremely close to C, can easily call into a C library if needed. And the vice-verse is also true if extern "C" is used (instruct the compiler to not mangle function names). So, should you even go through the trouble of wrapping it in C++? If so, what’s a good way to do it? This post explores these questions and offers an insight into the hell called cross-language interoperability.

[Read More]