Live data from Hacker News

Go Replaces Interface{} with 'Any'

github.com

111–120 of 481 posts

Re: Go Replaces Interface{} with 'Any'

#111
post #68

After generics (coming soon), a proper sum type and then I'll shut up.

same :) maybe also relax rules a bit to allow type elision for structs in function calls to get python like keyword args. foo("blah", {option1: true}) would work better than functional options people use now.

I think they should freeze the language for the next 10 years or so.

Re: Go Replaces Interface{} with 'Any'

#112
post #88
post #63

Earlier quoted context omitted.

Well it's better than most language with exceptions. People makes it a big deal, in reality it's not.

An exception has a stacktrace. This single piece of information is crucial when you debug and makes handling errors in Golang embarrassing. I rest my case.

If you want stacktraces just panic. But that's not proper error handling.

Re: Go Replaces Interface{} with 'Any'

#113

Earlier quoted context omitted.

Lol so true, go a little overboard with fancy language features and people think you’re a cowboy coder

I was in an interview not long after format strings in Python came out (for example, print(f”Hello, {name}”) rather than print(“Hello, %s”, name)) and the interviewer thought I was confusing languages and features, asserted this fact strongly, and was pretty surprised when it worked, but I think overall I lost points because the interviewer lost face. C’est la vie.

As a very casual Python user, I didn't know about that! that's great.

Re: Go Replaces Interface{} with 'Any'

#114

Earlier quoted context omitted.

0ver is parody, right?

Yes - https://0ver.org/about.html “ZeroVer is satire, please do not use it”

But why is it satire? It makes a lot of sense for projects that don't want to commit to a stable API.

Re: Go Replaces Interface{} with 'Any'

#115

Earlier quoted context omitted.

Doesn’t it? Is this new?

As far as I know this was always possible since modules were introduced. You just have to prefix the version tags for Go with the subdirectory in the repo: "my/sub/directory/vX.Y.Z"

I swear it didn’t always work this way, but I’m happy to be wrong.

Re: Go Replaces Interface{} with 'Any'

#116
post #71
post #36

Earlier quoted context omitted.

Typescript is stricter and safer while also being less obtrusive than Go

Any language based on JS can't be safer than Go. The end result of TS is JS which is a dynamic language.

Ok, so if Go compiled to JS it would be a dynamic language?

https://github.com/gopherjs/gopherjs

Re: Go Replaces Interface{} with 'Any'

#117
post #65

Their code is full of things like: type fileOps []any // []T where T is (string | int64) Go does not have neither generics nor union types. So people have to do this kind of thing :( I feel sorry for them. Reminds of Java 4 (15 years ago or something) where code was full of this crap: List /* */ values; Map /* */ map; Some devs spent a whole week doing nothing other than removing those commented out generic type decl…

> I feel sorry for them. Oh good grief. There are 32,768 programming languages. People are free to pick the ones they want to use and nobody wants your pity.

Are we wasting that bit to spite us?

Re: Go Replaces Interface{} with 'Any'

#118
post #55
post #21

Ball is in your court now typescript-on-the-serverside ppl!

I didn't realize there was a "war" going on between the two groups. If there is, I imagine it's not among the type of people who you'd want leading technical decisions at your company.

There isn't. What I have noticed in the go community is a rabid fandom and belief that golang is the pinnacle of language design when in reality go is a language for people that think memorizing a few syntactical rules is too difficult. People used to rabidly defend the lack of generics for example and look at where we are now.

And before people identify me as a TS fanboy, I'm not, I'm a go hater.

Re: Go Replaces Interface{} with 'Any'

#119

I'm not sure I like this change. I liked interface{} since it just works out naturally from Go's relatively simple type system, and anyone could come to the conclusion without actually being told "use interface{} to represent any possible value" just by having an understanding of that type system. Adding what is simply a type alias, multiple words for the same underlying concept, to me just feels like jargon. I admir…

I don’t think the concern is unreasonable at all but ‘any’ feels pretty solid as far as I’ve had the chance to poke around. There’s some tensions where I think ‘any’ is arguably much simpler:

The baseline is that constraints aren’t best expressed as interface literals in situ. Unlike exceptional use of ‘interface{}’, ‘any’ will be a more naturally invoked constraint.

Also, some of the uses of constraints rely on a unification involving an ‘any’ term that cancels out. Here, the use of ‘interface{}’ is not incorrect but maybe indirect.

Re: Go Replaces Interface{} with 'Any'

#120
post #71
post #36

Earlier quoted context omitted.

Typescript is stricter and safer while also being less obtrusive than Go

Any language based on JS can't be safer than Go. The end result of TS is JS which is a dynamic language.

That's absurd. If TS can't be secure because it compiles to an unsafe language (JS), Go can't be secure because it compiles to unsafe assembly.
Post reply on HN