Earlier quoted context omitted.
That's why unused variables should be reported. What people are arguing about is errors vs. warnings. > things that can really cause bugs "can" means that they don't always cause bugs: other compilers treat such uncertainties as warnings because the human looking at the screen is the one who is in charge. Go allows you to compile code which does not respect "go fmt", why? aren't you afraid of committing working code…
As someone else pointed across the thread, the error eliminates these bugs, not only in your code but, effectively, in all the libraries you import. It takes effort to retain those bugs. That has significant value, and is why I've conclude Go's choice here was the right one, despite the annoyances it causes. I like gofmt, but I don't really care whether the compiler enforces it. It's unlikely to catch bugs.
I Love Go; I Hate Go
281–290 of 329 posts
Re: I Love Go; I Hate Go
#282Earlier quoted context omitted.
Fast enough for a 60's computer, imagine nowadays. But if you want numbers, Turbo Pascal 5.5 was doing 34,000 lines/minute[1] on MS-DOS back in 1989. [1] http://edn.embarcadero.com/article/20803
Turbo Pascal isn't Algol 68. A PC in 1989 isn't a B5000. But even accepting the example, 34,000 lines/minute gets you a compile that takes 294 minutes, or just under 5 hours. That's... not very good. Of course faster hardware is part of the answer, but I suspect that it doesn't cover nearly all the ground between Turbo Pascal's compile time and Go's.
Besides I am comparing an 8086 with 640 KB against a i7 with 16 GB and three level caches.
Go being fast isn't that much of an achievement in 2016.
If Go compiles faster than Turbo Pascal with an 8086 CPU and 640 KB RAM, that is an achievement.
Re: I Love Go; I Hate Go
#283Earlier quoted context omitted.
i was shocked by that at first too. Then I came to love it. It's sooooo go. Don't import stuff you aren't using. Don't declare a var and just leave it there un-used. When I go back to ruby and commit that crime, I see why golang did what it did. There's something magical about a golang program that will compile without error. It's worthy of checking in to git. And months later, there will be no unsed imports FOR SURE…
Define unused imports/variables as warnings but produce an executable that first prints "This program is for debugging purposes only, it built with 133 warnings." and beeps loudly.
Re: I Love Go; I Hate Go
#284Earlier quoted context omitted.
This statement is probably true but that's kind of irrelevant. IMO it is actually a virtue of the language if it is perfectly usable without a modern IDE. Contrast that with Java and you'll see what I mean. Go follows the Unix philosophy where things like imports or formatting can be supplied by any external tool. If you wish to bundle all these small tools into a single IDE you can do it, too.
Everything is perfectly usable without an IDE, you are just more productive with one than without one. Regardless of the language. In this particular case, the IDE could automatically remove the imports when you remove the corresponding symbol from your source, or automatically add the import when you introduce a new symbol. The "can be supplied by any external tool" is a cop out that was acceptable in the 20th centu…
Re: I Love Go; I Hate Go
#285Earlier quoted context omitted.
> By comparison Elm makes much more extensive use of spacing and tries to avoid repeating the same information (e.g. file names) over and over. Yeah, but you need that kind of repetition to get text editor jumping to correct line number. AFAIK, Rust already implements concise messages on nightly.
> Yeah, but you need that kind of repetition to get text editor jumping to correct line number. Not really, what you need is a regular and parseable structure.
Though to be fair I am not huge fan of Elm's one error per build either.
Re: I Love Go; I Hate Go
#286Earlier quoted context omitted.
Turbo Pascal isn't Algol 68. A PC in 1989 isn't a B5000. But even accepting the example, 34,000 lines/minute gets you a compile that takes 294 minutes, or just under 5 hours. That's... not very good. Of course faster hardware is part of the answer, but I suspect that it doesn't cover nearly all the ground between Turbo Pascal's compile time and Go's.
I gave Turbo Pascal as an example, because even when compared against it, there are many features that Go lacks and Turbo Pascal had. Besides I am comparing an 8086 with 640 KB against a i7 with 16 GB and three level caches. Go being fast isn't that much of an achievement in 2016. If Go compiles faster than Turbo Pascal with an 8086 CPU and 640 KB RAM, that is an achievement.
Re: I Love Go; I Hate Go
#287Re: I Love Go; I Hate Go
#288Oh. Go love-hate relationship post. My turn. So I really like channels and coroutines built into language and used everywhere: it makes some patterns compose nicely and language very productive. But just as in the article - some of Golang choices are opinionated and IMO just stupid. Lack of assertions is one: Sure programmers are prone to ignoring errors, but Go is not helping at all. Just bans assertions and provide…
Do you find using pub/extern keywords more elegant than a simple capitalization? To me rust is verbose in many cases like java with a lot keywords heading towards C++ complexity which is exactly what Go tries to avoid. I understand that now crago becomes somehow part of the language as the extern declarations will become "optional"/deprecated. So yeah, I hope Go won't adopt any of these fancy/XXI century features.
Rust is noisy in other parts, for other reasons (trying to explain to compiler how to write super fast and data-race free code). But visibility qualifiers are not a problem.
`extern` is only for importing crates, which is like 10 lines at in whole package/crate. Irrelevant.
Re: I Love Go; I Hate Go
#289Earlier quoted context omitted.
This is an easy problem to solve. The Go compiler could simply include a bit in the resulting binary/library that indicates whether or not it was built with the "disable-unused-variable-error" flag. If you're using a library that was built with that flag the compiler can simply refuse to compile your code without that flag, forcing you to acknowledge the problem head-on.
This doesn't solve the problem. It just makes you aware it might be there. It doesn't keep the ecosystem clean. The result will be that everyone compiles with that flag on so they can use the libraries they want/need. It's in fact actively worse than just allowing warnings. At least if you allow warnings that way you aren't forced to lower your own codes protection just because one of your dependencies does.
Re: I Love Go; I Hate Go
#290Earlier quoted context omitted.
Why on earth would the language hinder you from iterating fast with a flag, and then convert all the warnings to errors when you run the full tests? For example, most JS linters do that check and as a general rule, the build servers would reject the commit when the linter complains. I actually have a (very hacky) plugin to ESLint that automatically removes unused variables before `hg push`. It's totally not optimal,…
Devil's advocate: if you can disable -Werror, then users will disable -Werror, and we'll end up in a C-like situation where everything warns all the time, and real problems get buried. Better to inflict some pain during development if it keeps the Go source corpus hygienic. One under-appreciated consequence is that this policy limits Go to one implementation. Say I write an alternative implementation of Go, that has…
The point about alternative implementations is interesting. Java has a comparable situation with unreachable code; the language specification has a simplistic definition of what unreachable code is, and makes it a compile-time error. A smart compiler can find more cases of unreachable code, but isn't allowed to make them errors. So it makes them warnings. It doesn't seem to be a big impediment to alternative implementations in practice.