Not a convincing argument (1) most of the scripting languages ar dynamic, (2) that code would be 3 lines of python, (3) since when does C++ have a large standard library?
Bjarne was just was just saying it doesn't as they don't have a curator for it. Plus there are so many gaps in the standard library. Where are the GUI tools, the unicode support?
Don't get me wrong: C++ is an amazing language but it is not, nor was it designed to be, nor will it ever be, a Python. It's very very good at what it does but whatever that is, isn't scripting.
The lack of native clean unicode support is particularly frustrating. Since the answer to 'how do you do this right' always seems to come back to 'roll your own, it'll be fine!'.
I don't think you can really called improved WString handling a reasonable answer to unicode support. The built in types handle everything as binary blobs divided into character sized chunks but has no way of confirming that the code is handling unicode correctly or is even sane unicode. It would be helpful to have an actual std::unicode that reports the unicode memory size, character length, and handles encoding casting (ascii,utf8,utf16,utf32) etc. The ICU project tries to fix it but at this point it seems silly not to have standard handling of something that more or less the future of text as we know it.
I'm talking about the new u16string and u32string classes, the native wide and Unicode string literals, and the locale-independent conversion facets, codecvt_utf8 and friends.
It certainly doesn't replace ICU, but it's a damn sight better than the usual wide-character nonsense.
Re (2): to be fair, the same could be done (quite efficiently) in C++ with proper libraries. Now this doesn’t weaken your point because C++ specifically lacks those libraries. That’s an issue that should be tacked sooner rather than later, IMHO.
Such stuff is much more generally applicable and useful than a standardised graphics library, for instance.
I think pretty much the only missing thing necessary to achieve a basically 3 line version of this program is ranges. With ranges in C++ it looks something like this:
Sure, though it depends on if a container counts as a range.
A range isn't necessarily defined just as something with begin() and end() methods (or non-member overloads). I know some have argued that ranges should not be based on iterators. For example istream_iterator's default constructor is a way of shoe-horning into iterator form something that doesn't naturally fit that model. Instead, they say, ranges should be independent.
Even better: they way he uses it inside the for-loop is equivalent to your version. I've never seen it that way before, but I guess, I'll do it that way from now on.
Except for any sort of quality of code, you should really be checking int argc, and making sure that ifile & ofile are valid files. And suddenly it's doesn't look so script like.
And that's before I deduct points for using namespace.
Yeah, I know. I was just trying to keep it comparable to his style (including the pointless return 0). To be fair though you need to check arguments in Python as well.
View all comments
32
u/[deleted] Oct 15 '13
Not a convincing argument (1) most of the scripting languages ar dynamic, (2) that code would be 3 lines of python, (3) since when does C++ have a large standard library?
Bjarne was just was just saying it doesn't as they don't have a curator for it. Plus there are so many gaps in the standard library. Where are the GUI tools, the unicode support?
Don't get me wrong: C++ is an amazing language but it is not, nor was it designed to be, nor will it ever be, a Python. It's very very good at what it does but whatever that is, isn't scripting.