4 ms·
You can't make C++ not ugly, but you can't not try (2010)
- malkia 16y agoMy experience exactly. Recent code I had to change map<string, int> to MSVC specific hash_map<string, int> because the hash-implementation was better in the case, rather than the tree in the first case (not sure whether it's avl or red-black). I really did not care about ordering. And then std::string. I had to go and pool a lot of the std::string's that we have in one of our tools through a function (reusing common lisp) called intern, that was storing them in a pool without reference counting - this saved quite a lot of memory (most of them were key-values pairs).
- briansmith 16y agoFor the first problem, see std::unordered_map (was std::tr1::unordered_map). For the second problem, see boost::flyweight<std::string>. And/or, "typedef std::shared_ptr<std::string> string" and add "new" in front of every string you create.
- malkia 16y agoFunny, a colleague just used std::tr1:unordered_map, and it was available in his VS2008 (I guess SP1), but not on everyone's machine. Yes, it seems to be the right thing - unordered, while hash_map is still ordered (it wants less operator).
- TGJ 16y agoDouble negatives are frowned upon for a reason....
- Confusion 16y agoI'm guessing the title is on purpose, as it nicely illustrates the problem of ugliness in a language.
- sendos 16y agoI guess C++ hate is in fashion, but for me, I just don't see it. I've programmed in myriad languages, including the HN-beloved Lisp, and I think C++ is fine and stands up there with the best of them in terms of ability, syntax, etc. It has its annoying problems, of course, but so does any other language. Maybe if I tried some of the languages that get huge praise here, like Haskell, I would see the light and see what a horrible horrible language C++ is.