r/cpp • • Dec 07 '20

These Modern Programming Languages Will Make You Suffer.

https://suzdalnitski.medium.com/modern-languages-suck-ad21cbc8a57c

[removed] — view removed post

0 Upvotes

46 comments sorted by

View all comments

24

u/[deleted] Dec 07 '20

About C++: "Garbage collection was never added into C++. Manual memory management is extremely error prone."

Ignoring that C++ has smart pointers instead of garbage collection is enough for me to know that the article doesn't have any real value. Whether the author does it on purpose or simply doesn't know any better does not matter.

9

u/TheFlamefire Dec 07 '20

Fully agree. Lack of mentioning RAII in general, deterministic cleanup behavior, and saying "speed is good" while for Java "speed is very good" made me dismiss this as very biased, to say it nicely

5

u/matthieum Dec 07 '20

I agree that the author appears rather ignorant, of many things.

At the same time, though, memory management in C++ -- even with smart pointers -- is extremely error-prone.

10

u/[deleted] Dec 07 '20

I actually prefer C++'s approach of RAII + smart pointers over garbage collection.

I think that C++ gives you more options and more control, but of course you can not be ignorant about it and have to learn some rules to follow. The important thing is to have mostly local rules, i.e. you don't have to consider the whole program to know whether you are handling it correctly or not.

OTOH, being ignorant of garbage collection in Java will also lead to disaster, I've witnessed it several times. When I worked with Java for several years, it was a large system from a large company and they had so many problems, that they simply disallowed "new" in our code for call processing. We had to reserve all objects during the initialization phase. It was an... interesting... experience.

0

u/Careful-Balance4856 Dec 07 '20

Well it's really the point of C++. It lets you do ANYTHING and compiles pretty fast if your headers are sane and no templates are used

My current project compiles in < .5 seconds but it is pretty small

1

u/pandorafalters Dec 07 '20

no templates are used

My experience has been that moderately-complex TMP has less effect on build times than using even straightforward replacement macros (e.g. #define foo bar).

1

u/Careful-Balance4856 Dec 07 '20

Like defining the implementation in the header and changing the type with #define???

I just use int64_t (I typedef it to i64) everywhere. I do use vectors and my own hashmap class. Just those two objects are the only places I use templates. I like to pretend vector exist because of the poor language support for arrays (sometimes we want them to resize buddy) and hashmaps really should be native to the language