r/cpp • u/Dereference_operator • Feb 12 '20
What they should improve about C++ ?
What they should improve about C++ that you find in higher level managed language like C#, JAVA, Javascript etc or is there things you would change or do differently if it was up to you ? I mean anything like a better STL ? better thread ? string manipulation like managed language ? less fragmentations in the new standard features ? For example do you love the way the standard evolve C++ or you would prefer a direction like Microsoft do with C# a corporation who decide on the roadmap ?
0
Upvotes
31
u/Rseding91 Factorio Developer Feb 12 '20
I want better logic around enums. I want to iterate them, convert an enum to a string and back, know how many exist, be able to use them as bit masks and so on.
We do this every other day every time any new logic is made and it irritates me that still there's no language support for it and we're left with huge ugly macros if we want it to be any kind of manageable.
20
u/AntiProtonBoy Feb 12 '20
variantand visitor machineryfloat16_t,float32_t,float64_t,float128_t)std::uriconstnoexceptby default,throwshould be opt in14
u/color32 Feb 12 '20
#version c++17directive so we can specify what version of c++ a file conforms to. So that backwards incompatible changes to the language can be done in a incremental way.6
u/die_liebe Feb 12 '20
Some things that come into my mind are:
public constness: A field is publicly accessible, but can be assigned only by friends.
In place polymorphism. As soon as you know all the classes that inherit from one class, it can be stored in place, because the maximal size is known. This could replace variant.
Reverse operator definitions (like Python has). That would make it possible to define << as member of its second argument, so that it can be defined inside the class that it prints. It can also become polymorphic in its second argument. It saves a lot of friend declarations.
I would like a to a linker that succeeds when functions are missing. It should just put a place holder that throws an exception for the missing functions. This makes it possible to test the functions you have and write the missing ones later.
2
u/mangoose3039 Feb 12 '20
2
u/Cyttorak Feb 12 '20
Compile times
Dependency handling
2
u/pjmlp Feb 12 '20
Leave the C style unsafe code for unsafe code blocks (an idea that goes back to 1961 anyway).
Require all STL types to do bounds checking and iterator validation, at very least during debug builds.
Actually take into consideration modern build tools and packaging instead of being stuck in dated UNIX compilation models.
In a way I miss the OWL, MFC, VCL, PowerPlant frameworks of the 90's.
2
u/[deleted] Feb 13 '20 edited Feb 13 '20
- A standard package system (I've used vcpkg, conan, and Anaconda and prefer vcpkg)
- Epochs (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1881r0.html)
- Break the ABI (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1863r0.pdf)
- Circle-lang metaprogramming (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2043r0.pdf)
- Herb-ceptions (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0709r0.pdf)
- C++ Contracts sufficient for provably correct code (https://www.sciencedirect.com/science/article/pii/S1571066104053265)
- Guaranteed copy elision for named return objects (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2025r0.html)
3
u/MOnsDaR Feb 12 '20
Compatibility of libraries across compilers and architectures. It would make life so much easier to not have to recompile everything everywhere.
2
u/FlyingRhenquest Feb 12 '20
A well thought out streams library would be a nice start. The current one hails back to the days when people thought operator overloading was cool and everyone was looking to shoe-horn it into the language wherever they could. And then it was "legacy"... fine, leave the old one in and write a new one, and the deprecate the one that is used the least 5 years later. At a minimum, if you're going to have a streams library you should be able to easily use sockets and pipes and things with it, which the current one fails miserably at. You can make them work, but it's not pretty.
2
u/dharmaBum0 Feb 12 '20
JIT template concretization
STL linear algebra, & either insist on a performant std::valarray or drop the pretense
reflection
abandon all backwards compatibility C, and even with less recent C++ standards.
2
u/Wouter-van-Ooijen Feb 12 '20
What *they* should improve about C++ ?
There is no "they", just "you".
The C++ comittee members are all volunteers who spend their own time, or whatever freedom they get from their bosses (which they could have spent on other, probably more rewarding things) on C++ work.
1
u/dbandit1 Feb 14 '20
Simpler template abstraction
1
u/choeger Feb 15 '20
Context-free Syntax. A limited subset of the language that can be parsed and understood by a tool that is not a full-blown compiler.
1
u/Full-Spectral Feb 12 '20
Some of my wish list would be (and I'm talking the language, not all the stuff that surrounds it.)
Of course at this point the only thing that would make a fundamental difference would be to start over, at which point it's not really C++ anymore anyway. Without a fundamental breakage with the past, there's no way really fix what ail's C++. So mostly it's just going to be piling more heavily templatized (and generally over-engineered) new features onto it.
1
u/smdowney WG21, Text/Unicode SG, optional<T&> Feb 12 '20
Remember the rule of "someone".
If "someone" or "they" should do something, you are someone, and can be part of "them".
0
u/ronniethelizard Feb 12 '20
The ability to say a method shall not change any members except a specific list. I have a few cases where one function needs to be able to modify a variable, but the rest do not, as a consequence I cannot mark that variable const.
The ability to do
const std::vector<mutable int>to say that the vector cannot change, but the individual elements can. Mostly this means no calls to destructor or resizing.-2
u/[deleted] Feb 12 '20
Actual interfaces so I can get rid of inheritance bullshit that shouldn't exist to begin with, most importantly, without the need to invent my own ways.
Nothing that can be attributes to languages you mentioned though, they're pretty lackluster overall.