Rightconst.dev – Put const where it belongs
rightconst.dev
Rightconst.dev – Put const where it belongs
1–4 of 4 posts
Re: Rightconst.dev – Put const where it belongs
#2That's just silly. I like C++ for its legacy and contributions but my god is it a confusing AF language for no reason. It can easily have syntax for each of these cases instead of reusing keywords and symbols in the most confusing way.
Re: Rightconst.dev – Put const where it belongs
#3> uint32_t const *const foo; That's just silly. I like C++ for its legacy and contributions but my god is it a confusing AF language for no reason. It can easily have syntax for each of these cases instead of reusing keywords and symbols in the most confusing way.
that said, I think the more extreme examples probably come from C codebases, where these kinds of declarations are actually highly useful as well as highly logical, compared to C++ which usually tones these kinds of things down via STL and higher level abstractions.
i'd also argue both C and C++ still have their place as legitimate tools for their purposes, and especially C still has no real competitor that can match it for its purposes.
Re: Rightconst.dev – Put const where it belongs
#4> uint32_t const *const foo; That's just silly. I like C++ for its legacy and contributions but my god is it a confusing AF language for no reason. It can easily have syntax for each of these cases instead of reusing keywords and symbols in the most confusing way.
most of these combinations actually have legitimate use-cases. and, kind of like what the article is pointing to; it's really only confusing if you learnt it the bad way from the start. that said, I think the more extreme examples probably come from C codebases, where these kinds of declarations are actually highly useful as well as highly logical, compared to C++ which usually tones these kinds of things down via ST…
Take the simple example of a pointer. It's just a data type, but it gets its own symbol. Ints or floats do not get their symbol, and pointer similarly could just be a keyword and not a symbol to be consistent. Pointer could be a type keyword for declaration, and * (asterisk) could be the operator to retrieve a pointer value. This disambiguates it easily and intuitively.
But again, I still like C++ and consider all of these inconsistencies as side effect of its longed lived legacy. It needed to change and evolve and making comprises is hard when it's already part of so many systems. I'm also not sure there's anything better. I have not yet learned Rust but it seems it's aiming for a different kind of experience alltogether. Not sure what could be the real successor to C++ while still remaining compatible in the way C++ is to C.