News for hackers. Stuff that matters.
Re:I Love Go; I Hate Go by wruza on Tuesday August 02, 2016 @02:44AM (#12208190)
Stockholm syndrome in action. There are two phases: active development and release engineering. -Wall for former, -Wextra -Werror for latter. If someone is not disciplined enough to throw out unused variables/imports/whatever from release, Go will not save him from hell.
Re:I Love Go; I Hate Go by laumars on Tuesday August 02, 2016 @04:51AM (#12208575)
> Stockholm syndrome in action.

That's a very negative way of saying "that's not my personal behavioral preference"

> There are two phases: active development and release engineering. -Wall for former, -Wextra -Werror for latter.

Many of Go's idiosyncrasies are for code readability and maintainability, which is very much a part of active development. The point being to mitigate the likelihood you end up with spaghetti code (yes, I know you ultimately end up with code quality only as good as the developer, but some languages do still make the process easier than others)

> If someone is not disciplined enough to throw out unused variables/imports/whatever from release, Go will not save him from hell.

Except it does though, since that's the very behaviour you're complaining about.

Re:I Love Go; I Hate Go by ckastner on Tuesday August 02, 2016 @05:11AM (#12208655)
>> Stockholm syndrome in action.

>That's a very negative way of saying "that's not my personal behavioral preference"

In my experience, Stockholm syndrome is not used to describe personal behavioral preferences, but rather (unexpected) transitions between such preferences from the negative to the positive.

In the grandparent's own words:

>>> i was shocked by that at first too. Then I came to love it.

Re:I Love Go; I Hate Go by laumars on Tuesday August 02, 2016 @12:19PM (#12211027)
It's possible that's what he meant, but that's not how I understand the term.

Stockholm syndrome refers is a victim forming emotional bonding with his or her captor[1]. Which would mean in instances like this, where the "captor" is a voluntary choice of language, the term is used akin to "masochism" (albeit without the sexual element). In essence, saying "the pleasure from use feature x is derived from the pain of using feature x".

Which is why I commented that "Stockholm syndrome" is a needlessly colourful way if saying "I disagree".

[1] https://en.wikipedia.org/wiki/Stockholm_syndrome

Re:I Love Go; I Hate Go by junke on Tuesday August 02, 2016 @12:26PM (#12211077)
The "masochism" aspect makes Go part of Bondage and Discipline languages:

http://c2.com/cgi/wiki?BondageAndDisciplineLanguage

Re:I Love Go; I Hate Go by fauigerzigerk on Tuesday August 02, 2016 @08:21AM (#12209358)
Yes, but it requires that the victim has no way out. Stockholm syndrome is not just any unexpected change of preferences.
Re:I Love Go; I Hate Go by mtanski on Tuesday August 02, 2016 @09:41AM (#12209836)
The victim has no way out short of switching languages which may or may not be under their control.
Re:I Love Go; I Hate Go by fauigerzigerk on Tuesday August 02, 2016 @10:53AM (#12210370)
Stockholm syndrome, as far as I know, was observed in situations of physical threat to life or health with the only way out being death.
Re:I Love Go; I Hate Go by junke on Tuesday August 02, 2016 @05:11AM (#12208658)
> Except it does though, since that's the very behaviour you're complaining about.

No, the meaning was: if someone cannot handle unused things, that someone is screwed. Go will not save him in other aspects which require a little bit of discipline and are not checked by the compiler.

Re:I Love Go; I Hate Go by mcphage on Tuesday August 02, 2016 @07:55AM (#12209232)
> if someone cannot handle unused things, that someone is screwed.

So what you're saying is, there are two kinds of people—those who don't need the feature, and those for whom the feature isn't sufficient?

Re:I Love Go; I Hate Go by junke on Tuesday August 02, 2016 @08:28AM (#12209397)
User laumars was apparently misinterpreting part of a comment by saying that "unused" errors (not warnings, but errors) would in fact save the hypothetical "someone" that was claimed to be not disciplined enough to remove unused imports at release time. But the parent comment was in fact saying that the disability to handle something as simple as unused imports would prevent said programmer to accomplish the less trivial things that programmers are expected to do and for which no tools is a substitute for.

My personal view on this is that warning the user should be enough. The compiler designer is basically saying: I can't trust developers to fix warnings and it is my duty to protect them from their own laziness by enforcing a certain way of working. This apparently attracts a certain kind of people. I prefer to be the one telling the compiler what to do, instead of the reverse.

Re:I Love Go; I Hate Go by mcphage on Wednesday August 03, 2016 @11:13AM (#12218514)
> My personal view on this is that warning the user should be enough. The compiler designer is basically saying: I can't trust developers to fix warnings and it is my duty to protect them from their own laziness by enforcing a certain way of working. This apparently attracts a certain kind of people. I prefer to be the one telling the compiler what to do, instead of the reverse.

I'm with you there, I just was making a snarky comment :-)

Re:I Love Go; I Hate Go by sagichmal on Tuesday August 02, 2016 @06:22AM (#12208889)
This is literally the "perfect is the enemy of the good" fallacy.
Re:I Love Go; I Hate Go by sagichmal on Tuesday August 02, 2016 @04:39AM (#12208541)

    > There are two phases: active development and release 
    > engineering.
For you, perhaps. Go encourages you to think about your problem and develop it in the "release engineering" style from the very beginning. This is a virtue of the language, in my view.
Re:I Love Go; I Hate Go by junke on Tuesday August 02, 2016 @05:02AM (#12208620)
Ada is probably the most real-software-engineers-dont-hack language ever designed, and yet compilers have flags to control checks and warnings.
Re:I Love Go; I Hate Go by tigershark on Tuesday August 02, 2016 @09:20AM (#12209697)
No, there is no encouragement here. Go forces you to treat things that have always been just warnings in other languages as errors. And I wouldn't call a virtue something that doesn't give you a choice. I will be really pissed off if the language thinks that I'm so idiot that I need errors instead of simple warnings for the cases discussed here.
Re:I Love Go; I Hate Go by Klathmon on Tuesday August 02, 2016 @09:56AM (#12209926)
You are human, humans forget, humans get distracted, humans think that their situation is the exception that makes the rule.

A program doesn't suffer from that. Forcing these things to be showstoppers makes sure they NEVER become a problem, and the "cost" (in terms of the developer) is pretty small in the grand scheme of things.

Re:I Love Go; I Hate Go by tigershark on Tuesday August 02, 2016 @10:20AM (#12210107)
How in the world forcing someone to put an underscore before the import name or adding a dummy variable to use the import (both should be removed after the debugging) helps to avoid bugs instead of making easier to introduce them?
Re:I Love Go; I Hate Go by Klathmon on Tuesday August 02, 2016 @10:29AM (#12210195)
Adding a dummy var won't work, because then the dummy var will trip the "no unused variables" check.

Adding a _ to the front of an import is not the correct way to get around this "problem" during development, commenting out the whole import is the correct way. That way if you forget, it's not in your code anywhere (as it shouldn't be since it isn't used).

The underscore system is meant only to be used when you need to import for side effects (something that i've never actually needed to use).

Re:I Love Go; I Hate Go by tigershark on Tuesday August 02, 2016 @10:47AM (#12210326)
I have seen both suggestions in this thread: var _ = unusedImport

If you can't even agree among yourselves what is the right thing to do then I think that this is another sign that this go behaviour is not the proper solution.

Re:I Love Go; I Hate Go by Klathmon on Tuesday August 02, 2016 @11:42AM (#12210736)
If you have seen other people suggest that using a _ for an unused import that is unused because you commented out the variables using it, they are just doing more work for a worse result.

If you comment out code that uses an import, comment out the import too. It's not just the recommended way, it's the only logical way of doing things.

And how is having 2 opinions on how to do something a sign that this is not the proper solution? People still can't agree on tabs vs spaces (and probably never will be able to), that doesn't mean that all programming isn't a proper solution. There are also people that think using version control is a bad idea, but that doesn't mean that all version control is broken...

Re:I Love Go; I Hate Go by AnimalMuppet on Tuesday August 02, 2016 @12:46PM (#12211233)
> Stockholm syndrome in action.

So here's a language feature that you don't like. Other people don't like it and then, after they get more experience, decide they like it after all. And you call it Stockholm syndrome? By saying that, you're asserting that there is no possibility that the feature could possibly be anything other than harmful. That's... pretty arrogant, actually. Both the language designers and the users who like it are objectively wrong, and you're right?

Look, you don't like it. That's fine. It doesn't work with the way you like to develop. That's fine, too. But your assertion is that it is worse than useless for all users, and that's a bit more than you have the knowledge to assert.

Re:I Love Go; I Hate Go by zaphar on Tuesday August 02, 2016 @09:13AM (#12209656)
This may work for you code. But are you sure that all the libraries you use also follow that rule? Are you going to audit all of those projects and their dependencies to validate they follow the same best practices as you?

The end result of Go's opinion on warnings is that you know a certain class of bugs in not present anywhere in both your code and all of your dependencies. While it's true that people and teams that follow the best practices around warnings also tend to follow the best practices for other things but there is no guarantee for the ecosystem in a language that allows warnings, and no project lives in a vacuum.

Re:I Love Go; I Hate Go by hehheh on Tuesday August 02, 2016 @09:31AM (#12209767)
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.

Re:I Love Go; I Hate Go by zaphar on Tuesday August 02, 2016 @10:58AM (#12210408)
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 by wruza on Tuesday August 02, 2016 @07:01PM (#12214113)
Complaining about unused import doesn't solve anything IRL, if we talking about solving something. Problems in code are complex diseases, and cleaning unused entities is like washing your hands, not like taking a cure. And hand cleanliness checks is too idiotic measure to cure brain cancer. Of course all our problems are still here in both cases, but at least with Go we will die clean for sure.
Re:I Love Go; I Hate Go by hehheh on Tuesday August 02, 2016 @02:21PM (#12211965)
If a library is so popular that "everyone" uses the flag so they can use it, surely someone can be convinced to remove the unused import statement. If the ecosystem makes that difficult then we're talking about a totally different problem.