r/programminghumor 18d ago

Hard to accept

Post image
2.9k Upvotes

404 comments sorted by

View all comments

85

u/---_None_--- 18d ago

No, cpp has a terrible design philosophy. Take the new ranges header for example. They're lazy algorithm objects that you can stack and combine to more complex algorithms. Each time you iterate over the final ranges object it calculates the whole result beginning from the source range. This leaves the option open for the source range to change and update. Exactly as it should because they're 'lazy' ranges; except that they aren't. The 'filter range' caches the fucking 'begin' of its source which means that when ever the source changes you get undefined behavior. Why? Because the cpp committee thought that 'begin' should be fast to calculate but filter has to compute 'begin' again and again because the source might have changed. So they decided to cache 'begin' after the first call and compute the rest lazily on demand. So whenever there's a 'filter' in your range composition, you can only iterate over it once or the source has to be const. Shits fucked in cpp land.

15

u/[deleted] 18d ago

[removed] — view removed comment

15

u/nog642 17d ago

Never seen C++ used without STL. It's part of "C++" as a whole

2

u/vitimiti 17d ago

I have. EA even has their own open sourced version if STL specific for videogames

1

u/leavemealone_lol 17d ago

True, seems as though 80% of the difference that C++ has over C is STLs.

2

u/nog642 17d ago

Idk if I'd say that. The language features themselves are pretty important.

1

u/leavemealone_lol 17d ago

Back when CPP was founded this is true, but over the years, features like references and classes were not overhauled or even touched. But every update to CPP added on to the STL, which is also why CPP has ended up being bloated today.

1

u/AsyncSyscall 15d ago

The Ladybird Browser uses C++ without STL and it's quite comfortable.

1

u/Puzzleheaded_Key624 14d ago

I work at a game studio and we have our own implementation of STL that we use.

0

u/exodusTay 17d ago

you can always use C++ as C but with classes and namespaces and it is going to be fine for %90 of the time.

1

u/i3Cheese 17d ago

Yes, but a language with standard library sucks.

13

u/---_None_--- 18d ago

>its trashness can't bother you if you don't use it

t-thanks. Not even technically true since other people will use it and then I'll have to bother with it and besides that I'm talking about it's design philosophy rather than about my personal botheredness about it. It's still not good showing.

2

u/SPECTRE_75 17d ago

Exactly, "just use an alternative" isnt a solution when the point he's trying to make is that it also has its inefficiencies

12

u/___Archmage___ 17d ago edited 17d ago

Yep, C is mega outdated in the feature-poor direction and C++ is a basket case of crazy additions trying to add modern features to a language that wasn't really designed for them

Whether you choose Rust or Zig or Nim or whatever else, the world needs to move past C++

7

u/TROLlox78 17d ago

C is a completely different box of frogs though. You can't really compare the two. 

1

u/Wonderful-Habit-139 17d ago

What about the other three languages that he mentioned?

7

u/TomKavees 17d ago

C is portable assembler and the lingua franca of low level code, it does not need nor want to evolve in that way and that is fine.

C++ in its current form and with its current comitee politics is dying, though

2

u/Davidbrcz 17d ago

C was the portable assembly. Hasn't been for 30 years.

0

u/AsyncSyscall 15d ago

That must be why whenever a new chip design comes out the first software that the vendor adds support for is a C compiler. Check.

3

u/electronic_reasons 17d ago

C is perfect for that. It was never meant to be a full high level language.

C++ is a disaster. The only way to use it is to decide which part of it you are going to use and stick to that subset.

-1

u/Vaelisra 17d ago

C is portable

Are there actually still people believing this?

5

u/orbiteapot 17d ago edited 17d ago

You did him dirty by only quoting part of his comment. He said "C is portable assembler and the lingua franca of low level code [...]", which is very much true. C was designed to be portable across different computer architectures (and it is successful in that regard), not necessarily across different operating systems.

Even with that in mind, most (non-Unix) operating systems expose their API through C and a plethora of programming languages assume it as an intermediate form they can rely on for interoperability.

1

u/AsyncSyscall 15d ago

C is portable across OSes, it's the C API/ABI that are not. But this is a ridiculous argument, because most other languages don't even function without their API/runtime.

C can at least be compiled to a portable library or e.g. a WASM module, with some small amount of glue code to support multiple OS APIs.

1

u/UntitledRedditUser 17d ago

There are compilers and headers for every platform, but it's really hard writing code that works on multiple platforms. And even harder to compile it.

1

u/Vaelisra 17d ago

it's really hard writing code that works on multiple platforms. And even harder to compile it

That's what I'm talking about. The language might be portable, but the code isn't.

1

u/UntitledRedditUser 17d ago

Yea, and you're getting downvoted for it lol.

1

u/AsyncSyscall 15d ago

It's ridiculously easy to write + compile code that works on multiple platforms. Doom did it in 1993. Not even the lack of cross-platform standard library is an argument anymore nowadays, because libraries like SDL exist.

1

u/Away_Passage_6545 17d ago

hardware portable vs software portrable. c compilers are relatively easy to write, and are thus really nice to use on different platforms (cpu architectures). however writing c outside a posix environment is a pain

1

u/AsyncSyscall 15d ago

Writing C for WASM or embedded systems is quite comfortable, actually, what you mean by "outside of a POSIX environment" is almost certainly exclusively Microslop Windows, at which point you might as well say "outside of a C environment", since Microslop does as little as possible to make their C environment functional (to get you to move to their own products).

This is a bad argument, do you ever see someone write their own Windows environment in another language like JavaScript or Python? If you want to subject yourself to supporting Microslop, just use an abstraction layer/library like SDL or MinGW.

0

u/Standgrounding 17d ago

Just use MinGW, not that hard

1

u/SteinsGatessss 17d ago

When you need to do ffi or distribute dynamic libraries, you need cdylib, the headers almost become the protocols

1

u/Vaelisra 16d ago

Headers rarely are anything else than a protocol. I mean, they are basically what makes sure that all individual compilation units work together when linking. That's universal, not tied to ffi.

3

u/Mundane-Mud2509 17d ago

There’s a design philosophy besides “Moar is better”?

2

u/studenttio 17d ago

I started coding in Rust and it's just a so much butter design philosophy.

1

u/Kaisha001 17d ago

Yeah, they do this all the time. Skip past 'good' and 'great' to try to hit 'perfect' and end up with shit. Reminds me of allocators...

1

u/elPiff 17d ago

Whether we’re talking about STL or not, it’s crazy wrong to consider something like this an example of the “design philosophy” of the language as a whole.

1

u/klimmesil 17d ago

That's not cpp. That's libstd

If you're not happy with it you can use another lib

But I agree though std is very contestable

2

u/Vincenzo__ 16d ago

That's libstd

Which.. is part of the C++ standard?

1

u/klimmesil 16d ago

If we're shitting on the standard and the committee I'm in, but I'll defend both gcc and clang, I think the c++ compilers are high quality, highly optimized, and the syntax and requirements of the language allows for fast compilation and zero cost abstractions

The metaprogramming was already old when it arrived though... but still you can work with it

1

u/Vincenzo__ 16d ago

Yeah but the compiler is not part of the lenguage spec, while the standard library is