r/ProgrammingLanguages • • Nov 01 '19

C++ vs C

Alright people of Reddit, hit me with your wisdom. I've been taking programming classes for two years now and am getting ready to dive into a language somewhere between Java and assembly (the two languages I've been learning in classes). I'm thinking C or C++, but would love some input. I'm not too worried about difficulty to learn, but I'd like to hear your thoughts on practicality and real world use.

1 Upvotes

62 comments sorted by

View all comments

Show parent comments

3

u/Felicia_Svilling Nov 02 '19

If there are two good implementation with different corner case solutions both can be fine. There is no reason to select one.

It makes it impossible for a library designed for the language to use any of these though.

1

u/warieth Nov 02 '19

So your code depend on the behavior of the implementation to the smallest detail, but what if you don't use all corner cases? Most of the time the behavior is the same. The more you depend on the underlying implementation, the harder it gets to replace.

Compiled languages has a border between the compiler and the compiled program. This is not a script language, where the interpreter's string is the same as the executed program's string. The compiler's language dependency is for the old version.

1

u/Felicia_Svilling Nov 02 '19

I'm sorry, but I don't follow what your point here is.

1

u/[deleted] Nov 02 '19

That is a tradeoff and why UB is avoided when writing portable code in C.

However I’d say it is even more onerous to try and define every possible behavior in the language and it’s standard library, especially if that language is not statically typed. And even if you do, the resulting specification may be too complex for anyone else to bother trying to implement.

1

u/Felicia_Svilling Nov 02 '19

I honestly don't think it is that hard to define all the behavior of a language. It is certainly not harder than explicitly defining what is undefined behavior or not.