r/ProgrammerHumor • • 2d ago

Meme unityHasBeenAchievedByCompilerDevs

Post image
218 Upvotes

32 comments sorted by

73

u/FishWash 2d ago

No no unity is C#

18

u/deanrihpee 1d ago

but those C# somehow turned into cpp too in the end (IL2CPP)

57

u/hpyfox 2d ago

They said C++ was "suppose" to be backwards-compatible/superset of C, but then type-handling walks into the room.

Other problems exist with C and C++ compatibility but that's one of them.

4

u/nimrag_is_coming 1d ago

It's now sort of you CAN write C++ compliant C code, but there's things that you can do by default in C (such as implicitly converting from void pointers) that C++ doesn't like you doing without an explicit cast

1

u/setibeings 15h ago

You can also write C compliant C++ code but like... why?

1

u/hpyfox 11h ago

H- how??

2

u/setibeings 10h ago

Just stay within the subset of c++ and c that's valid in both, then give your file names .cpp extensions, and pass cpp specific arguments to your build system, but again.... why?

35

u/Legal-Software 2d ago • Bravo

Says no one who has ever compared CPU and memory load of the two side-by-side.

8

u/realrealvantheman 2d ago

Holy bro how many languages does this guy know

11

u/fr000gs 1d ago

there's a limit of 6 emoji on the flair for this sub

21

u/deanrihpee 1d ago

need more, so some of us can look like a North Korean general

7

u/MissinqLink 1d ago

Well it’s not like they give you a test before adding them

2

u/gerbosan 1d ago

Thin?

2

u/rosuav 18h ago

Dark humour - it's like food in North Korea.

Not everyone gets it.

2

u/gerbosan 13h ago

Like:

It's hard being the fat kid in the class,
it's even harder being the fastest kid in the whole country

1

u/Moist-Snow-8127 1d ago

Hello

1

u/Moist-Snow-8127 1d ago

Wait I forgot to put Lua in it!

1

u/NomaTyx 23h ago

lowkey the more languages someone has on their badge the less seriously I take them

3

u/RealSlyck 2d ago

Versus JavaScript, they might as well be WinkleVii.

6

u/satansprinter 1d ago

I just want c with namespaces and structs with methods

4

u/Percolator2020 1d ago

I mean that’s how it was in the beginning and for a very long time, especially in embedded.

3

u/JackNotOLantern 1d ago

C is mostly compilable in c++ compilers. I think the only incompability is that c++ has more key words than c, so if e.g. a variable in c is called something that is a keyword in c++, then it will fail. 

4

u/tstanisl 1d ago

There is a lot of other differences. C has multiple constructs not available in C++. C++ is basically a fork of some random pre-C89 dialect of C.

3

u/geekusprimus 13h ago

Yup. VLAs, while much maligned in C, are technically part of the C standard. They are not part of the C++ standard (though many compilers support them as extensions). The restrict keyword is another one that C supports but C++ does not. C++ is also generally much stricter about how types and casting are handled, handles inline functions a bit differently, etc.

1

u/tstanisl 12h ago

VLA are not maligned but misunderstood. Probably the most misunderstood concept in C, where many still perceive it as just a syntactic sugar for risky stack allocations, a deeply flawed view. Newer C standard tried to brings them back into the spotlight.

I would not say that C++ makes cast stricter, C style casts are perfectly valid in C++. It just adds more ways to cast things giving a bit more way to express the intensions (i.e. const_cast). A huge misstep  is disallowing implicit cast from void* which actually is one of the safer and more convenient implicit cast. Forcing such cast can hide a real defect and this practice is strongly discouraged in C coding guidelines in favour of other safer idioms.

It is worth to mention compound literals that don't exist in C++, and designated initializer which subset was partially adopted by C++.

Other subtle difference is changing type of some expressions where C traditionally used int. The sizeof 'A' is probably the most known example.

2

u/stupled 1d ago

Is all C underwraps

2

u/dumael 1d ago

One has abstract base virtual private destructors, the other doesn't.

1

u/conundorum 23h ago

They both do, it's just that you have to do it all by hand in C, and the compiler does 90% of the work for you in C++.

(Fun fact, C++ vtables are actually just an automation of the vtables that C programmers write by hand.)

1

u/tsato-7408 4h ago

The function-pointer table is only part of it; C also makes the abstraction's object layout and lifetime conventions explicit.

1

u/krak_1 23h ago

Laughs in embedded C impossible to pronounce compiler name.

0

u/Chingiz11 1d ago

TCC would beg to differ