Well since i joined this forum i have come to know about bad programming practices like using eof() or goto or system(), etc.
Suprisingly all these methods were told to me by people who are supposed to be experts of c++.
What i dont understand is that why these unfriendly functions still exist?
Shouldn't they be removed from newer versions of compilers?
Otherwise they will continue to be recommended to beginners.
> What i dont understand is that why these unfriendly functions still exist?
Because the wide experience of the C++ community has been that:
a. they certainly are not "evil" (no matter what people on forums tell you).
b. each one of them is a useful facility, which can be used safely and correctly, given the right context
c. there are programming situations where no clearly better alternative is available.
The C++ standardisation process has been quite aggressive in first deprecating and then removing features where unequivocally better alternatives are available.
For example, std::auto_ptr, std::unary_function, std::binary_function, std::random_shuffle, std::ptr_fun, std::mem_fun, std::mem_fun_ref, std::bind1st, std::bind2nd have all been removed in C++17.
There are billions upon billions of lines of code out there that use these. You can't just break all that code by removing things. Its backwards compatibility.
That said, bad and good are binary, there are grey areas. Goto is still the only way to get out of nested loops in C, and c++ allows C statements. eof is bad in a loop when used incorrectly, but it DOES tell you if you are on the end of file marker and does have valid uses. It is incorrect usage that is bad, not the function. System is a complex story about security flaws, but every replacement for it can suffer the same issue if the program called externally has been compromised.
Besides the good things said above, C++ often has ways to do things multiple ways and some ways are better (safer, more maintainable, more efficient) than others, but those others are still necessary in some specific cases. Much of the C++ Core Guidelines project https://github.com/isocpp/CppCoreGuidelines is about placing those bad (unsafe, error-prone, etc) features behind safe interfaces, such as hiding arrays behind spans and ranges, hiding new/delete behind unique_ptr, etc, so that the programs can enjoy all the good things modern C++ has to offer without giving up on any of its darkest powers.
> There are billions upon billions of lines of code out there that use these.
> You can't just break all that code by removing things. Its backwards compatibility.
Forgive me, because your name is Indian, and the description of your experiences, (and the times of your activity), leads me to think you are probably sitting somewhere in India right now. Correct me if I am wrong.
The state of computing is growing fast in India, but the global resources for the computing still can't compete with places like the USA, Western Europe, Australia, etc. So people on the forum here might often sound like we're sitting in a glass tower when we say things about modern C++.
It is an unfortunate fact that a lot of IT industry and, worse yet, University-level education in India is ten or more years behind the state of the art. What this means is that this forum is often plastered with students asking for help with code designed for things like Turbo C++ and the like. (Though, thankfully, lately that seems to be happening less and less. Maybe most Indian Universities have finally told their professors to stop requiring their students to use ancient technology and get themselves a free modern compiler to use.)
We even get the occasional person bragging about how he's part of some big IT firm in India and then suggests an answer which is absolutely wrong.
In any case, the best way to move forward -- not just for yourself but for India -- is to educate yourself to good practices as best you can, by visiting online forums like this one and stackoverflow and the like, and using good practices even when you are required to use crufty old stuff, and, importantly, push back a little when asked to do things the wrong way. If everyone does that then India's IT industry will catch up faster and compete better.
You can bet people in Dubai IT aren't using Turbo C++.
Anyway, end rant. I hope you are enjoying the learning process.
*There are a lot of really bad programmers in the USA, etc too, so don't anyone get too offended over something I didn't say.