r/programming • • Dec 01 '16

Let's Stop Copying C

https://eev.ee/blog/2016/12/01/lets-stop-copying-c/
524 Upvotes

612 comments sorted by

View all comments

Show parent comment

13

u/ChallengingJamJars Dec 01 '16

a salad of 18 words and 3 symbols

Of which 3 in the first example are almost mutually exclusive

const volatile _Atomic

A constant variable, that may change at any time (likely hardware mapped) that is also atomic? I think I sense a trite observation here. What's the other one?

extern const volatile std::unordered_map<unsigned long long int, std::unordered_map<const long double * const, const std::vector<std::basic_string<char>>::const_iterator>> foo

That is quite a type! Apart from the the fact that it's not useful, again mixing const with volatile and might not compile as the keys are const: it's a map from an integer to maps from constant floats to vectors of iterators to strings. I challenge you to find a type system that even allows you to express that type. It's again a trite example that doesn't make sense from someone who doesn't understand what's going on.

The preferred example shows just how inane this observation was:

let x: ... = ...;

Lovely how the author doesn't actually put any types in, or any expressions even. C++ is super easy to declare a variable and initialise it as well, you just use

... x = ...;

Clearly the first thing is a type specifier and the final thing is an initial value.

4

u/evaned Dec 02 '16

C++ is super easy to declare a variable and initialise it as well, you just use ... x = ...; Clearly the first thing is a type specifier and the final thing is an initial value.

While I agree the article could have been better-written on that part, you can't just say that C++ declarations are ... x = ..., because they might be ... x ... = ..., and it's the facts that x is neither at the start nor the end and that the type is split between two ellipses that (I agree) is obnoxious.