Over the past few weeks we have cleaned up the addictions of our Swift Talk backend. Now that we are done, we finally feel that we are at the top of the code base again. No more dark, dusty corners!
In this post, we will outline how the codebase has evolved over time, and the changes we have made to clean it up.
We started developing the Swift Talk backend almost three and a half years ago. To begin with, we hired a contractor to build the site using Ruby on Rails. After we launched, we continued making small changes ourselves and hiring other entrepreneurs for bigger things.
.js files as before, only from our Swift server.
A few things bothered us about the state of this codebase:
Some of the Swift dependencies felt unnecessary, given the small code it would take us to directly interface with the underlying libraries.
When it comes to Swift dependencies, we ended up writing our own lightweight cover around libpq, similar to the wrapper we demonstrated on Swift Talk. Our wrapper is about 300 lines of code, almost half of which are simple mechanical conversions between Swift types and their representations in PostgreSQL. We are happy to maintain this little piece of code against a mature library like libpq itself. The advantage is that we can easily fix warnings that occur with new Swift versions, fix bugs when we meet them, or make changes to the API to better suit our needs.
We also removed our dependence on BlueCryptor, a Swift wrap around CommonCrypto on macOS and libcrypto on Linux. Since we only used it to create md5 hashes for our assets, we wrote our own md5 wrapper around the native crypto libraries, with about 30 code lines.
Before, we used Perfect XML to parse XML on Linux, as the Foundation's XML parsing gave us strange crashes. In recent releases, these issues have been resolved, and we managed to release addiction and use the Foundation instead.
We took a long look at CSS and also managed to remove almost all dependencies.
To check out the backend, the source code is on GitHub.