0

I have stumbled upon this question

I am wondering if these kind of questions can be considered opinion based. The question might have an objective answer, or the community might not have a consensus nowadays (I don't know it myself). So... in the second case, should we point out that there is no consensus, or should we consider it an opinion-based question? It seems kind of dependant of the situation. What does really make a question opinion based then?

6
  • 1
    benchmark your code and you will see what is the fastest on your machine and with your data, the best implies always a deterministic way to explain what is the best, but your goals may be others as mine, so we would differ in the result
    – nbk
    Commented Jun 8, 2022 at 7:47
  • True @nbk. It is possibly not so easy to be objective on the matter.
    – S. Dre
    Commented Jun 8, 2022 at 9:20
  • Yes, anything asking for the "best" anything is going to be safe to close as primarily opinion-based. Unless they spell out that by "best" they mean "this specific, narrowly-scoped, objective criterion that is the same regardless of environment or other temporal factors". But if they bothered to consider and specify such criteria, they would almost certainly not be asking for the "best" something in the first place.
    – TylerH
    Commented Jun 8, 2022 at 14:58
  • 5
    A consensus doesn't make an opinion not an opinion... it only makes it a popular opinion.
    – Kevin B
    Commented Jun 8, 2022 at 15:00
  • I am sorry but I do not agree. De facto at least. A lot of our science is based on consensus, and we have been progressing because we give the most popular and advanced theory the status of truth, even if every 20 years it's proven wrong.
    – S. Dre
    Commented Jun 8, 2022 at 18:53
  • "the best" is an opinion (and few people will be qualified to dictate what is the best) and a red flag, but it can be fluff too. People tend to be a little overzealous when asking questions, laying down terms like "only working answers please". Or another shoot-yourself-in-the-foot antic, "I'm using library X but I'm open to suggestions". If the opinion is in the fluff, it can be removed without changing the question.
    – Gimby
    Commented Jun 9, 2022 at 12:23

2 Answers 2

12

I am a Rust subject matter expert. This feels like one of those cases where the quality of the question overall has convinced the surrounding peers that the question is better off left unanswered. Here is why:

  • The main red flag was asking for the best way to do something. The author of the question mentioned multiple criteria yourself, which makes the question a bit too open ended and vague. Doing this is an almost sure way to have the question closed.
  • The OP has shown a few examples, but they are not complete (it contains definitions which we do not know about), and there was not much effort in figuring out what they compile down to, or how fast they are. Given that the difference between the three is in how the pattern is matched, one would most likely find out that they compile to the same thing. It would then come down to a matter of readability or taste.
  • There could probably exist an answer which draws from existing conventions and lint suggestions (Clippy), but even those suggestions are subjective and are known to change over time. The single_match_else Clippy lint would have suggested you to write if let instead of match, but right now it's set to allow by default, so it's not that much of a great suggestion.
  • Ultimately, an answer would probably have suggested to write something completely different too, as suggested in one of the comments on the question. It would probably be more idiomatic to use the map entry API to check and insert an element.

Maybe with some editing to include a complete (but minimal) example, and to focus on what the OP intends to achieve, rather than just which one is best based on an amalgamation of criteria, it could then be on its way to be reopened.

6
  • 3
    "the quality of the question overall has convinced the surrounding peers that the question is better off left unanswered" That's emphatically not a valid reason to close a question. At most, that's a reason to downvote it. It is better taken as a reason to actually answer it. If the problem is bullet #1, that's not opinion-based; that's too broad/unfocused. If the problem is bullet #2, that's not opinion-based; that's lacking sufficient code/context to demonstrate the problem (and/or unclear). If the problem is bullet #3 or #4, then that's not a problem at all.
    – Cody Gray Mod
    Commented Jun 8, 2022 at 8:07
  • 6
    @CodyGray The bullet points were a set of problems which I detected in the question, not independent reasons to close it (although some of them are). Granted, "opinion based" may seem like the wrong closure reason, but it may have been caused by what I described in #2 and #3: it is unlikely for there to be performance differences in the three versions of the code, so it comes down to which is more idiomatic, which in turn is also utterly subjective.
    – E_net4
    Commented Jun 8, 2022 at 8:14
  • 4
    But... if there's no performance differences between the three versions of the code, leaving a programmer to feel free to pick any one that speaks to them, then that's the answer to the question!! And that makes the Q&A extremely useful, to have someone who is a Rust expert tell them (ideally, prove and/or explain why) there is no performance difference that needs to be considered.
    – Cody Gray Mod
    Commented Jun 8, 2022 at 8:22
  • I edited the question to address some other concerns, but I'm curious why the incomplete examples are actually a problem - yes, lots of things aren't defined within those code blocks, but all of those are the same among the different versions, so I don't see why it matters? Commented Jun 8, 2022 at 15:08
  • Indeed, trying to specify "best" as two totally separate/independent metrics makes the question in need of help by the OP. @TheZachMan your effort is laudable but still falls prey to asking an off-topic (read: opinion-based) question: "follows conventions of the languages". Conventions or best practices questions are opinion-based ones.
    – TylerH
    Commented Jun 8, 2022 at 15:12
  • @E_net4-MrDownvoter I have further revised the question. Not sure if you feel it's answerable now.
    – TylerH
    Commented Jun 8, 2022 at 15:18
5

I disagree that it is primarily opinion-based. However, I do see it as too broad (read: lacking sufficient focus).

If you are to ask a question about which is "best", you need to give some criteria by which "the best" is to be judged. Performance is a reasonable (and often-overused) standard, as is compliance with language conventions (especially in "opinionated" languages where there is a strong and well-defined set of rules/conventions).

What you cannot do, however, is ask for both. Which is exactly what this question, in its current form, does:

Which one is the best (either from the perspective of following language conventions, or from performance, though I suspect performance is identical)?

However, that can be easily remedied by simply picking one aspect to focus on (i.e., one definition of "best") and editing the question. Ideally, that edit would come from the original asker of the question, otherwise the answers may not be very useful to them.

Speaking more broadly, there is, for some reason, a real reluctance among a certain group of users to abide performance-related questions on Stack Overflow. To this, I say: pish-posh. Yes, "everyone" knows that the "best" way to determine which code is the "fastest" is to "benchmark" it. As the quotation marks imply, there are caveats to this commonly-held belief. But those aside, that doesn't make the question off-topic or otherwise unsuitable for Stack Overflow. Performance questions are only a problem if they are too broad. If the question presents a small subset of options to consider and asks which among them is going to run the fastest, that's not too broad, and it's not opinion-based, and it's not off-topic. In fact, it's probably one of the more useful questions that we could host on this site, far more so than the zillions of "debug my weird, mostly-broken code" questions that we get day in and day out. Problems that are faced by large numbers of programmers are kind of our raison d'être, particularly those where there is a lot of misinformation or lack of knowledge floating around out there, allowing us to give high-quality, expert-level advice that is vetted/verified by the larger community of experts. If that doesn't justify optimization/performance questions, I don't know what does.

2
  • 1
    I think people have a distaste for performance questions because so often they don't include the parameters necessary to recreate a similar performance benchmark. If more "which one is faster" questions included that, perhaps the situation would be different. It's not like they are asking in the context of number of operations or the clock cycles taken for X vs Y... people tend to just ask 'which one is faster/better/more efficient". Which is... not exactly a stellar case for allowing that kind question.
    – TylerH
    Commented Jun 8, 2022 at 17:51
  • Somewhat orthogonal, it's for the same reason I scoff at the W3C for dragging their feet on a CSS parent selector. For decades we were told "it would be too computationally expensive" without anyone bothering to demonstrate what they considered "too computationally expensive" meant; we just had to take their word for it and assume their experience/environment would be similar to ours WRT the result. Show me the money, please.
    – TylerH
    Commented Jun 8, 2022 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .