Live data from Hacker News

Why I Don't Like Golang (2016)

teamten.com

41–50 of 237 posts

Re: Why I Don't Like Golang (2016)

#41
post #19

> if I name my source file i_love_linux.go, it won’t get compiled on my Mac What the fuck?

Others already explained why.

Now a bit more background, this goes back to C and C++, and is considered a best practice to name translation units as name_os_arch or similar pattern, with the header file being only name, instead of #ifdef spaghetti.

This is actually one of the few things I think Go did right.

Re: Why I Don't Like Golang (2016)

#42
post #5

They've fixed the import / modules situation to a point where it's usable and much improved, and generics have been added. However, the issue this brings up about structs / types not explicitly declaring which interfaces they implement is a real and unaddressed problem, especially in large codebases. The only tool that I'm aware of that finds implementations is GoLand, at steep JetBrains prices. Figuring out what typ…

I highly disagree with the interfaces criticism.

Firstly You can literally just use one of the dozens of go lsps or code tools to search for API invocations to find what structs are passed/called into it. More importantly if you need to know you've written bad code. The entire point of an interface is that you SHOULDN'T need to know the underlying type. If you do you've violated the entire point. Just pass concrete ones. I've written Go for years and never had a problem with this, even in large open source projects like Kuberenetes.

Secondly, the criticism about flipping return values order/meaning isn't a criticism of interface being structurally typed (https://en.wikipedia.org/wiki/Structural_type_system). If you return int, int and the second int "should be even", you should have defined a type "Even" and returned int, Even*. Systems which are structurally typed can demonstrate functional extensionality and (https://github.com/FStarLang/FStar/wiki/SMT-Equality-and-Ext...) and check whether you've flipped the arguments, which would be a more valid criticism (but such checks are expensive and conflict with compile time requirements). Also Java has the same problem, if you define two interfaces with the same method signature and a single class implements both you can't disambiguate.

Thirdly, the structural typing has a huge advantage, namely looser coupling and more tightly defined interfaces. If you follow the "accept interfaces return structs" go idiom, you'll see why. An open source library that does so leaves their returned structs open to be used by consumer code, that itself uses interfaces, without modification required. This means most go code has small, tightly defined interfaces, where every function on the interface is invoked in the relevant function.

For example if you have a library with this definition:

type Baz struct {}

func (b Baz) Foo(){} func (b Baz) Bar(){}

I can use Baz in my code like so:

type Fooer interface { Foo() }

func DoSomething(f Fooer) { }

And use the underlying library, while being decoupled from it, without having to modify it.

Fourthly: You can explicitly say a type implements an interface...

* A good study: https://blog.boot.dev/golang/golang-interfaces/

* In Idris we would do:

even : Nat -> Bool even Z = True even (S k) = odd k where odd Z = False odd (S k) = even k

int -> even doubler a = 2 * a

Re: Why I Don't Like Golang (2016)

#43
post #31
post #19

> if I name my source file i_love_linux.go, it won’t get compiled on my Mac What the fuck?

Explanation from a previous discussion - https://news.ycombinator.com/item?id=16414435 ...seriously wtf

In 5 years of writing to code this has never prevented me from naming a file what I wanted to name it. I enforced conventions are nice, when I need to look at what’s different between platforms I can very quickly do so in any large repo.

Re: Why I Don't Like Golang (2016)

#44

As a new Go user I seriously don't get the hype. It feels like C with some (not many) niceties thrown on top, that's not what we expect from high level languages. I am still waiting for the tada moment, hope it comes.

What are you using it for?

Crud APIs...

Re: Why I Don't Like Golang (2016)

#46

As a new Go user I seriously don't get the hype. It feels like C with some (not many) niceties thrown on top, that's not what we expect from high level languages. I am still waiting for the tada moment, hope it comes.

I don't want to spill the beans here, and well: you figured it already out by yourself.

Re: Why I Don't Like Golang (2016)

#47
post #7
post #5

They've fixed the import / modules situation to a point where it's usable and much improved, and generics have been added. However, the issue this brings up about structs / types not explicitly declaring which interfaces they implement is a real and unaddressed problem, especially in large codebases. The only tool that I'm aware of that finds implementations is GoLand, at steep JetBrains prices. Figuring out what typ…

When developers who usually make 6 figures of money complain about $90/yr IDE price I just cannot help laugh. Actually it's even better... the price elevators down from $90 -> year2 90 - 20% -> year3 90 - 40%. Over three years that's like $150-$200 total and it will save you so many headaches. But that's a steep price? Are you kidding? Why do developers hate tools that cost money when they save them time and allow th…

I'm shocked at how often I see software engineers not paying for Sublime Text. These are people who get paid to write software not paying for software.

Re: Why I Don't Like Golang (2016)

#48

> There’s no ternary (?:) operator. Every C-like language has had this, and I miss it every day that I program in Go. The language is removing functional idioms right when everyone is agreeing that these are useful. And everyone agreed so hard that it was removed from almost every modern C replacement (Rust, Nim, Zig, Elixir, Kotlin).

Elixir has the if-else being an expression.

foo = if x, do: 1, else: 2

Re: Why I Don't Like Golang (2016)

#50

Earlier quoted context omitted.

What are you using it for?

Crud APIs...

IMO it’ll be slower to write crud apis and there are some missing batteries you have to look for, it’s fairly verbose but I think some of that will change with generics and hopefully more pattern matching.

On the flip side when you deploy it, it will like just work and run smoothly. Also very easy to add full integration tests as you can create a mock http server at runtime, paired with some db tools (go migrate) it’s very easy spin up a whole env and test it. It’s also very easy to get at lower level things like headers and cookies without it getting in the way. Also much of the web middleware is interchangeable or a few lines away from an adapter as there is a common interface in the std lib.

Post reply on HN