News for hackers. Stuff that matters.
Re:Go memory ballast: How I learnt to stop worrying and love... by jerf on Monday December 02, 2019 @09:44AM (#21682701)
"> interface{}

I certainly agree on this one. It is a weird feature and often a 'smell' when found in Go code."

The feature itself is not a problem. Every major static language has the equivalent. It's often called something that involves the word "dynamic".

Having programmed in Go for many years now, I don't find myself using it very often in my own code. I've come to think of this as something said by either people who have never used Go at all, or people who used Go briefly but insisted on programming Javascript-in-Go or something. The latter is definitely a Bad Time... but it's always bad to program X-in-Y. If your code is shot through with interface{}, you either chose Go for something way outside of its domain, or you are not using it correctly.

"> comments that affect code generation

I agree that they should have introduced syntax for this, assuming you mean compiler flags (or w/e they're called)."

This is another criticism that I think mostly comes from people with a checklist criticism set of Go, because in practice, this is of negligible concern. It doesn't come up often, it isn't proliferating (i.e., it's not like with every point release we get another two or three new kinds of comments), it's literally never been an issue of any kind for me in the last six years. It's a complete non-issue. I am far more annoyed by, say, the fact godoc doesn't give me basic markdown than comments affecting compilation has ever annoyed me, and that's just an occasional minor annoyance.

Re:Go memory ballast: How I learnt to stop worrying and love... by _ph_ on Monday December 02, 2019 @10:17AM (#21683057)
I think interface{} is a great feature, when you want to write code that safely handles any type. fmt.Printf is a great example for this. As type information is attached with the value, type safety is fully maintained when casting the contained value back to its right type.

Where it is appropriate, it is a very cool thing that you can have fully dynamically typed variables with all safeties in place. Of course, it shouldn't be used in place of better abstractions, like specific interfaces or properly factored code.

Re:Go memory ballast: How I learnt to stop worrying and love... by dgb23 on Monday December 02, 2019 @11:37AM (#21683994)
> It's a complete non-issue.

It is an issue as someone who doesn't write Go code often but occasionally reads/debugs it. At least for the first couple of times I've come across it made me scratch my head for a couple of hours, because I didn't see what the issue was it being 'hidden' in the comments. Which is fine. It just isn't in line with the general premise of Go's language design, so I wasn't even expecting it. So in a sense you are right!