How I learned a programming language, and how I wrote a popular microservice framework.

·

3 min read

Learning

The programming language that I'm talking about is Go, but I think it's almost the same for most programming languages.

I've been coding for over 20 years since graduation. Before learning Go, I've used many programming languages for production, includes C, C++, C#, Java. Early in year 2013, I decided to learn Go.

I spent one day to read through Go syntax and keywords, and spent couple days to read the official docs and blogs. Effective Go is highly recommended if you’re learning Go. I think for most languages that we can start with the official documents, before reading some other books.

Using

After that, I started to write a small crawler project, and found that writing Go code was very comfortable for me, comparing the experiences that I got from other languages I’ve used.

Then I started to use Go to rewrite our production services, which were written in Java and PHP. From then on, I started to write the microservice framework. And In 2015, all our production services were transferred into Go. We have more than 30 million users and more than 3 million daily active users. In comparison with Java and PHP, we saved about 50% server/cloud cost.

In 2018, I joined another company, more than 50 million users and about 7 million daily active users. Because of lots of service downtime, I decided to rewrite the services with Go and my framework. We spent about 5 months to work on it, and we got uptime better than 99.99%. Also, we worked out some dev tools that helped us improved much productivity.

For the rewriting, there are some more considerations to use Go and let our devs to transfer from Java to Go:

  1. All our existing code was in Java, and no one can tell how it was organized. When server was hung, everyone told to restart, no root causes for most problems.
  2. I decided to rewrite the whole system, and change to another programming language, to avoid copy/paste from the previous code base.
  3. We have tens of millions of users, the server cost was a very important concern against Java.

Open source

All the framework and tools are open sourced in GitHub in later 2020. Until now, lots of users and feedbacks helped us improved pretty much. And 16.1k stars 2.2k forks for about 1.5 years.

https://github.com/zeromicro/go-zero

I made ~2k contributions on github in the last year. And I open sourced some other projects, all these efforts helped me a lot on both technical skills and job opportunities.

I really think writing open source project helps devs improve fast, especially for popular projects. Because lots of users review the code, give you feedbacks for better design, and much more.

Hope it helps!