DEV Community


what's the advantage of golang instead of java or C# ?

・2 min read

There are a few reasons why I prefer Go over Java and C#, not least of which is the standard library. You can install plenty of packages to do almost anything you want, but Go's standard library is minimalistic and very readable (what is golang?).

The big advantage of golang is that the code is less verbose and easier to read and write. The syntax is easier than java, and borrowing some syntax from python make it more natural for me than C#.

package main

import "fmt"

func main() {
    fmt.Println("Hello World!")
Enter fullscreen mode Exit fullscreen mode

What is Go?

Go is a programming language (golang) with a culture that is growing out of the love for software tooling. I'll say that again. Go was built from ground up with the singular purpose of creating an ecosystem of reusable tooling that serves as the foundation for the language itself.

Go is a language that is powerful enough to be the foundation of such things as the Docker system, but simple enough that you can learn it quickly.

Why Go?

To be honest, the real reason I start to use golang is that it's supported by Heroku (and has a free tier) and DigitalOcean (not free). That make it very easy to try, with almost no cost.

If you try go in production, you'll probably have a little cost. At least it's possible to pay 0 if you're lucky (0$/month and 0$/hour for its free plan) and that's great.

Go is also very easy to learn if you know another language such as java or C#.

Go is really focused on back-end development. For front-end you can use something like Angular or Vue

Discussion (5)

ahferroin7 profile image
Austin S. Hemmelgarn

There’s another huge advantage to Go over C# and Java that I often do not see mentioned: It does not require a special runtime on the target system.

Java needs a JVM install, C# needs a CLR install (usually .NET, sometimes Mono), but if you build things right, Go needs absolutely nothing beyond the basic OS.

rhyek profile image
Carlos González

Not sure about Java, but dotnet apps can be self-contained (they include the runtime) and you can now do trimming to lower the resulting file size somewhat. Nevertheless, this is usually not a concern since having a runtime ready to run your compiled application is pretty much a ubiquitous practice empowered by docker.

jcbritobr profile image
Júlio César de Brito Gardona • Edited

Its a different thing. Golang compile directly to machine code. Self contained executables in dotnet uses the clr embedded to final deploy. Go solution is very small and statically compiled.

avinersan profile image
Andrei Vinersan

My opinion is that go is most of the time better performing out of the box although .net core 5 might be quite close.
However I think that go is way more verbose and has way less features/extensibility.
Major things that I lack in go are generics, typed attributes/annotations, DI, linq, automatic open api (swagger) generation based on types (Goa is probably closest but not the same), extension methods, object equality/hashing override, string interpolation and there are probably many others.

On the other hand go arguably offers a nicer experience with goroutines (no need to spread async/await everywhere) and is probably easier to learn as it has less features.

patarapolw profile image
Pacharapol Withayasakpunt

You can use a Dockerfile in Heroku as well. No need for buildpacks.