54
junon
10d

Someone on a C++ learning and help discord wanted to know why the following was causing issues.

char * get_some_data() {
char buffer[1000];
init_buffer(&buffer[0]);
return &buffer[0];
}

I told them they were returning a pointer to a stack allocated memory region. They were confused, didn't know what I was talking about.

I pointed them to two pretty decently written and succinct articles, the first about stack vs. heap, and the second describing the theory of ownership and lifetimes. I instructed to give them a read, and to try to understand them as best as possible, and to ping me with any questions. Then I promised to explain their exact issue.

Silence for maybe five minutes. They disregard the articles, post other code saying "maybe it's because of this...". I quickly pointed them back at their original code (the above) and said this is 100% an issue you're facing. "Have you read the articles?"

"Nope" they said, "I just skimmed through them, can you tell me what's wrong with my code?"

Someone else chimed in and said "you need to just use malloc()." In a C++ room, no less.

I said "@OtherGuy please don't blindly instruct people to allocate memory on the heap if they do not understand what the heap is. They need to understand the concepts and the problems before learning how C++ approaches the solution."

I was quickly PM'd by one of the server's mods and told that I was being unhelpful and that I needed to reconsider my tone.

Fuck this industry. I'm getting so sick of it.

Comments
  • 23
    This is why I simply don’t try anymore.
  • 12
    So he gave otherguy a free pass even though he was posting misleading info? Ok let him teach then, sit back and watch the ship sink lol
  • 7
    also the reason why I don't go too in deep with technical discussions or forums in one way or another.

    Here i will post some things from time to time, i think the last time was around 2017 or 18 if memory recalls.

    Other than that nah, specially on plz sie help fix code sir questions.

    It's draining, glory-less and pointless
  • 2
    They should probably go learn some higher level language first then..

    Care to share those articles you posted? :)
  • 5
    @lotd

    - https://gribblelab.org/CBootCamp/...
    - https://arne-mertz.de/2016/01/...

    The second one is admittedly a little dubious but it illustrates a point decently well.
  • 3
    Geez there is a right way and a wrong way to do it. Bloody mod took the wrong side here.
    You where helping them with all kinds of similar and related errors. When in C(++) memory understand you must.

    Hope that you don't see this as an industry thing but individuals that are stupid.
  • 1
    binary exploitation sends it's greetings.
  • 2
    wow thats good
  • 5
    so a mod on a C++ learning/help doesn't understand C++ at all...

    and I bet the guy that suggested malloc doesn't either and just uses malloc everywhere... sure, it's not a problem if you have 32GB of ram to spare, maybe he doesn't even know he's causing leaks everywhere!

    eitherway, the mod is in the wrong clearly and you were approaching the new guy correctly imo.

    maybe I'd try to explain stack/heap myself without articles and links, risking tiny issues, but it would probably stick more with the noobie, as getting an article with a tiny scroll bar is often daunting I guess?... at the very least I'd stress that he needs to manage and free any memory he ever allocates himself and explain what happens if he doesn't I guess...

    I guess the issue with learning and helping is that you can't have expectations at all, and you're either going to be pleasantly surprised or really annoyed depending on the personality of the one trying to learn...
  • 5
    These don't sound like developers but rather students who can't be arsed with doing their homework on their own and don't actually care about the subject
  • 2
    @AleCx04 And isn't that a sad commentary on the state of affairs?
  • 1
    To be fair to the person asking the question, I often ask questions like this about a million different subject areas, of which I do not have enough lifetimes to study the issue enough to work out the answer myself.

    So whilst I appreciate links to, how to understand something, which I will read if I have time, I'm also after a quick fix to a specific problem, if anyone cares to share one.

    And I do the same back, if someone has a question to which I know the answer, and it doesn't take me more than a few minutes, or even seconds, to rattle it out, I do so.

    I do also try and provide links so if they want to learn more, they can do so.

    For example, I want to know how to get a bicycle gearbox with a reverse gear option, since there are so few of those, quick simple answers are appreciated, rather than I spend 5 years learning about gearbox design to make my own..

    I wouldn't as a mod, tell anyone off for trying to help in any way.
  • 7
    Not to get too political, but I feel like this sort of attitude is fueled by the outward-facing political climate in big tech. The idea of merit is thrown out the window in favor of some really destructive behaviors more often than in the past.
  • 1
    Right Right...
    The bus just starting.
  • 3
    Damn! I feel you.
    This is why I’m glad that I learned C++ before Java and C#.

    It gets you a much deeper understanding of all the concepts of languages and how you can utilize them efficiently.

    People without that understanding tend to be too pragmatic in coding.
    Use classes for everything, use List for everything. Always use mutables instead of constants, etc.

    And then they have the nerves to refer to it as "Simple". As if it is some sort of superior programming style. Just because everything else is too hard to grasp for them.
    The person which asked you for help will most certainly become such a dev.
    They don't want to learn. They want the most simple and generic solution for everything, no matter how dumb or problematic it is. If it's simple, it wins.
  • 3
    @Lensflare As someone who learned C# and is now trying to learn good habits in C++, I can definitely see your point.

    I should also point out that those of us who learned Java/C# first feel much the same way about Python and JavaScript devs. Unfortunately most university curriculum is starting to really default to Python insteadof Java these days. So this will only get worse.
  • 0
    Perhaps that PM is on a payrole of some hardware vendor. When I raised a similar issue I got a nice reply from the representative of the software saying "Yearly advances in hardware are huge. We don't need to emphasise on code optimisation as customers can buy better servers to make up for it."
    They stand by it and the requirements grow as time passes.
    Weekly reboots are standard. Virtualization not recommended as that leaking bloatware eats up the whole machine.
  • 0
    The standard always goes down it seems.

    Make it fool proof, they'll make a better fool.
  • 1
    @LotsOfCaffeine I'm curious as to what would happen to someone like that. You see, I'm trying to teach myself coding as I find computers magical. But this person who doesn't really care to really understand what he/she is doing, where do they end up in?

    What kind of job can someone like that land?
  • 1
  • 1
    @Lensflare I do not think that simple is bad at all. I think the problem comes when you don't even understand why it works. Someone here wrote something about bikegears, bike gears are simple but many people don't understand the concept of "Don't change gears under load" and they still mess up their gears and/or break their chains and derrailleurs.

    Funny enough, isn't grouping people like that and saying something like "He will become a dev like that" is simple too? It's an easy way out I reckon.
  • 0
    @d-fanelli xD Damn...hahahahahaha
  • 0
    @AKDasCode idk if these people finish their degree at all, or if they do finish it, even end up in positions that are relevant to it
  • 0
    @LotsOfCaffeine I see, thank you :3
  • 0
Add Comment