News for hackers. Stuff that matters.

Ask HN: What's the big deal with Go (Golang)?

Looking to the wisdom of the masses here, and trying to understand the use case for Go (as opposed to other languages).

I have heard that it has faster compile times. I have heard that it's low-level. But I don't get why I should choose it over a language that I enjoy, such as C++ (for low-level control, particularly the modern incarnations of it).

Can you help me to understand what the killer feature of Go is and under what circumstances I should consider using it? Likewise, what would be a poor application of the language?

(Context: I'm not necessarily a language snob. I use C++, Python, JavaScript, Java, etc., and I know which I prefer for solving particular types of problems. I just don't understand why I might need Go. There's a longer story as to why I'm so concerned about using it or not, but that is for another time.)

Thanks for your comments!

( 19 comments | 3 points | on HN )
Re:Ask HN: What's the big deal with Go (Golang)? by PaulHoule on Wednesday October 11, 2023 @06:12PM (#37850971)
Compile time is a ‘killer’ app for some. Organizations like Google and Lockheed Martin have C++ code bases that take 40+ minutes to compile. If you are in that situation it’s fair to put that attribute ahead of everything else.
Re:Ask HN: What's the big deal with Go (Golang)? by gjvc on Wednesday October 11, 2023 @06:18PM (#37851034)
Re:Ask HN: What's the big deal with Go (Golang)? by PaulHoule on Wednesday October 11, 2023 @06:33PM (#37851202)
I don’t know about that one but I’ve seen other caching systems in place where people had been going in circles for 18 months and couldn’t give instructions as to how to build the system reliably and my first step was to clear everything out and start from zero because slow progress is better than no progress.
Re:Ask HN: What's the big deal with Go (Golang)? by gjvc on Saturday October 14, 2023 @06:19AM (#37879388)
don't tar everything with the same brush.

as an aside, passing unique build / vcs / version ids as preprocessor directives are a great way to stymie these kind of systems.

Re:Ask HN: What's the big deal with Go (Golang)? by gogogo_allday on Wednesday October 11, 2023 @07:32PM (#37851738)
Here are the reasons I chose it for a few projects: single binary distribution; easy concurrency; low system overhead; small language; garbage collection; semver respect; and opinionated styling.

I used it for pushing data around on a server and a cli. The easy concurrency was the killer feature for the server, and single binary distribution for the cli.

Re:Ask HN: What's the big deal with Go (Golang)? by codegeek on Wednesday October 11, 2023 @07:44PM (#37851824)
I am not a Go expert but have built a couple of internal tools for the company and what I like most about Go is the simplicity of code. At least for me, Go code is just plain simple and beautiful to write. I can code in PHP (experienced), C# .NET (newbie) and did C++ and Java in college. Something about Go just feels so easy to me. Btw, I also like the whole explicit error handling in Go which others hate.

Another thing about Go is that it is a balanced language in my opinion (both high and low level depending on use case). You can build a cli, a full stack web app or write low level network code. I love it.

Re:Ask HN: What's the big deal with Go (Golang)? by donatj on Wednesday October 11, 2023 @08:17PM (#37852058)
The language is very simple which makes developing it with a team much simpler. Everyone writes code the same way, because for the most part there's one right way to do things, which makes code review a lot easier.

For the most part, the build process is very simple, no "dll hell".

Very stable API. With the Go 1 promise, code written 10 years ago still just works.

Others mentioned the statically linked binaries. That's huge. We compile a binary targeting Linux, throw it in s3, that gets pulled to production. Whole thing just works. No dependencies.

Re:Ask HN: What's the big deal with Go (Golang)? by revskill on Wednesday October 11, 2023 @08:49PM (#37852236)
To maintain Kubernetes.
Re:Ask HN: What's the big deal with Go (Golang)? by dgunay on Wednesday October 11, 2023 @09:12PM (#37852368)
Versus C++? I have many gripes with Go but I'd choose Go over C++ for a lot of uncomplicated stuff like backend web services that just have to have "pretty good" performance. Faster than Python, slower than C++, but not by much.

Killer "features" of Go:

  - Very easy to get someone up to speed on it. I chuckle when I see positions advertised as "preferring Go experience". A good programmer can learn most of Go's features in a month.
  - Makes a lot of "magic" impossible or so annoying as to be not worth writing. This means you can usually just read your dependencies' source code to easily figure out what they're doing. Nearly all Go code looks the same.
  - Languages like e.g. Rust attempt to actually model certain problems accurately, which introduces a lot of unavoidable complexity. Go does not bother itself with such concerns as "correctness" in many cases. I sound snide but for many use cases this is the right move.
  - Go moves slower and has a commitment to backwards compatibility that many other languages don't.
Re:Ask HN: What's the big deal with Go (Golang)? by joshxyz on Wednesday October 11, 2023 @09:28PM (#37852441)
depends on the goal really.

writing fronttend backend web apps? id go with typescript for react and nodejs.

writing scale efficient backend services, go or kotlin or java makes sense.

writing performance freak modules and software or embeddes or similar, go rust or cpp or c.

you wanna get down to the trade offs. where are you exactly in the stage of development, who your users are, the platforms you are targetting, such and such.

i use typescript. but my ts code imports uwebsockets.js which lets me use a web server written in cpp and c. for caching we use redis. for routing we use caddy.

you wanna take advantage of other languages and premade solutions by other people on where they excell.

Re:Ask HN: What's the big deal with Go (Golang)? by _thinx on Wednesday October 11, 2023 @10:02PM (#37852673)
do self-research first[1], then, give it a try. small pet project should be. if it really fit your taste. go with it.

[1] https://go.dev/solutions/

Re:Ask HN: What's the big deal with Go (Golang)? by atmosx on Thursday October 12, 2023 @12:02AM (#37853371)
By all means, use C++. No need to use something you don’t enjoy.

A poor application of Golang that I have seen are full featured web frameworks like the ones you find in interpreted languages (Rails, Django, Lavarel, Phoenix, etc).

I feel like Ruby and Python are better & easier for applications that perform text ETL, text scraping, etc.

Re:Ask HN: What's the big deal with Go (Golang)? by cqiDFbfRUggaQph on Thursday October 12, 2023 @12:50AM (#37853570)
As someone who has spent 9 years working on Go: - Self managed thread pool, Go routines are transposed onto threads. - Channels for thread synchronization. The Select block lets you efficiently block a routine until one of multiple channels return. - Fast compile times, fast execution. - Type safety and garbage collection. - Modern types like slices. You only have to check for nils when you explicitly use pointers. len([]byte(nil)) doesn't panic. - First class Unicode support. - Best date/time library I've used (sorry Python but you need timezones). - Builtin tooling for testing, benchmarking, standard formatting and dependency management. - Best package manager I've used. They force you do things their way but it's worth it IMO. All packages have a canonical URL that's explicitly referenced in code. - Supply chain protection for dependencies. - Dependencies are statically linked for easy distribution. - Great standard library with no breaking changes over the last 10 years. (Pretty sure)

At the end of the day though, use whatever works for your style. C++ isn't going anywhere. But I am noticing a lot of people talking about the importance of type safety when Rust development was allowed in the Linux kernel.

Re:Ask HN: What's the big deal with Go (Golang)? by cookiengineer on Thursday October 12, 2023 @01:38AM (#37853784)
From a pentester's perspective:

- CGo as a bridge between C and Go/VM world

- go:embed and go:generate for bindings, preshipped modules and assets

- 100% static binary as simple as an environment flag

- golang compiler is self hosted in go, which means you can make malware that can make malware :)

- pretty much all operating systems or as close to it, without any host system requirement and neither dozens of compiler environments with outdated SDK headers

- go assembler, which ironically makes this the best language for malware development

- batteries included language, use golang.org/x and that is almost always anything you will ever need

- can be typesafe but also not ("unsafe" package), which is important for exploit development

- doesn't need 2 Million string abstractions (just kidding, rusties)

From a software architect's perspective:

- VERY opinionated language design, you have to set aside your personal opinion to be able to like it

- generics took a long while, now they're here but you still have to implement all yourself. Not there yet with forEach, map, reduce etc.

- Uppercase for export was a dumb decision, because serializer specific annotations to map field names is an effect for that cause

- standard formatting guidelines, use go fmt, don't use semicolons because nobody does

- for loops everywhere, which can be bad for readability compared to forEach() scopes

Re:Ask HN: What's the big deal with Go (Golang)? by AnimalMuppet on Thursday October 12, 2023 @09:00AM (#37856581)
Depends on what kind of C++ you're writing.

Interfacing to hardware? Bit-flipping in registers on a peripheral chip? I'd use C++ for that.

Something with lots of dynamic memory usage? I'd at least consider Go because of the garbage collection. That makes an entire set of problems just go away.

Something with a ton of network connections? Again, I'd consider Go.

Something where I need the last drop of performance? C++.

Re:Ask HN: What's the big deal with Go (Golang)? by fyzix on Thursday October 12, 2023 @07:41PM (#37864606)
Fast compilation, Fast runtime, Easy to learn, Easy to distribute, Easy concurrency.

ps: I wrote a data processing benchmark[1] and go is currently leading the charts. I ported it to c++ but it's not performing as expected. Take a look if you have the time.

[1]: https://github.com/jinyus/related_post_gen

Re:Ask HN: What's the big deal with Go (Golang)? by drakonka on Friday October 13, 2023 @09:45AM (#37870534)
If you enjoy C++ and are productive with it, I don't think there's any need to force yourself to use Go unless you for some reason feel that's a more lucrative job market. I much prefer working with Go over C++. Its test tooling, straightforward syntax, strong opinions, and lack of clutter makes it efficient and enjoyable for me.
Re:Ask HN: What's the big deal with Go (Golang)? by tmaly on Friday October 13, 2023 @12:31PM (#37872424)
For me, there are three things that make it a great language.

1. simple syntax, you can pick up the language quickly and reading code is easy.

2. backward compatibility for 1.0. This has made it easy to just recompile and get any compiler performance improvements.

3. batteries included standard library. Testing, benchmarking, json, xml, http server all build into the standard library

Re:Ask HN: What's the big deal with Go (Golang)? by almatabata on Friday October 13, 2023 @04:47PM (#37875444)
I love it in the context of hacking actually. When working on HackTheBox machines or other CTFs you sometimes need to deploy tools onto the machine like these:

https://github.com/jpillora/chisel https://github.com/DominicBreuker/pspy

When you deploy them they just work. Compare that to compiled C++ code you often face issues with the deployment in my experience. And production machines usually do not ship compilers.