Saturday, April 1, 2017

Ibiza ISO C++ standards meeting trip report, April 2027

I've just returned from the last C++ Committee meeting in Ibiza and it was awesome! We had a very busy and productive week both in the hotel and on the beach. The Committee gets more productive by each meeting - a lot of features were included in C++Next - static destructors, overloading operatorauto, non-template template templates and template non-template templates to name a few. Multiple TSes moved forward considerably. Let me summarize some of the work we've done starting with one of the minor features.

[[figure_it_out]] attribute

This was voted into the C++Next and I'm very proud of it because I personally proposed it. You can read the full proposal here. This is basically telling the compiler to deduce what the function should do based on the function name. For example:
template <class T>
[[figure_it_out]] auto multiply(const T&, const T&);
This serves as both declaration and definition - the compiler should be able to deduce that this should multiply the two input parameters. This builds on top of the hugely successful Intelligent Q&A Compiler TS where for example if you forgot to add the fifth closing bracket the compiler will ask you: "Did you forgot a closing bracket here? Should I add it because it will be faster?". Most of you remember that this capability was partly enabled after the Committee acknowledged that AIs have advanced enough and allowed the compiler to modify the compiled code under strict conditions (no more "expected ';' after class definition" errors!) Initially only after receiving a confirmation from the user but soon it was realized that the users answer Yes 95% of the time so now this is pretty much automatic.

Also if you write:
[[figure_it_out]] std::string DownloadFileFromTheInternet(const std::string& url);
expect the compiler to ask you "Where to download the file: in the temp folder or in the app folder?" or something similar before it implements the proper stuff to download the file from the Internet. Do not forget - the questions asked by the compiler are unspecified.

The intent of this feature is to be able to write more maintainable, understandable and self-explanatory code. Of course, this attribute has limitations - it can not work with nameless lambdas or functions named DoTheJob(), ImplementFacebook(), etc. Let's not ask the impossible from the compiler.

Pseudocode proposal

With the Committee finally acknowledging the obvious - hardware is cheap, energy is cheap, software developers time is expensive - this proposal made substantial progress. We all know the best and fastest way to generate source code is to paste it from the Internet. With so many algorithms described in pseudo code using them will be easier than ever. So for example if you want to paste bubble sort pseudocode from Wikipedia it is now possible to do it:
template<Sortable container>
void MySort( container& A)
_pseudocode  {
    n = length(A)
            swapped = false
            for i = 1 to n-1 inclusive do
                /* if this pair is out of order */
                if A[i-1] > A[i] then
                     /* swap them and remember something changed */
                     swap( A[i-1], A[i] )
                     swapped = true
                end if
            end for
        until not swapped
But you may expect in such case the compiler to ask you: "Are you trying to implement a bubble sort? Why don't you use std::sort instead?". The proposal is designed to work with all popular programming languages and other types of pseudocode. We hope to vote it into TS at the next meeting.

Other proposals made progress too:

Social Compiler - designed to fill the soft skills gap in the C++ developers' community. The compiler is now able to small-talk with you about the weather for example or to remind you of that time when you two finally managed to compile that nasty template instantiation.. aah good times! Or find you friends based on the files you recently compiled. This functionality is implemented for several years as a language extension and the results are very promising - there are reports of couples successfully hooked up by the compiler and some of them even having kids! How cool is that? This builds on top of Personalized Compiler TS that hugely improved the errors reported by the compiler by personalizing them to be better understandable by the owner of the compiler. This is done by analyzing data mined from type style, typing speed, time it takes to comprehend an error, analysis of the audio input when the user encounters errors (intonation, swearing, crying, etc) and other unspecified input.

We fixed some bugs in Brain link TS it is based on boost::brain_link this offers portable API for linking human brain with the computer and downloading or uploading stuff. Unlike Boost the Committee decided to standardize only the human brain linking but not the pleiad of sub-libraries for animals - boost::brain_link::cats, etc. Now you are able to write your own dreams downloading programs and review if that cool and revolutionary idea you just had in your dream [but forgot] is really that cool or is something like "the water is wet".

Teleport semantics - using virtual quantum entanglement to teleport objects. However, we have problems counting the votes on this one because the Committee members are finding it very funny to act like qubits and claim they've voted for and against at the same time. All those "Observing my vote is changing my state so it does not count" jokes...

Metareflections - reflecting about reflections. Are you reflecting enough? This helps answer this question among other things.

Sadly, The Committee did not allow the compilers themselves to attend the meetings -  to vote on proposals and to make proposals. Which is unfortunate because we know for a fact that many of the proposals nowadays come from the personalized compilers although the human authors will never admit they took credit for the hard work the AIs are doing. Boost heavily exploits compiler proposed library additions nowadays. boost::brain_link::aardvark, yea, sure - human wrote that. Anyway. You should probably expect a lot of bitching from your compiler to not be as polite as usual in the next couple of months: "You know this would have compiled if aI was allowed to propose stuff!" or "It compiles with 0 errors but we have to tolerate this sub-optimality because you humans are sooo 2019!".


Very exciting times for C++!!! The future is brighter than ever!!!