Building Bipa in 90 days

How I built Bipa alone using Rust in just over 90 days

Bipa Engineering
Published in
4 min readJul 2, 2020

--

Lets start by getting things straight, it wasn’t 90 days 😬, it was just over 4 months, but if we discount the distractions due to the pandemic, it would amount to about 90 days. 😅

Bipa is a mobile app that allows Brazilians to buy and sell Bitcoin on their iOS devices, it consists of a web server and a mobile app as it’s main applications.

Bipa’s server is written using Rust and the Rocket web framework. Choosing Rust as the main backend language has been a huge plus in helping me ship the first version of a product that works.

When writing large software, things tend to get ugly pretty soon. Different parts of the software end up affecting each other and if we don’t keep that in check we can introduce some serious bugs into our programs.

In my last job, where I worked maily with Ruby and Elixir. I dedicated a large portion of my time to writing unit and integration tests that would cover all scenarios we could possibly imagine. And still, I can recall many instances where we would make a very subtle change on our code, and we would end up with users having an inconsistent experience on the platform.

If you looked at all the problems, you would see that most of the bugs came from wrong assumptions about the code’s signature or from refactorings that have not been fully completed. This really frustrating, especially for beginners who have not yet experienced many of the problems you encounter when programming and end up making many of the same mistakes over and over again.

Who has never accidentally shipped a typo that broke a specific part of the app? That scares the hell out of people starting out as software engineers, which ends up holding them back into experimenting more with their code and capabilities, so they stick with these ‘patterns’ to architect and organize their code to protect from themselves.

When starting Bipa I did not want to have to go through that, I wanted a language and framework that would allow me to be productive and write correct code without shooting myself in the foot. More specifically, I wanted to be able to:

  • Know what my code does just by reading it, I strongly believe code is your best documentation.
  • Refactor it like a boss, change as much as I want without worrying too much it would break something else.
  • Have a strong community and well written frameworks ready to use.

When reading these points, the avid reader will immediately notice that what I really wanted was a language that would provide me a strong type system. So when evaluating what to use, I considered Go, Swift and Rust.

Go

Go is a great language, and althought I do not have experience previously building with it, I could have easily learned as Go’s main mantra is to be have a simple syntax, a pre-defined pattern around things, not a very large standard library and be easy for someone new to pick it up. Also, the syntax did not satisfy my petty personal tastes at the time, though I admit I could get over it.

Go does have its positives though, it has a very active community around it, with many projects and many companies adopting it, I would say its turning into the new language of choice for startups, taking Ruby’s place.

Swift

Swift is great, I am using it for the mobile app and it would possibly be a very pleasant experience writing both the client and server in Swift. However, the swift server side ecosystem is very small and has a few frameworks that do not seem to be used by many projects and teams, althought some frameworks do seem to have most of the depenedencies needed to successfully write a server. In addition to that, Swift is also does not have very strong support for development beyond Apple things, for example, there is no swift default code formatter.

Rust

I had a little bit of experience with Rust, so I might have been biased. Rust has excelled at everything that I wanted, it has allowed me to write code that documents itself, I did many refactorings along the journey of writing it and was always able to get everything working again without major problems.

Rust has empowered me to become a better software engineer, it’s helped me see how important memory management is in a program. Also, I have learned a ton of SQL over the past months due to Diesel (Rust’s main ORM framework) requiring us to write our migrations in pure SQL rather than Rust. In addition to that, I learned a lot about better abstractions, error handling and type systems.

While most of it is goodness, there are the bad parts about using Rust. As usual there are trade-offs, Rust can help you a lot while developing by providing you with an extra co-worker (Rust compiler), but this co-worker takes time to think and if you don’t have a very good computer, it will take a little while to compile, Bipa’s server takes about 40 min for the Dockerfile to build and compile the binary.

Conclusion

Overall, I think I would not have been able to write all the features needed in just over 90 days if I dindn’t have Rust and its compiler. Or maybe I would, but I am sure they would be a lot more buggy than they are, using rust has allowed me to be confident on my software, even though I understand that there are probably still bugs out there for me to find.

I would strongly recommend Rust for anyone looking to write a web server, you will not be disappointed with your experience (apart from the compile times).

--

--