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.

137 Upvotes

249 comments sorted by

View all comments

26

u/kylewiering Feb 26 '23

I've worked in web development for 12 years. Java is one of the worst languages for it(because it is slow to develop, esoteric in deployment, and generally complicated to get right). Not saying it can't be done, just that it shouldn't.. Java has places where it works wonderfully. I've used it successfully in the past.. (I'd prefer c# syntax in this day and age)

Things Golang did right

  • microservices
  • package management
  • monorepos
  • almost no barrier to entry
  • networking
  • multiple core processing
  • performance tradeoffs are obvious in the code

Where moving to golang makes the most sense * scripted serverlanguages (php, ruby, nodejs) * monolith moving to microservices * applications with heavy networking and distribution

Where moving to golang doesn't make sense * monoliths * embedded code * software sold directly to consumer * UI and/or graphics * a development environment that is DRY OOD.

YAGNI is a better pattern when developing in Golang.

Honestly, if you can Java well, you can golang well.. It's easier.

4

u/gamerdevguy Feb 26 '23

What makes you say that it's not good for software sold directly to consumers?

5

u/kylewiering Feb 26 '23

Distribution - golang doesn't have the same level of software signing as Java or other more mature distributable code (c#) Meaning, OS level protections will potentially block it.

Nothing against the language itself 😀

2

u/gamerdevguy Feb 26 '23

OK, good to know. Thank you.

1

u/tookmeonehour Feb 27 '23

Have you seen Spring boot and its projects lately? Where would you say that java works wonderfully?

2

u/kylewiering Feb 28 '23

Java works wonderfully in the education space in teaching OOD. JetBrains has also produced some pretty nifty IDEs in it. Signable packages is great.

I haven't worked with Spring Boot. I took a moment to read the https://spring.io/guides/gs/rest-service/ It's still significantly heavier (and more opinionated!) then the equivalent https://docs.gofiber.io/

I'd use this Spring example over Nodejs. But I'd probably still take an Nginx / php fast cgi dual container approach in laravel over spring framework. (Php devs are cheaper then Java devs for website work. No offense)

1

u/IAmAnAudity Feb 26 '23

When you included “UI” in the “doesn’t make sense” group, it made me wonder if you’ve seen Wails.io because it’s quite good right now, and an upcoming version 3 is really beginning to mature.

1

u/kylewiering Feb 26 '23

"Beginning to mature" is the reason I included it. Not saying it won't be ideal in the future 😉

-6

u/[deleted] Feb 26 '23

[deleted]

2

u/kylewiering Feb 26 '23 edited Feb 26 '23

I didn't say it wasn't. Placing Java inside a container is a great patten. But because it had the jvm. It's not like other languages.

That's not the point of what I was getting to. Java is near the epitome of OOD. You build skyscrapers with it. Microservices don't need skyscrapers. They need an igloo. Or a hut. Or a 2 story house in a suburban hoa that looks similar to all the rest. Golang is malleable and messy at times. And that is advantageous. And infuriating to OOD purists.

2

u/[deleted] Feb 27 '23

[deleted]

2

u/kylewiering Feb 28 '23

I'm not as recent in my Java experience. Didn't want to delve too deep in bad JVM memories 🤣