Current Proposals for C++17
meetingcpp.com
meetingcpp.com
I already use it as a "catch all" over specialized functions (gcc -std=c++17).
int foo(auto a, auto &&b);
to int foo(a, &&b);
? Too big a change? Too much magic? Maybe more difficult to read or parse. The argument "It's not clear that the function is a template" isn't there any more, though, so it seems reasonable to me.Interestingly, I remember hearing about this exact problem in the context of Swift's closures; if you want type inference, you need to leave off the parens around the parameters. This is mainly done (IIRC) because it's easier for the parser.
[1] http://blog.reverberate.org/2013/08/parsing-c-is-literally-u...
template <typename T1,typename T2>
int foo(T1 a, T2 &&b);
"auto" is shorter.When I used C++ last time this was always a huge ordeal.
You can already do "using ClassX", but yeah, the package management story in C++ isn't great.
There's a proposal for modules in C++[1], which should help, but as far as I know that's not going to be in C++17. Clang already has a (different) version implemented as well[2].
[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n446... [2] http://clang.llvm.org/docs/Modules.html
Its probably a bit easier with C as it has a common ABI, and C# as it only has one tool chain, and not multiple toolchains from multiple vendors like C++.
Modules will help here further.
This is the one thing I really like about .NET. C++ would be so much more accessible to beginners if it was easier to integrate other libraries. Even integrating something as common as boost is quite hard with Visual Studio on Windows.
A C++ implementation could provide translated units which encapsulate not only compiled code, but also contain compiled class declarations, such that these units can just be used without any preprocessing, tokenizing or parsing. That would be outside the language.
The C++ language as it stands is defined in terms of a textual representation: everything proceeds from translation units being scanned into preprocessing tokens and so forth.
To use a compiled class declaration, you would still need to see the source code somewhere, in some form, in some documentation. Otherwise, how would you know that the frobozz class has a freakout method which accepts two int parameters.
My honest if somewhat noobish question is: Why isn't support for features like type safety and so on being incorporated into CPUs themselves, like they did with SIMD instruction sets?
I mean, if so many languages require "runtimes" now, why haven't the features that are common across those runtimes, been factored out into hardware already?
Swift could theoretically be as fast or faster than C/C++, but C/C++ have decades compiler optimizations that are going to be hard to beat. I say Swift has the potential to be faster because of the pointer aliasing problems of C/C++, which Swift can potentially optimize (like why Fortran still can beat C).
But your question about runtimes and performance are kind of a red herring. High performance means utilizing the underlying hardware well. A lot of the popular modern languages were designed for convenience over speed and were designed in an era of ever-increasing single processor CPU speeds. Very few languages map to how hardware actually works so they give up speed. Few mainstream languages automatically vectorize _well_ and _reliably_ to automatically exploit SIMD (C/C++ don't really do this...we generally have to write the intrinsics ourselves if we care). Few mainstream languages do a good job exploiting the multiple cores/CPUs available to us (don't say threads...they are pretty poor. This is one interesting feature of Go). Cache locality is now extremely important to high performance and most languages don't let us really control this. (C/C++ give us some say on our memory layouts.)
C++17 is the first "big" standard change since C++11. It will likely be followed by a small bug fix revision, analogous to C++14, a couple of years later.
C++14 had relaxed requirements on constexpr, initializers in lambda captures, using auto for return type deductions, and a few other small tweaks.
struct Foo {
int i;
float f;
bool b;
// No constructor
};
std::make_unique<Foo>(1, 2.3f, true);
Doesn't compile, since make_unique requires an appropriate constructor (see https://isocpp.org/files/papers/n3588.txt for the rationale).It also doesn't work when Foo's constructor is private, even when called from a function that would have access to this private constructor.
And this is my beef with C++: Yes it's powerful, and I quite like it, but you sooner or later hit these speed bumps that unnecessarily complicate things.
"C++ use is on the increase. We need to improve C++ to sustain the momentum, not better serve the C++ programmers, not out of fear of competition."
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n449...
It was probably intended to be "..., to better serve the C++ programmers, ...". That would provide a contrast for the final "not" to be operating on.
"We need to improve C++ to sustain the momentum and to better serve the C++ programmers, not out of fear of competition."
The accidental repetition of not is not an unusual mistake, and the original sentence doesn't match the tone of the previous paragraph given that he says "I deem something 'major' or 'minor' based on what it does for users"
https://en.wikipedia.org/wiki/Java_version_history
https://en.wikipedia.org/wiki/C_Sharp_(programming_language)...
C++ did that in the 2000's, in that time there wasn't much news about standardization, because of this C++ was seen as legacy, people moved to other languages. The new languages such as Rust, Go etc. are also a result of this.
The C++ committee has now a process of ongoing standardization established, which will improve the language further, and make it easier and more efficient to write C++. Also, the standards are usually backward compatible for at least 2 standards. What gets removed is often obscure features like auto_ptr, random_shuffle etc. which are superseeded by better alternatives. Clang modernize can even get your code base automatically updated to a new standard.
I know, that some of you are left behind, as you are stuck with the traditional "almost never update the toolchain" model, but clang and other tools are such a leap forward, that this is not a model for the future anymore.
So, C++ ecosystem evolves to become better, and make you as a programmer more productive and lets you write easier and safer code.
Language features that ease your daily working with C++11/14:
- Lambdas, especially when working with <algorithm>
- ranged for loop
- auto instead of typing long types
- variadic templates increase compilation speed over the previous macro based simulation of this feature.
- the basic support for multithreading which std::thread & co offer.
And also, as always in C++: you only pay for what you use. You still can write code in old styles pretty well with C++14, same will be true for coming standards.
If your last exposure to C++ featured nothing but raw pointers, you should really give it a second look.