r/cpp • • Sep 30 '21

Why is c++ community so pedantic in stackoverflow?

Please don’t get me wrong. What i mean is why answer “you need read books”, “you should read the documentation”, or focus on tangent things instead of actually try to answer the questions?

in contrast, here in reddit, i even get job offers when asking questions.

260 Upvotes

177 comments sorted by

View all comments

Show parent comments

48

u/[deleted] Oct 01 '21

If you're not pedantic in C or C++, instead of stack overflow you get buffer overflows.

1

u/[deleted] Oct 01 '21

I'm ok with buffer overflows, I can use a garbage collected language when the situation is getting out of hand.

4

u/[deleted] Oct 01 '21

What does garbage collection even have to do with buffer overflows?

Yes, languages that run on virtual machines are 'usually' more memory-safe than C, but you don't need the overhead of running an entire userspace operating system if you just follow the good practices in your language.

2

u/[deleted] Oct 01 '21

Have you ever seen a buffer overflow in a program written in a garbage collected language?

Yes, languages that run on virtual machines are 'usually' more memory-safe than C, but you don't need the overhead of running an entire userspace operating system if you just follow the good practices in your language.

Not all garbage collected languages run in VMs, golang for example.

2

u/Kered13 Oct 02 '21

I mean, strictly speaking garbage collection and bounds checking arrays are orthogonal concepts. It is true that they almost always come hand in hand though.

1

u/[deleted] Oct 01 '21 edited Oct 01 '21

golang puts a lot of virtual machine functionality in the binary, it's not that different.

And it's also not memory safe if you don't follow the best practices, just like any language.

And again, having a garbage collector has nothing to do with memory safety. Rust is the most memory safe language available, and has no garbage collector, and you can use a GC library to manage memory in C, which won't make it memory-safe.

1

u/[deleted] Oct 02 '21

The safety checks aren't necessarily a feature of the VM.

1

u/[deleted] Oct 02 '21

The safety checks aren't necessarily a feature of the VM.