News for hackers. Stuff that matters.
Re:Why You Should Know C++ by silentbicycle on Wednesday May 20, 2009 @07:40AM (#618376)
C99 has single line // comments. It also has the restrict tag.

About the idea of C++ as a better C, See "C++ - The Forgotten Trojan Horse". (http://ejohnson.blogs.com/software/2004/11/i_find_c_intere.h...)

If you're using C++ for the STL, keep in mind that the ML languages (OCaml, SML) also have compile-time parametric data structures, and they infer and check their usage for you.

They also have a proper module system, so when you change a private variable, you don't have to choose between linking errors or recompiling damn near every piece of C++ code in your source tree.

They're also pretty fast.

Re:Why You Should Know C++ by chancho on Wednesday May 20, 2009 @08:33AM (#618424)
The ML family of languages is my favorite (second only to C++, natch.) but their brand of parametric polymorphism is equivalent in C++ to MyTemplate<T*> (or, if you like boost, MyTemplate<reference_wrapper<T> > would be more accurate.) They are not the same as MyTemplate<T>. This is by choice of ML language implementors, as they see it as a defect of C++ that every template instantiation has to be compiled independently. Instead, they turn static compile-time polymorphism into run-time dynamism using indirection and function pointers. (Maybe MLton doesn't do this, but I know GHC does.)

It's the difference between C's qsort and C++'s std::sort. The latter blows the former out of the water when sorting small things. This brand of polymorphism is unique to C++ and until someone does it better (which no one seems to have any interest in, except maybe Walter Bright) then C++ will always be "the best C."

Re:Why You Should Know C++ by silentbicycle on Wednesday May 20, 2009 @10:13AM (#618558)
This is why I said "pretty fast", not necessarily faster than C++. Using ML means trading a small percentage of C++'s raw speed for code that can be debugged, adapted, etc. with much less trouble. I have found this to be a more than reasonable trade-off in virtually all cases.