News for hackers. Stuff that matters.
Re:What makes you enjoy Go lang? by tail_exchange on Monday April 24, 2023 @06:59PM (#35694398)
Things I love about it:

- gofmt. The fact that it comes with an opinionated formatter means I don't waste time with bikeshedding.

- Simplicity. I love how Go just gets out of my way and lets me do my work. I also don't need to worry about crazy abstractions and deep levels of inheritance.

- I usually don't need to worry about performance bottlenecks. Go is pretty fast.

- Typed. Over time I ended up hating languages like Python and JavaScript because of the lack of typing. Typed languages let me catch a large amount of errors at compile-time, and it also serves as documentation.

- Go-routines are a very elegant way to deal with concurrency.

- The standard library has a great selection of tools like JSON parsing that are usually not native in other languages.

- Dependency management is pretty good. Not the best, but definitely better than languages like C++.

- Single binaries. You can compile a Go application into a single binary and have it as the entry point of a container. The result are very small containers that start up very quickly.

Thing I don't like about it:

- Error handling got better over time, but it's still annoying to find out if an error is of a specific type in legacy code.

- It would be nice to have more built-ins for lists, such as .includes(), .filter(), .map(), etc.

- Nil pointers. It would be great if there was a way to ensure points will never be nil.

I was really skeptical about it at first, but it quickly became my favourite language.

Re:What makes you enjoy Go lang? by Tozen on Monday April 24, 2023 @10:47PM (#35695995)
Some good points are presented. Interestingly, Vlang (https://vlang.io/) has the .filter(), .map(), etc... and addresses Nil/Null (relegating it to unsafe). Error handling is done differently (with many liking that style), but this point tends towards a programmer's preferences.
Re:What makes you enjoy Go lang? by cookiengineer on Tuesday April 25, 2023 @12:40AM (#35696549)
I would want to add to the above list:

- I love golang's build toolchain. Cross-compilation is just an environment variable.

- I love its go:embed functionality, as it removes the necessity of crappy squashfs based solutions, and allows embedding all assets e.g. a webserver/website needs.

- What I both like and dislike: Marshalling. It can be a joy to use marshalling when you are in control of the data structures, but it also can be PITA when you have to parse external JSON data structures that do not conform to the same types.

Something like parsing a package.json, where fields can be e.g. a string, an array of objects or a single object is real pain to do in golang because it requires to use the reflections API.

Re:What makes you enjoy Go lang? by drakonka on Tuesday April 25, 2023 @04:43AM (#35697999)
All of this. Another thing I love is its test tooling and test conventions. Go makes it very intuitive, efficient, and (for me) fun to write tests early and often. _Not_ testing feels like a waste of really great tooling shipped right with the language.
Re:What makes you enjoy Go lang? by Alifatisk on Tuesday April 25, 2023 @08:06AM (#35699320)
Thank you for this comprehensive list, this made me more excited about the language.

These were the highlights for me: - Simplicity - Typed - Go-routines - Single binaries (Cross-compilation is just an environment variable)

> - Nil pointers. It would be great if there was a way to ensure points will never be nil.

Like Dart sound null safety?

Re:What makes you enjoy Go lang? by tail_exchange on Tuesday April 25, 2023 @09:21AM (#35700074)
I never used Dart, but from the examples I saw online, seems to check out.

Go is more similar to languages like C, where you use a * to declare a type as a pointer. So an int is just a value in the stack and cannot be null, but an *int is a pointer to somewhere in memory and can be null. It would be lovely to have a third option in this list, something like *int for non-nullable pointers and *int? for nullable pointers.

Re:What makes you enjoy Go lang? by DanielHB on Tuesday April 25, 2023 @08:26AM (#35699505)
> - Typed. Over time I ended up hating languages like Python and JavaScript because of the lack of typing. Typed languages let me catch a large amount of errors at compile-time, and it also serves as documentation.

Funny, I actually think golang typing to be extremely weak and hard to use, especially with all the pointers vs non-pointer values. Typescript is by far the best type system I ever used, but even compared to Java/C#/C++ the golang types are archaic and basic, more akin to ANSI C in power

Yes the types are better than dynamic languages, but compared to modern type systems it is not very good

Re:What makes you enjoy Go lang? by henhouse on Wednesday April 26, 2023 @06:18AM (#35711557)
There’s a great “lo” package which implements these JS-like array and map functions using generics in Go. Coming back from a JS/TS job I’ve been really happy to find this.