4 ms·
I'd also say that many of these things are trivially fixed in other languages using tools. Most big projects have some code style guidelines which can be enforc
by mike_hearn 12y ago
I'd also say that many of these things are trivially fixed in other languages using tools. Most big projects have some code style guidelines which can be enforced using a linter and any good Java IDE can auto-clean imports lists for you at commit time (IntelliJ can be configured to auto-optimise imports just before commits for instance).
Making the compiler super strict about it seems like a good way to make quick changes awkward. Especially when there isn't a strong debugger you often end up commenting bits of code out or adding "return true" type statements half way down functions, and it's annoying when the compiler refuses to let you do it. This is one of the things that bugs me about javac - if it detects dead code in a function it refuses to compile. Maybe I'm weird but in my work this has caught legitimate dead code exactly zero times, but has triggered false positives due to transient debugging changes eleventy bazillion times. Luckily javac is dumb and you can trick it by just writing the code as "if (true) return;"
- threeseed 12y agoBoth Eclipse and IntelliJ have supported cleaning up imports and running style tools on every save for years. I have no idea why this would be a core part of any language.
- skj 12y agoIt's not part of Go-the-language. It's part of the distribution of the most popular (ok, only) implementation of that language.
- solipsism 12y agoNot true. It is illegal for a package to import itself, directly or indirectly, or to directly import a package without referring to any of its exported identifiers. - https://golang.org/ref/spec https://golang.org/ref/spec
- skj 12y agoWhat? I'm saying that the tooling that helps manage import paths in the way you want is not part of Go-the-language. The language restriction against unused imports certainly is.