3 ms·
I have to agree that even thought STL is extremely powerful, it makes program extremely verbose. But, in my opinion, the real reason C++ code seems so verbose
by d0m 17y ago
I have to agree that even thought STL is extremely powerful, it makes program extremely verbose.
But, in my opinion, the real reason C++ code seems so verbose is because of the lack of closures. In C++, when you need one, you have 2 choices: either manually coding everything that would be in the closure or create a totally new function.
In fact, in the new c++2k10, it could be interesting to have a STL-like but with closures instead.. so one can do:
some_sequence.sort_by(_1 > _2);
or: foreach(sequence, cout << _1 << endl); that's, again in my opinion, way better than:
for (int i = 0; i < sequence.size(); i++) { cout << sequence[i] << endl; } and again still better than:
for (list<int>::size_type i = 0; i < sequence.size(); i++) { etc..}
- wuch 17y agoActually his example can be written quite succinctly (but in general case closures would be much more expressive): copy(words.rbegin(), words.rend(), ostream_iterator<string>(cout));