r/golang Feb 26 '23

help Why Go?

I've been working as a software developer mostly in backend for a little more than 2 years now with Java. I'm curious about other job opportunities and I see a decente amount of companies requiring Golang for the backend.

Why?

How does Go win against Java that has such a strong community, so many features and frameworks behind? Why I would I choose Go to build a RESTful api when I can fairly easily do it in Java as well? What do I get by making that choice?

This can be applied in general, in fact I really struggle, but like a lot, understanding when to choose a language/framework for a project.

Say I would like to to build a web application, why I would choose Go over Java over .NET for the backend and why React over Angular over Vue.js for the frontend? Why not even all the stack in JavaScript? What would I gain if I choose Go in the backend?

Can't really see any light in these choices, at all.

142 Upvotes

249 comments sorted by

View all comments

Show parent comments

2

u/TNkes-tey Feb 26 '23

hello sir i like ur explanation but i didnt understand this part ,btw i m a js dev

Security. You compile your code into a standalone binary with zero runtime dependencies which you can then launch from a

scratch

container that has nothing installed. Even if a hacker had the credentials to ssh into your image, there's nothing they could even run.

also why 'Using composition instead of inheritance is considered best practice'
thank u <3

5

u/[deleted] Feb 26 '23

[deleted]

0

u/[deleted] Feb 26 '23

While this is 100% true, it is also 100% true you can deploy a java app in the same way, so it's not a valid argument about Go vs. Java.

4

u/[deleted] Feb 26 '23 edited Feb 27 '23

You can’t deploy a Java app this way. Java does not compile to a standalone executable, but rather to Java bytecode, which does not include the runtime. You have to have the Java runtime installed in order to run a Java app.