Linked by Owen Anderson on Mon 19th Apr 2004 05:43 UTC
General Development For years the development scene has been dominated by the C family of languages, primarily C itself and its immediate successor C++. Recent years have given rise to other C-descendents, however, such as Sun's Java and Microsoft's C#.
Permalink for comment
To read all comments associated with this story, please click here.
Why D, thereīs C++
by yojo on Mon 19th Apr 2004 10:30 UTC


I donīt know where to start. The author complains about the complexity of C++ and suggests a language D to solve the problems in C++. He provides sample code in D, that, upon examination, looks so C-ish, that one wonders whether the author has even taken a look at C++ before.

To put it straight: If the example is the hallmark of "decomplexified" D-Code, you have a lot left to improve. First, i would suggest to check out, whatīs possible in C++.

The canonical word-count program would like this in C++:
(and for the ever-complaining pointers-are-evil,c++-buffer-overflow,no-garbage-collection-mafia: take a close look how many pointers there are, how much memory is forgotten to be deleted and how many lines it took)

----
void print( std::pair<std::string, unsigned int> pair )
{
std::cout << pair.first << " " << pair.second << std::endl;
}
int main( int argc, char **argv )
{
std::ifstream iff( argv[1] );
std::map<std::string, unsigned int> map;
std::string str;
while( iff >> str )
map[str]++;

std::for_each( map.begin(), map.end(), print );
return 0;
}
---