Live data from Hacker News

Go Replaces Interface{} with 'Any'

github.com

311–320 of 481 posts

Re: Go Replaces Interface{} with 'Any'

#311
post #295

Earlier quoted context omitted.

Java 10 introduced "var", which broke code with variables named "var". I'm glad they did not introduce a new language JavaWithVar.

That wouldn't be large enough a change to warrant a new major SemVer. I'm talking about things like python2 -> python3.

> That wouldn't be large enough a change to warrant a new major SemVer.

Yes, it would. Breaking is breaking.

Re: Go Replaces Interface{} with 'Any'

#313

Earlier quoted context omitted.

> Java (and Javascript in its attempt to copy it) are about the only languages that actually promote using exceptions for errors Python does. Ruby does. It's not just Java and JS. Go is very open about its approach being a departure. > And actually, many APIs in the wild do represent errors as integers. Many, many APIs in the wild are implemented in (or meant to be consumed from) C, which doesn't even have exceptions…

> Ruby does. Definitely not. Especially because early Ruby implementations brought huge overhead when exceptions were used, you were strongly advised to only use exceptions for actual exceptions. Ruby was one of the first languages that really started pushing the idea that exceptions should be reserved for exceptions, even if was just for technical reasons. Those overhead problems have been addressed and are no longe…

Ruby has two kinds of exception handling. There is try/catch, this is used for flow control and should not be used for error handling (it doesn't have stack traces). And then there is raise/rescue.

Using try/catch as intended is a bit of an art, but raise/rescue is everywhere. It is absolutely the primary way of handling errors. I think you might be confusing these two.

Re: Go Replaces Interface{} with 'Any'

#314

Earlier quoted context omitted.

That wouldn't be large enough a change to warrant a new major SemVer. I'm talking about things like python2 -> python3.

> That wouldn't be large enough a change to warrant a new major SemVer. Yes, it would. Breaking is breaking.

Nearly every big fix in an API is technically a breaking change if you want to be pedantic. This kind of collateral damage which requires multiple points of failure doesn’t usually count as a semantic major change.

Re: Go Replaces Interface{} with 'Any'

#315
post #305
post #283

Earlier quoted context omitted.

Hence I’m not happy with anything that doesn’t look like Java. Go seems amazing otherwise, but I cannot get over the fact that it forces me to capitalize or not capitalize my variables, and has types in the wrong order.

Well then I guess it's Java for you until retirement. Go can feel a bit alien if you only know "C-style" languages, because its creators took inspiration from a wide array of languages, including Pascal. Actually Pascal-style declarations are easier to read, but you have to keep an open mind and not just go "doesn't look like what I'm used to, so it must be bad"...

C/Java style of annotating the return type of a function first, and then annotating the argument types before the name feels really old school at this point. Python, TypeScript, Go, Rust, etc. all opted for annotating after the name.

Since this is so prevalent in newer languages, despite a pretty strong tradition in the other direction, I wonder if there is a pretty good reason for this which language design experts are keenly aware of when they design new languages.

Re: Go Replaces Interface{} with 'Any'

#316

Earlier quoted context omitted.

> That wouldn't be large enough a change to warrant a new major SemVer. Yes, it would. Breaking is breaking.

Nearly every big fix in an API is technically a breaking change if you want to be pedantic. This kind of collateral damage which requires multiple points of failure doesn’t usually count as a semantic major change.

> Nearly every big fix in an API is technically a breaking change if you want to be pedantic.

A fix is not a breaking change in the API, because “breaking” refers to expected behavior (so, yes, code that relies on a bug can be broken by a fix; presumably, if you've coded to an observed behavior differing from the spec you are aware of having done so.)

Re: Go Replaces Interface{} with 'Any'

#317
post #264

Earlier quoted context omitted.

define a "major" language change, then. after that, get everyone to agree on that definition. that's why semver works; the definition of major change is defined, and that's when you update the major version number.

I have sympathy for your sentiment, but you don't have to come up with a proper definition nor get everyone to agree on that definition. The Go people can just make up reasonable version numbers without having an all encompassing theory with definitions, and they only have to convince themselves, not everyone on earth.

> The Go people can just make up reasonable version numbers without having an all encompassing theory with definitions

but "breaking change" IS the criteria for reasonable version numbers that they have chosen.

"breaking change" is easily tested and well defined.

"big change" is as far from well defined as you can get, because "big" is unquantifiable and subject to judgement and interpretation; i.e. a poor candidate for drawing boundaries.

Re: Go Replaces Interface{} with 'Any'

#318
post #3

It's a type alias, introduced for generics. By the way, Go 1.18 Beta 1 is released (with generics): https://groups.google.com/g/golang-announce/c/eAjK4Oezs_A

How is generics not a big enough change to warrant 2.0? Edit: I’m impressed generics aren’t a breaking change! I thought this changed Interface{} to Any as a breaking change

Was "any" a reserved word in Go before? Because if not, this would be a breaking chnage for all code that uses a var named "any".

Re: Go Replaces Interface{} with 'Any'

#319
post #305

Earlier quoted context omitted.

Well then I guess it's Java for you until retirement. Go can feel a bit alien if you only know "C-style" languages, because its creators took inspiration from a wide array of languages, including Pascal. Actually Pascal-style declarations are easier to read, but you have to keep an open mind and not just go "doesn't look like what I'm used to, so it must be bad"...

C/Java style of annotating the return type of a function first, and then annotating the argument types before the name feels really old school at this point. Python, TypeScript, Go, Rust, etc. all opted for annotating after the name. Since this is so prevalent in newer languages, despite a pretty strong tradition in the other direction, I wonder if there is a pretty good reason for this which language design experts…

I think it's much easier to parse unambiguously, especially when you have operators on values that also appear in types (e.g. `*` and &`).
Post reply on HN