Live data from Hacker News

Facebook Go Libraries

github.com

91–98 of 98 posts

Re: Facebook Go Libraries

#92

Earlier quoted context omitted.

In fact, you should be glad that "go fmt" exposed the fact you were relying on something that you should not have. Better to find a bug sooner rather than later, and relying on implementation details of your particular language implementation is a bug.

It seems to me like it would be very much in line with the Go philosophy to automatically uncover this in some way other than just an impossible-to-debug pre-compile sort, like disallowing it on a language level. Perhaps that's a Hard Problem, though, so not a reasonable request.

Well, they could do what they did with map iteration: make it happen arbitrarily different each program execution.

Re: Facebook Go Libraries

#93
post #92

Earlier quoted context omitted.

It seems to me like it would be very much in line with the Go philosophy to automatically uncover this in some way other than just an impossible-to-debug pre-compile sort, like disallowing it on a language level. Perhaps that's a Hard Problem, though, so not a reasonable request.

Well, they could do what they did with map iteration: make it happen arbitrarily different each program execution.

Breaking it randomly and requiring debugging is not the same as telling you you're doing something wrong and where.

Re: Facebook Go Libraries

#94
post #92

Earlier quoted context omitted.

Well, they could do what they did with map iteration: make it happen arbitrarily different each program execution.

Breaking it randomly and requiring debugging is not the same as telling you you're doing something wrong and where.

Worked for maps :)

The same exact argument applies. The code was broken to begin with, the implementation behavior did not break anything.

And, just like with map iteration ordering, it's very difficult/impossible for the compiler to say "hey don't depend on this!".

The only way that I can think of to get this concept (that import order in code and init() order in runtime are unrelated) is to have things break.

Re: Facebook Go Libraries

#95
post #94

Earlier quoted context omitted.

Breaking it randomly and requiring debugging is not the same as telling you you're doing something wrong and where.

Worked for maps :) The same exact argument applies. The code was broken to begin with, the implementation behavior did not break anything. And, just like with map iteration ordering, it's very difficult/impossible for the compiler to say "hey don't depend on this!". The only way that I can think of to get this concept (that import order in code and init() order in runtime are unrelated) is to have things break.

I guess I've personally never seen the value of static initializers (in other languages at least), they always seem like the source of hard-to-find bugs. So perhaps that's really where my complaint is. Is there a compelling use for them in Go over explicit initialization?

I suppose if the runtime randomizes things, at least you would never experience it consistently working in the first place, so maybe the issue wouldn't ever come up.

Re: Facebook Go Libraries

#96
post #94

Earlier quoted context omitted.

Worked for maps :) The same exact argument applies. The code was broken to begin with, the implementation behavior did not break anything. And, just like with map iteration ordering, it's very difficult/impossible for the compiler to say "hey don't depend on this!". The only way that I can think of to get this concept (that import order in code and init() order in runtime are unrelated) is to have things break.

I guess I've personally never seen the value of static initializers (in other languages at least), they always seem like the source of hard-to-find bugs. So perhaps that's really where my complaint is. Is there a compelling use for them in Go over explicit initialization? I suppose if the runtime randomizes things, at least you would never experience it consistently working in the first place, so maybe the issue woul…

Right, that's the idea.

Regarding static initializers, I use them for precompiling regexps and templates, but not much more than that.

Re: Facebook Go Libraries

#97

Earlier quoted context omitted.

go fmt will reorder your imports, which means that if there is an import ordering dependency, it will either be exposed (or hidden) by go fmt.

you should never have an import order dependency, since initialization order is unspecified.

Shoulda woulda coulda:

https://bugs.launchpad.net/gocheck/+bug/1178806

Re: Facebook Go Libraries

#98

Earlier quoted context omitted.

you should never have an import order dependency, since initialization order is unspecified.

Shoulda woulda coulda: https://bugs.launchpad.net/gocheck/+bug/1178806

I say that's great! It helped uncover an otherwise unnoticed bug.
Post reply on HN