Build a simple microservice in three languages to have a solid baseline to compare implementation time.

Workflow

1. Download json data from reddit

2. Transform it to a different structure

3. Return transformed data

This is a very common pattern for microservices. Slightly bigger than a hello world and forces you to bump into some platform warts.

Summary

Golang is in a sweet spot of simple syntax, fast compiled language, rich standard library and age of platform. I would recommend it to any team looking to build on a solid platform.

Crystal is a beautiful language. The standard library is rich and well thought out. Type inference mostly just works. The size of the community, age of the language and issues teams have hit trying scale up to larger systems will keep me away from recommending it for anything other than side projects.

I want to like Rust. This is my second time implementing something in rust. They have done a great job writing documentation around the language. Rust book is massive. My main issue with rust comes when you start to wade outside the standard library.

You have to chose your own destiny on concurrency primitives, http clients, servers, routers even byte buffers come from external crates. Hopefully you pick libraries that work together. Good luck if your team goes through an open source audit.

Detailed thoughts on implementations

Rust

Rust requires a larger investment in time to get moving. Larger being defined as a hour or two of reading about memory management for a senior engineer will get you started. Errors are normally helpful at suggesting next steps.

Batteries were not included. Have to go out and decide which async library / http server is right for your project. To do this basic workflow brought in 150+ transitive dependencies.

Many of the code examples out there are using use xxx::*; which makes it hard to understand where things are coming from. Avoid use* while you are learning.

Originally tried to go with hyper http client until I realized hyper’s http examples don’t support https. Decided to go with reqwest but the current version of reqwest’s docs are broken.

Golang

Implementation-wise was pretty straight forward. Deep generic JSON access was really ugly and involved a lot of type casting. Went with a defined JSON type to clean up the code.

Go has a standard http server but routing is third party. Went with echo because the documentation and error handling was helpful. Used std JSON support but its known to be slow. Consider picking a third party library if your payloads are large.

Implementation brought in 11 transitive dependencies.

Note: Reddit seems to be blacklisting go’s http agent. Consistent 429s until I changed it.

Crystal

Youngest language. Smallest implementation. Code is very ruby like. I appreciate the JSON builder concept the standard library provides. Release build can spike in time to 5 seconds. Build time horror stories on reddit make me nervous about using it for anything serious.

Standard library wise similar situation to golang in that http server built in router is third party. Implementation brought in 4 transitive dependencies.