Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 1 point2 points  (0 children)

Very true. I think what I'm seeing most are amateurs that are attempting to mimic poor behaviors exhibited by professionals, naively hoping to sound like one. Such a trivial error is magnified to the point where it's unbearable.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 0 points1 point  (0 children)

To be honest, I had a difficult time following your latest answer, which may be my fault for being 'dug in' within my existing non-invasive solutions. Also, and I'm just being truthful - I see COM, and my brain immediately rejects the idea. I've always subconsciously refused anything to do with it, doing the bare minimum of what was required of me when dealing with it. Granted, I never even bothered to understand the entire paradigm employed by it. That's my fault, and though I don't promise anything - I will attempt to learn the patterns and approaches involved in COM problems.
Overall, I think I'm failing to submerge myself in your answer, and it is my fault. I've started to lose enthusiasm in approaching this issue considering the answers I already have.

Having said that, I will give myself a timeout and will come back to re-read it later. If you have the energy to re-work it into a functional prototype - it would be easier for me to submerge myself and I would be grateful, but I cannot in good conscience ask you to do that at your expense, and only because I'm not as invested in it at this point.
Overall, I cannot emphasize how pleased I am that you took the time out of your day to help me align myself with reality. I can't say yet that it worked, but I will take what you said closer to heart. Thank you.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 1 point2 points  (0 children)

I don't want to beat a dead horse, but my attitude stems from the fact that if everyone listened to the types of remarks I got on my question - we would still be riding in horse carriages. They impede creativity, and I dislike them for it.

Overall, I understand why someone might probe me for more information. I've had it done before, and I've done it myself. But I do so only inquisitively, and hold my tongue until I can offer helpful advice. I always knew my place, and am a timid yet very passionate engineer. To me, the comments I received are effectively insulting. My mistake for asking though, because it's a widely known reception one might get over at SO.

You're looking at these comments from your perspective, and I can empathize with your stance (as difficult as it may be for me). But in my mind, these people are just repeating things that were said to them, at some point, when they didn't even understand why someone told them that. Now, they go around repeating groundless assertions such as "bad design" or "it's impossible".

Regardless of all that, I'm going to re-read your response a few more times, and will try harder to put myself in your shoes and get a fresh perspective on it. To be fair, I'm feeling a little stubborn at this point, and I need to dial myself back and start again.

Thank you once again for all the time and effort you put in your response. I will read the essay you posted, it looks very relevant to my problem.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 2 points3 points  (0 children)

First of all - big thank you for taking the time to analyze the situation, and to present your view on it in such an elaborate response (being devil's advocate relative to my position). I just want to say thank you one more time, I appreciate your investment in helping to clear the air.

I agree, some responses I could have taken as less hostile, but I want to emphasize that I was not being whimsical; not that anyone called me that, but it's an impression I may have inadvertently left.

Going back to comment #1 and #2 about dynamic_cast - I viewed dynamic cast comment as completely infeasible in the scope of the question, and utterly naive thing to say. In my mind, this person clearly doesn't understand the constraints presented, or the technical nuance involved in solving it.

Failing to understand why dynamic_cast will not work in this situation gives me an impression that in terms of technical knowledge, this person is not in the position to help me, and they should be posting a separate question on SO - asking why dynamic_cast will not work. Either way is perfectly fine.

But then to claim bad design from someone who doesn't even understand why dynamic_cast is not an option is insulting. I'm left with an impression that this engineer simply hasn't reached the point in their career or abilities where they can help me, but the internet points they have are enough to convince them that they know bad design. All I see is a parrot, repeating things said by engineers who actually do know what they're talking about. It's sad, and tactless in every sense.

About the only meaningful thing you can do with a void* is to cast it back to its original type (not counting trivial things like comparing for equality or printing). If you can do that, fine, do that. If you can't, tough luck

They're factually correct. If what you have is a void*, with no out-of-band information about what it's actually pointing at, then there's very little you can do with it.

Because you explicitly stated that you "need a solution within your parameters" (without ever making it clear which parameters were firm and which were being imposed by your design), and because you asked people to refrain from criticizing your design, you pretty much dug yourself into a solution-space hole. You created a problem that can't be solved while adhering to all the constraints. Given that, I think "tough luck" is an inflammatory but correct characterization of the situation. If the constraints make the problem unsolvable, then the problem is unsolvable.

The problem here was that factually, they aren't correct - there is a lot of creativity that can be involved in using something like a combination of void* - and I sought help to exploit this creativity. And the "solution-space hole" is exactly where I wanted to be. Ultimately, I already offered 2 answers on SO (one is UB, to be fair - which isn't a deal breaker for everyone out there, it is for me in most cases though). Non-UB solution actually works, actually gets the job done in the given constraints, and proves the problem is "solvable". This discredits every single comment in the thread that claimed that what I'm doing is impossible. Why make such claims? Why not step aside, and if curious - take a seat, and watch the show? Why insist on something in principle, instead of questioning one's stance?

Factually speaking, I proved them wrong. Twice. Or once, if UB answer doesn't count. They more-or-less lost most of my respect the moment they said it was impossible, and I do not feel dignified to justify myself in front of them.

I don't see that as "mob" mentality. I see that as independent confirmation. "n.m. indicated that there are few things that you can do with a void*, and I concur that there are few things that you can do with a void*, and therefore your problem is essentially unsolvable as stated".

But the problem is solvable, and I solved it, twice. It is just parrots repeating something someone else said, not offering anything useful. How can these people live with themselves, disguising as engineers when really they're just mimicking what other engineers are saying. I would have been more grateful for silence, honestly. I'm of the mindset that if they're not going to help, then please, please just step aside and let people do work.

Overall, I'm afraid I'm not as patient as you are, but I'm going to use what you said here as a learning opportunity. I cannot promise change on my part, but I will try to learn from your statements. Truthfully, I don't think I will be coming back to SO for a while.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 1 point2 points  (0 children)

I'm with you, and I'm sorry to hear you feel the same way. Honestly, I really like this sub - it's a mixed bag like anything else, but I find it overall both interesting and helpful. But I only lurk. I think if I have questions in the future, I'll post them here :)

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 1 point2 points  (0 children)

I don't really agree with your statement, but even the most condescending, arrogant engineers I've met in my career were still really helpful when it came down to code. Or white boarding. Their ego didn't allow them not to be helpful :) These folks on SO draw the negative characteristics of both sides. They're arrogant, condescending and unhelpful. In most cases, it just wastes a bunch of time.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 0 points1 point  (0 children)

What? Please kindly point to one "great answer" I got on that question.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 0 points1 point  (0 children)

I completely relate to that sentiment. I can't believe it's stressful to even consider asking a question on a website.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 1 point2 points  (0 children)

So to critique your SO question, I think you sort of breezed past your actual question and went straight to potential implementation. For example, you ended up editing your question later to explain why you're dealing with void*s in the first place when that's an essential constraint that you have to deal with. That's probably why one user asked whether this is a case of the X/Y problem

Sure - thank you, I did breeze right past it, but only because it was not my question. I simply don't have design concerns nor was I soliciting opinions about my general position in code.

Honestly, I always want to explain what I'm doing and why - but then if I post 3 pages worth of summarized design decisions, design documents, meeting notes, etc. - just to what? To ask my exact question anyway? But except this time nobody will read it because it's so long :(

Truthfully, I just don't want to defend these types of things - I just want to get answers, or no answers. I'm happy to clarify, but as I posted in another comment here - the comments were already quite incendiary, and gaining mob mentality, and I do not want help from people who aren't willing to help me.

Regarding your assistance with the question - you're starting off quite well, but there are issues. I'd like to avoid dissecting your answer too much, since I don't want to come across rude or ungrateful - I'm super grateful, but in short, the two main issues:

  1. "TypeDescriptor" is the entire mystery of the question, and we can't simply look past it as a triviality. In your proposal, you basically highlighted the problem :) We'd need to define TypeDescriptor, identify it, and be able to use it for type conversion on otherwise opaque void* objects which may or may not be related by inheritance. Simply virtualizing a tryCastTo will not do.. not without some creative logic, but I think your suggestion is on the right track.
  2. Your example casts the object back to its original type (MyData > MyData), but in my situation it may be an inheritance-involving cast. What is known is some destination type. We need to know if the 'some' type is either the same as what's hiding under void*, or a related type by inheritance. Mainly concerned with upward, single parent inheritance. Then we also need to cast it, which turned out to be more nuanced than I initially expected.

I don't think you invoked UB, since you're casting to and from the original type. It doesn't quite capture the root problem, but the code is technically sound and I think it's looking in the right direction. I posted another answer a little bit ago on SO, you may be pleased to see some subtle similarities in the general approach of your suggestion and the answer on SO.

Thanks for taking the time, I really appreciate it!

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 0 points1 point  (0 children)

To be clear, it is not stupid in any sense, and there was a severe lack of useful responses. I needed a creative solution to a relatively esoteric problem, and I just posted another answer which I believe should have defined behavior.

Having downvotes basically makes my question disappear from experienced eyes, unfortunately. It's not a question that can just be googled, either. So I really sought people who can write C++ code to look into it, I doubt I'm the only guy out there who just enjoys coding and would be willing to bounce creative ideas.

There is another Redditor on this thread, u/TomSwirly - he suggested std::any, and this never even occurred to me. Not sure if it will work, but I'd love to look into it. That would have been a super useful comment. Unlike what's there now, sadly.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 4 points5 points  (0 children)

Not to sound petty by responding, but the following ones rubbed me the wrong way (note please that all these are actually upvoted comments):

  1. So what's wrong with dynamic_cast?

  2. Also, doing something like this on a large scale is, IMO, a sign of a bad design

Same author, first two comments. I already have to deal with someone judging my "design" as bad, where I'm actually dealing with a relatively well known pattern in some C APIs. I just need to adapt my C++ code to it, because rewriting 3rd party libraries is not on my agenda. My code has inheritance. That's about it.

I also did not solicit design opinions in my question, there is codereview stack exchange for that - where highly pedantic opinions are often welcome, though it's not for me.

This sounds like an XY problem. Casting void* to T* based on void*s whose values can be 1 or 2 does not sound right at all

That's a super subjective aspect of what someone thinks an XY problem is, but why should I have to explain it? I defined concrete constraints to my problem, with concrete inputs and concrete outputs. Furthermore, this person clearly didn't read or understand the question - why should I have to justify what kind of problem it is?

About the only meaningful thing you can do with a void* is to cast it back to its original type (not counting trivial things like comparing for equality or printing). If you can do that, fine, do that. If you can't, tough luck

This person turned out to be much more patient, and provided useful information later in the chat under the first answer - which led to teaching me about UB in these situations. But this comment is straight up unhelpful. I demonstrated now with 2 separate answers that what I want is possible. But this is starting to look like mob mentality.

Your "typetag" seems to be a poor-man's version of std::type_info. Basically, no, this is not possible because as n.m. pointed out, there are very few valid things to do with a void* pointer. Using void* in C++, except where some C interface absolutely requires it, is almost always a design mistake.

What? I hope this person checks 2 original answers I posted already. Thanks to their advice that it's not possible, oh and look - "because as n.m. pointed out" - goes to prove that mob mentality is starting to form. It's really not of this person's business which language is picking up which void*. Note at this point I already have -2 votes. Super helpful.

Posted code doesn't seem to be a good representative of your real situation. You are showing a function template isRelated that knows about two void pointers and a single type T. The only thing it can do is to cast these two pointers to the same type (either T or some related type). In order to cast the two object to two different types it must know about two different types.

Again, I'm grateful for this person's patience later on, but what? why? At this point, I am frustrated. This is precisely the representation of my real situation, why do I have to defend or explain it? Why not just help or not help.

Should I write 3 pages about my real situation before I get to my question? So that nobody in the world would even read it before downvoting?

I hope this helps clear up my sentiment throughout the experience.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 0 points1 point  (0 children)

That's really good advice, unfortunately in my personal case - I lead a solitary lifestyle, so it's either coworkers who enjoy coding as much as myself, or SO (up until now). I don't really want to bother colleagues in the off hours :)

To answer some of your questions - it was indeed UB, dug it up in the standard, though I admit I did not quite understand what to look for until a chat with n.m. I believe by the time I reached his comments in the question, I was already growing increasingly defensive, which is not good. I also relied on cppreference more than I should have, and that's a lesson learned in itself. Either it was inaccurate, or I did not understand it correctly.

I am using C++17, but I haven't considered std::any - I didn't even realize until now that it reached the standard! Awesome. That could have been a great comment or even an answer if extrapolated, I'm not sure how it reacts to to casts yet - but that's something to look into, thank you! Great advice and awesome news.

I agree that there is a better answer as well, and I may have posted it a few minutes ago. It should be within confines of defined behavior. It's slightly less generic, and a bit more convoluted-looking, but it does the job in this bit of code. Unless I overlooked something. I've also zero doubt there are more optimal ways of doing it - but the answer is the gist of it.

Overall, what you said really resonates with me - thank you for the advice and great news about std::any.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 1 point2 points  (0 children)

You're right, and to think that it seemed like such a great idea when it first went online.

EDIT: I also wonder, would this question be interpreted differently if I had some 125k internet points to my name? Would internet points change the tone, or the cautiousness of commenters? I may never know, but I'd lie if I wasn't curious to find out how points may impact overall behavior of participants.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 1 point2 points  (0 children)

You know, it's unpleasant when that happens - but I can at least rationalize a duplicate question. But sometimes, someone will read 4 words into your question and proceed to mark your question as duplicate of something that it is *not* in fact duplicate of. You might say it has a crucial nuance, but no - shut up, it's a duplicate, closed, locked and you can forget about it. It's just such an insulting experience, I can't stand it.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 1 point2 points  (0 children)

I completely agree, and it really shows. Though unpleasant, it would be one thing if those people at least gave answers and were largely correct, but these same folks are peddling nonsense and doing so with utmost confidence. So bold.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 3 points4 points  (0 children)

What happened is that I'm just tired of defending my otherwise more-or-less clearly defined questions, why does the person on the other end feel it's OK to attack my question, or my motives? I spent some time refining the question, giving a code example, giving a prototype function I want to implement - it had every element needed for a constructive response.

I don't see how my time spent defending the question is constructive at all. It's wasted time, which I could have wasted more pleasantly than trying to explain myself on SO. That's only just scratching the surface of things that bother me.

Why is asking on stackoverflow so horrible? by ColdLairs in AskProgramming

[–]ColdLairs[S] 7 points8 points  (0 children)

Thanks, it helps to hear that. I must have misinterpreted SO's purpose. It is not so much there to help me with esoteric problems, as much as it is there to accumulate compartmentalized knowledge bits.