62

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
  • 24
    This is why I simply don’t try anymore.
  • 14
    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
  • 8
    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
  • 3
    They should probably go learn some higher level language first then..

    Care to share those articles you posted? :)
  • 6
    @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
  • 7
    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...
  • 8
    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
  • 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.
  • 4
    @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
    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
  • 1
    I'm still at "why's nobody mentioned shared pointers".

    But in response to @AKDasCode, if you learn something like java or python, anything with a garbage collector, you don't need to understand stack vs heap, they hide a lot of complexity, so you can kinda go far. Most devs I've worked with are on the "add more servers" side and have never worked in an environment where you can't. I'm not saying good or bad so..
  • 1
    I also wouldn't necessarily say the standard goes down, but the barrier to entry definitely does.
  • 1
    @atheist We discussed them but I was still trying to reach the concept of stack, heap and lifetimes.
  • 0
    For some reason those discord servers members and mods irks me a lot😂
Add Comment