Minimal

stressed for motivation and achievement

2006-08-28

 

More dogma: C++, this time

Still on a denouncing-dogma vibe, I’ve been meaning to post a link to this Register article for a while: Out of the (C++) Loop. For those with experience of the STL, its algorithms/iterators and (especially) parameter-binding, it’s a classic.


Comments:
C++ supports vectors and iterators? When did that happen?
 
Are you trying to be clever and/or funny, anon?
 
If all you want is C then use C or the C-compatible subset of C++. If you want the features of C++, such as its built-in support for object-orientation, generic programming, template metaprogramming and other methodologies, then use C++. As with anything else, you choose the best tool for the job at hand.

C++ is a very large and sophisticated toolkit with many useful tools in it.

Taking a simple piece of code and showing how it can be rendered more complex by choosing inappropriate tools doesn't really advance the science of programming...
 
Of course, you're right about dogma. I meant to imply that I wasn't dogmatic about these things and other people shouldn't be either. Some people are just as dogmatic about their beloved C as the C++ zealots are about C++.

The right tool for the right job is what counts, not what this week's new book or article on The Register says. ;-)
 
Seriously, I've not used C++ for many years. I always found it a pain to produce the same output which other languages could produce in half the time. Pooh to elegance and compact code size.

Does that mean that C++ can now have something like:

myvector = new Vector();
myvector.add(myobject1);
myvector.add(myobject2);

Instead of having to create an infernal chain of pointers? And then read the contents back like:

myiterator = myvector.getitertor;
while (myiterator.hasnext){
....}

? That will make life so much easier. I always feel nauseaus whenever I start having to decipher * and & in code.
 
std::vector myvector;
myvector.push_back(myobject1);
myvector.push_back(myobject2);

std::vector::iterator myiterator;
for ( myiterator = myvector.begin(); myiterator != myvector.end(); ++myiterator )
{
// blah
}

That's probably the most common usage you'll come across in C++. Containers (of which vector is one example) and iterators have always been part of the C++ Standard Template Library.
 
Well I never. It'll be boasting exception handling next.
 
Thanks for providing the answers, Chris. I've been a tad tied up lately (and not in a kinky way, sadly).

As for you, Matt, grab yourself a copy of Visual C++ Express and see what's going down these days. With the .NET framework to back it up, there's some pretty neat stuff available. I'd still take C# first, mind.

Of course, that's assuming anon is Matt. :)
 
It is me. So much for internet anonymity.
 
Post a Comment



<< Home

Archives

April 2002   May 2002   June 2002   July 2002   August 2002   September 2002   October 2002   November 2002   December 2002   January 2003   February 2003   March 2003   April 2003   May 2003   June 2003   July 2003   August 2003   September 2003   October 2003   November 2003   December 2003   January 2004   February 2004   March 2004   May 2004   June 2004   July 2004   August 2004   September 2004   October 2004   November 2004   December 2004   January 2005   February 2005   March 2005   April 2005   May 2005   June 2005   July 2005   August 2005   September 2005   October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006   January 2007   February 2007  

This page is powered by Blogger. Isn't yours?