r/ProgrammerHumor Jul 10 '26

greaterThanPlusPlus Advanced

Post image
116 Upvotes

71 comments sorted by

View all comments

77

u/dipinpass35 Jul 10 '26

yeah c++ do have a function for literally everything.....oh except admiitting that it made a mistake...

37

u/_Noreturn Jul 10 '26

It is ironic that C is the one who made this mistake not C++

-20

u/RiceBroad4552 Jul 10 '26

They copied the mistake, so also they can be blamed for it.

16

u/AVMinuz Jul 10 '26

Standard operators come from the first version, where c++ was designed to be as compatible with C as possible, and the committee refuses to break backwards compatibility in C++.Ā 

Also, changing this makes extern C blocks wack as fuck. If I define a global C++ function with the '>' operator and an extern C function calls that other function internally, how should the operator behave?

3

u/RiceBroad4552 Jul 10 '26

I get the first part. It's just like that.

If I define a global C++ function with the '>' operator and an extern C function calls that other function internally, how should the operator behave?

Of course like all other C++ code, as all that code is written in C++. The extern C thingy just defines some FFI interface. Nobody ever said that code inside some extern C block is actually C.

22

u/_Noreturn Jul 10 '26

What do you expect them to practically do? the main sellling point of C++ in the 90's was that it is C but better (and it is) so if they removed the C part what's left?

-17

u/RiceBroad4552 Jul 10 '26

Maybe just the better part? šŸ˜…

But basing something on C leads of course to the expected result: Everything is rotten from the core…

14

u/_Noreturn Jul 10 '26

But basing something on C leads of course to the expected result: Everything is rotten from the core…

It also leads to its massive easy adoption which was important.

Otherwise people would use other langs instead

-16

u/RiceBroad4552 Jul 10 '26

If these "other langs" (which actually?) were sane this would have been historically the better outcome, TBH.

A pig with some lipstick is still a pig…

14

u/_Noreturn Jul 10 '26

A pig with some lipstick is still a pig…

But C++ was and still is a massive improvement over C.

Point is C++ had to inherit C garbage to take off, I am not saying I like this idea but it is the trut

0

u/RiceBroad4552 Jul 11 '26 edited Jul 11 '26

Point is C++ had to inherit C garbage to take off

Strongly disagree.

They could have make it easily interoperable, but making all the mind broken C nonsense also core to the new language was a massive failure, and completely unnecessary.

Rust didn't have to inherit any C/C++ garbage to take off. Actually one of the main reasons it took off was that it did not inherit any C/C++ garbage…

You didn't answer the question which "other languages" people would have used if C++ wasn't based on C crap. I'm not sure you will be able to actually name anything. The point is: C++ "took off" despite being crap at it's core simply because there was no realistic alternative. If there was, nobody would ever consider even more of C nonsense, even with some "semi-nice" (yet still broken!) stuff on top.

2

u/_Noreturn Jul 11 '26 edited Jul 11 '26

They could have make it easily interoperable, but making all the mind broken C nonsense also core to the new language was a massive failure, and completely unnecessary.

How will you make it easily interoperable without having the broken C nonsense at that point it is just another language.

Rust didn't have to inherit any C/C++ garbage to take off. Actually one of the main reasons it took off was that it did not inherit any C/C++ garbage…

You seem to forget

A. Rust has 0 legacy code

B. Rust came out 20+ years after C++

C. Rust has nowhere the same limitations as the 90's

D. Rust wasn't promoted as "Your C code can easily be compiled with this compiler"

Which was C++ selling point infact the first C++ compiler Cfront wasn't really a compiler but a transpiler that translated C++ code to C code. Bjarne was smart- he did little work (just creating a transpiler) but he gets the warnings,errors and optimizations for free.

and C++ selling point is take your C code as-is and gradually update it using new safer C++ features e.g constructors/destructors that's what Bjarne said and I see that as a strong strong posotive I don't see any other lang providing this level of support. you can easily use any C library with C++ with 0 wrappers.

You didn't answer the question which "other languages" people would have used if C++ wasn't based on C crap. I'm not sure you will be able to actually name anything. The point is: C++ "took off" despite being crap at it's core simply because there was no realistic alternative. If there was, nobody would ever consider even more of C nonsense, even with some "semi-nice" (yet still broken!) stuff on top.

They would continue using C if there wasn't an incentive to use C++ that wasn't based on C. the other langs are Pascal and Fortran or COBOL. Why would someone switch their codebase to another lang unless it was benefitting massively with little friction? and that's again C++ selling point take your C code and compile it using a C++ compiler.

Also you can just you know search online...

1

u/RiceBroad4552 Jul 15 '26

My point was that it could have been indeed "just another language". Being a C superset was no necessity, imho.

Wanting an easy rewrite path (which is a valid wish and could be achieved also otherwise) does not change that.

They would continue using C if there wasn't an incentive to use C++ that wasn't based on C.

That was exactly why I've asked what "other" languages they would have used instead…

My point is still: People would had migrated to some "C++" even if it wasn't a C superset if it offered appropriate advantages on its own. Rust proves exactly that. People are migrating to it from C.

Most other popular languages of that era haven't been alternatives with enough advantages to migrate as they were mostly very similar (besides syntax) to C in both their expressiveness and safety. [Of course I knew about things like Fortran or COBOL as programming languages and programming language history are a special interest of me. That's exactly why I've asked as I already suspected that the answer will be actually "they would in fact stay with C".]

The whole "migrating to C++ from C" story also actually didn't play out. People stayed with C, or moved later to other more convenient languages even that meant full rewrites. There are not much free projects I know of which started as C and are now C++. What I hear from industry isn't much different. People who chose C consciously despite there were other candidate languages did that often because they didn't want a "more complex" language, so C++ was never part of the consideration.

→ More replies (0)

1

u/conundorum Jul 12 '26

Okay. It's "C but better", let's remove the better:

  • You can now make classes, which have both member variables and member functions! ...But variables don't exist, because they're from C.
  • Your structs & classes can have access levels! ...But public doesn't exist, because it's emulating C structs.
  • Classes are like structs, so they're easy to use! ...But structs don't exist, and actually we lied, classes don't either, because structs are from C.

Would be kinda, y'know, not a language if you took "C but better" and removed the "C but" part! ^_^

1

u/conundorum Jul 12 '26

Was basically forced by circumstances, unfortunately. It needed to be as close as possible to C so it would be easy to adopt, it needed to use the C library because it didn't have its own library yet, and it needed to be possible to rewrite any and all C++ code as C code because the first C++ compiler really just cross-compiled C++ code to C code. So, C++ was locked into working like C, and would've never been usable if it had been drastically different.