Serverless functions in your favorite language with OpenWhisk

rodric rabbah
Jan 23, 2018 · 3 min read

Apache OpenWhisk is a readily extensible serverless computing platform that supports functions authored in many programing languages including Node.js, Python, Swift, Java, and PHP. The set of supported languages extends beyond these five however, and includes Go as well as other compiled languages. In fact, a feature of OpenWhisk that has been around for some time, but not well documented, is its support for native binaries. With a native binary, any executable that is compatible with a standard OpenWhisk container may run as a serverless function, also known as an action.

The native binary approach affords you more languages to choose from for your serverless applications, such as Go, Rust, C and C++ to name some. Not to mention, you can also bring your own Docker container and run it as a function.

I recently added a quick guide for running Go programs as OpenWhisk actions. Thanks to James Thomas, there’s also a tutorial for Rust actions. You can even run COBOL programs as actions (check out this YouTube video for a demo).

In OpenWhisk, actions run within managed Docker containers. The platform’s architecture permits bespoke Docker images for each language runtime. This approach has permitted IBM Cloud Functions, for example, to offer Node v8 support with SDKs that are specific to the IBM Cloud portfolio, including Watson services and Cloud Object Storage. Another recent addition will bring a Python image with packages popular for numerical analysis and machine learning.

You can find out the supported runtimes and images specific to an OpenWhisk deployment from the manifest accessible at the root of the API host. For example: for IBM Cloud Functions, or your localhost for a private deployment.

The OpenWhisk community has demonstrated some of the extensibility of the platform, notably with the addition of PHP support by Rob Allen. We welcome GitHub contributions (C# is on the wishlist) and encourage interested developers to join the conversation with the growing community on Slack.

A recent discussion on GitHub around runtimes raised the issue of running Bash scripts as serverless functions. With native action support, that’s also readily supported in OpenWhisk. Here’s a brief example using Bash to flip a coin N times and return the number of times the coin is heads or tails.

Saving the code above to a file, the wsk CLI turns the rest into a standard action creation and invocation.

Parting Thought: The polyglot nature of actions is noteworthy in the context of function composition. That is, actions may be composed irrespective of their implementation language. As a result, developers are empowered to use the right language for the task at hand while building complex serverless applications. The platform’s support for a wide range of languages, with a canonical interface between functions, protects existing investments in legacy code, provides a gentle migration path to the cloud, and doesn’t force developers to give up their language of choice for the sake of adopting the serverless computing paradigm.

Apache OpenWhisk

Apache OpenWhisk is a serverless cloud platform that…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store