Why Go

Posted by Keal on October 15, 2025

最近很容易被问到这个问题, 让我们来看看网友是怎么说的.

Reddit

截取来自reddit上网友回答的问题Why Go

高赞回答1:

In the company I work for our main product is written in Java. It’s a big jumbo monolith that runs with a lot of resources and takes ages to build etc. And it works, it does its job well and does it fast.

However all our new modules are being written in Go. To solve a few of the issues the java is having.

Our go programs compile down to a single binary that we can throw in a tiny container. We can then spin it up in kubernetes pod with a few resources and if it needs more we ask kubernetes to spin up more. So we have better resource usage. And we can let kubernetes do all it’s magic and we don’t have to care much.

We can also do our builds in a matter of seconds. Speeding up development etc.

Now I know I know. Java can run on small low resource containers too. And if you put effort in you can speed up builds etc. We do all that, but that’s time away from actually making our product.

Go was designed for creating small microservices and so does it well. All its tooling and best practices are made with this in mind. Java was built to run on big jumbo machines with all the memory and CPU it wants! All its best practices are designed around the fact that a big jumbo machine runs everything. So it has to be shoe-horned and stomped on to get away from that.

Go was designed from the ground up to be used for microservices, so goes that path easily. Java was designed for giant enterprise mainframe shit, so fights you every step if that’s not what you’re doing.

Why should YOU choose Go? You probably shouldn’t, you know Java and if you like it then work away. Your probably not too worried about running microservices in kubernetes.

I used Go for the first time 6 years ago and fell in love. Use it for all my personal projects now. So if you want to try something new, give it a whirl. You might like it.

The advantage of being designed to run small self contained binaries is it runs really well on your laptop without hogging all the resources. So it’s a dream for small projects.

主要想说的是Go更适合小型服务或项目,尤其是微服务架构下Go很适合,而Java是为大型机器设计的.

我认为这基本合理, Go在小型服务上的资源消耗和性能上面更容易发挥出性价比. 并不是说其他语言不能, Python有协程, Java也有虚拟线程, 但Go在这件事上对开发人员更友好

高赞回答2:

As someone who was recently moved from Java to Go, I can say that Go has the following “wins”:

  • In Go, it is much harder to create footguns. Go pushes you into simpler code and forces composition-over-inheritance. In Java, inexperienced devs will create crazy inheritance trees, abuse generics e.g Request<K,T,W>, over complicate DI, over use annotations and what not.
  • Go scales easily to millions of network connections per box and allows for better utilization of hardware **without any effort to optimize **. You can reach good hardware optimization in Java as well but that requires using reactive programming (which makes things much harder) or waiting for Loom to become mainstream.
  • some situational “wins” that might not mean anything to you but could be very important:
  • Go uses much less memory then Java (until Valhalla drops). Not everything is a pointer and memory usage is better
  • Go compiles faster
  • No warmup time for starting apps (AppCDS exists but I haven’t used it)
  • binary size is smaller)
  • Java does not come “with batteries included”. In 2023 you must have knowledge with some build tool. Go build tools are trivial to pick up

简单梳理就是:

  1. Go语法更简单,不容易犯错
  2. Go更容易充分利用硬件资源
  3. Go的内存使用比Java少
  4. GO编译更快,构建更简单

我认为这几点都算的上好优点, 语法简单,减少了奇怪的表达方式,就减少了出错的机会,也减少了review的成本(当然现在有AI的情况下,review成本已经降低很多). 占用资源少且能充分利用硬件资源,在可拓展项目上更能发挥优势,毕竟当你的服务需要巨大的资源时,任何节省资源的方式都将节省巨额的资源费用,不是吗?