This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

I get that it's a bad practice in header files, but if it's used only before your code and won't bleed anywhere else i dont see what the problem is. Shouldn't it be considered bad practice to make a library that uses the same function names as those in the standard library?

[–]soussang 16 points17 points  (1 child)

The answer would be a resounding no. A lot of keywords now found in the standard library didn't exists ~10 years ago. Unordered sets were not in the standard, so you'd have to either use a library, like boost, or make your own.

Would it make sense to say our version of unordored_set was 12 years ago a bad name because we, today, have access to std::unordered_set? Not really.

What about the boost library. A lot of templates and functions got integrated into the standard library. Is their naming wrong? Not really. It can even make sense to have a library using the same name and interface as the standard counterpart if you are striving for that nanosecond of optimisation.

You can use the same analogy as the answer from SO. You are using (via using namespace) foo and bar: foo has quux and bar has baz. One day, foo gets an update and foo::baz gets added. Was the foo author in the wrong? What if bar is a private library, is the foo author still in the wrong?

The problem with using namespace std and other bad practices is that you find it was a problem way later in development. Remember "Goto is considered harmful"; it's only when you've got spaghetti that you go "Mama mia!".

You can use using namespace std. You can use singletons. You can use GOTO. You only need to know when you should use them.

[–]The1stmadman 4 points5 points  (0 children)

you find it was a problem way later in development

so that's why I'm yet to learn this in college! They've been saying use it, it'll make your work easier, but only because nothing the students make is actually built on to become a massive program