Rusty Box: Creating a Rust client for the Box API

Rui Barbosa
Box Developer Blog
Published in
3 min readJun 14, 2023

--

Recently Box held an internal hackathon, and I participated exploring the idea of creating a Rust client for the Box API.

What was I thinking?

I had 3 objectives for this exercise:

  • What would it take to build a Rust client for the Box API
  • Is there any interest from the developer community in having a Rust client.
  • Having fun while learning something new

Why Rust?

Rust is a robust language specifically designed for systems programming, offering a multitude of advantages. By building a Box API client in Rust, we can leverage its key features such as memory safety, performance, concurrency and parallelism, developer productivity, and cross-platform compatibility.

While Rust may not be the easiest language to learn and has a steep learning curve, it enforces strict rules and doesn’t tolerate errors easily. However, I have grown to appreciate its capabilities immensely.

Having spent the past year working with Python, I have found myself gravitating towards a more disciplined approach using type hints, static analysis tools, and strict coding conventions.

Rust takes this discipline to the next level. When developing in Rust, the focus shifts towards optimizing for correctness, even if it means sacrificing development speed. In the context of an API client, prioritizing correctness is essential.

By harnessing the power of Rust, we can create an API client that excels in memory safety, performance, concurrency, and productivity.

I highly encourage you to consider exploring Rust for your next project and unlock its benefits.

YASDK (Yet Another SDK)?

Box already has SDK's for C#, Java, Python, Node, iOS, and Android, and the community has created a few more for Ruby, Salesforce, Chrome, R and even OutSystems. All of them open source.

If your favorite developer language is not covered on the above you can always fallback to using the REST Api directly.

However we want to test the waters and understand if Rust is having traction on the developers who want use the Box API.

Drop us a note either here or in our developer community at forum.box.com

The Great Experiment

The Box hackathon lasted for 24 hours, and although I'm happy to share what was done, don't expect much. The code still has a lot of .unwrap() , it is cumbersome, incomplete, not supported, rebel scum, hack and slash, and it can be found on this GitHub repository.

Rusty Box Hackathon presentation. (Inspired by Namtao lostterminal.com)

I'm am currently working on creating a proper crate, very early stages work in progress. If you would like to contribute here is the GitHub repository.

How do you sell Rust internally?

Of course we didn't win the hackathon, everyone was doing the AI thing, and some incredible ideas for applying AI to new Box features were presented, which can be incorporated on our product road map. These ideas are much more useful and easy to executed when compared to adopting a new language.

This got me thinking on how do we, developers, convince management in diverting company resources to adopt a new development language such a Rust.

Rust does have powerful arguments from a technical perspective, and it has also been adopted by some technology giants such as Mozilla, Microsoft, Amazon, Google, Facebook, to name just a few, also Linus Torvalds welcomed Rust into the Linux kernel.

However these are not good enough arguments for a well managed company.

Box is a SaaS company, and I bet the invoice from the cloud providers is among the top 5 cost categories in the balance sheet.

Rust makes a more efficient use of memory and computing power, it should in theory, by the end of the day, lower the cloud computing cost.

But how do we prove it? How to measure this?

If you have any experience related with this topic and you feel you can share some wisdom with us, then drop us a note either here or in our developer community at forum.box.com

If you enjoyed this article, please give use a clap, and make sure to follow our Box Developer Blog.

We also just release a brand new Box Developer forum, this is the ideal place to reach out and engage us directly.

Happy coding!

--

--