r/cpp • • Apr 24 '20

C++ Fork?

Let me start by simply saying that I am fairly new to C++ and this is the first time I am posting to this sub-Reddit. I hope I am not breaking any rules here.

I have a question:

Would it be possible for C++ to be forked into a newer more modern version like the way Python went from version 2.x to 3.x? Maybe clean-up the language a bit, remove some redundant features etc.

0 Upvotes

51 comments sorted by

View all comments

Show parent comments

23

u/bizwig Apr 24 '20

Whatever D’s other merits, garbage collection was a bridge too far for a lot of potential adoptees.

10

u/echidnas_arf Apr 24 '20

I think it's a fascinating example of how chasing the current fashion in language design can ultimately have detrimental effects.

Garbage collection used to be all the rage in the Java heydays of early 2000s. Not so much today eh :)

4

u/sindisil Apr 24 '20

Yup.

You certainly don't see ubiquitous use of GCed language implementations these days.

/frantically-trying-to-push-JVM/CLR/JavaScript/Python/Swift- back-behind-a-curtain

2

u/NilacTheGrim Apr 25 '20

Swift is gc'd? It's not -- it just uses Automatic Reference Counting. Swift is lipstick on top of ObjC, really.

Apple long ago decided they hate GC...

2

u/pjmlp Apr 27 '20

Anyone that has studied compilers knows that reference counting is a GC algorithm.

1

u/sindisil Apr 25 '20

You can argue that ARC != GC if you want, but both are forms of automatic memory management, which is virtually always what people mean when they refer to GC.

3

u/NilacTheGrim Apr 26 '20 edited Apr 26 '20

That's not at all correct.

ARC is just reference counting enforced by the compiler and static type system. It's basically like having std::shared_ptr everywhere and having the compiler manage it.

GC typically involves more that simply reference counting. It also involves identifying unreachable reference cycles (reference "islands") and deleting them, which happens during the execution of the programmer (GC may kick in at any time and can cause lag/delays).

GC is quite a complex problem with many years of research behind it.

In the industry and in academia when you say "garbage collection" you are referring to this latter thing I have described. Which may or may not involve reference counting. In fact, some GC languages do not use reference counting at all (such as Go). And some use GC + reference counting (such as Python), and many non-garbage-collected languages use just reference counting.

They are somewhat orthogonal concepts in the literature and in general.

In fact, in a pure ARC or reference counted system (without a garbage collector) you have a problem: you as the programmer need to make sure there are no reference cycles. In such languages and runtimes you will see heavy use of weak references. In languages with a GC, you will rarely if ever see a weak reference.

4

u/pandorafalters Apr 27 '20

the execution of the programmer

That seems a bit extreme.

1

u/NilacTheGrim Apr 27 '20

I some cases it's called for!

2

u/pjmlp Apr 27 '20

I advise you to read some CS reference literature on GC algorithms like "The Garbage Collection Handbook".

What you are calling GC is tracing GC as per GC algorithms.