So I'm 33 and tinkering with C++ because it's the de facto language of my industry, but I'm continually frustrated by how difficult simple tasks are. I understand that the design of the language was based on speed over everything, but there is no reason a language this widespread and well-developed shouldn't have more tools for a beginner.
Although there have been many examples, my current beef is turning the current time into a string. This should be something as easy as:
string theCurrentTime = time::getLocalTimeAsString();
instead I get examples like this:
http://msdn.microsoft.com/en-us/library/a442x3ye.aspx
which is absolutely ridiculous. I won't post the code here, but going line by line I would need to understand the following things to understand what that code is doing:
--create a structure for a new "tm" object, which requires knowledge of that library
--create a character array
--create a __time64_t object
--use the _time64 method, and know that I have to pass it the address of the __time64_t variable, which basically requires a complete knowledge of passing by reference vs passing by value
--run the _localtime64_s function with the "tm" structure and __time64_t objects as parameters
--manipulate the string using the string copy functions to change "am" to "pm"
--convert it to an ASCII representation using the asctime_s function, which requires the character buffer, character buffer's length, and address of the "tm" structure
--and then the thing that really sets me off, the example uses the line:
printf( "%.19s %s\n", timebuf, am_pm );
which I can barely even figure out even after looking at
http://www.cplusplus.com/reference/cstdio/printf/
so I think that's something about formatting the string to 19 characters and putting a newline at the end of it. But why anyone, developer or beginner, should have to count how many characters are in the string just to print out the time is absurdly tedious.
Speaking a little more broadly, and this is colored by the fact that I recently read the biography of Steve Jobs, this is such poor design. This functionality was written by elitists who've forgotten that not everyone has been writing C++ programs for a decade. And if I add in the fact that the VisualStudio version was giving me an error message 4996 when I was using a simpler example, but that the MS docs for that error message couldn't point me to an easy-to-use fix for that problem, it's an example of how Microsoft is failing to deliver a product that is easy to use.
In summary, this is one example where doing a simple task in C++ requires way more knowledge than should be necessary. I should not need an in-depth understanding of the C++ time libraries, the differences between passing by reference and value, and the archaic formatting options of the printf function to get the local time.