lunes, 4 de diciembre de 2023

What are some of the worst things about C/C++?



Top 5 things I don’t like from C++

#5. std::queue
This container doesn’t have an iterator, you can access the underlying container (usually std::list or std::deque) but that doesn’t feel right.

#4. std::array
This container is useful, but it has one flaw, the size is chosen at compile time. A non resizable container that could specify size at runtime is missing.

#3. enum class
The currently recommended way to uses enums is enum class. But I'm not gonna doit, declaring them that way removes the basic operators that usually can be used with enumerator, you could use static_cast on each access to the variable, but it would look horrible. The idiomatic way would be to override operator<< for your enum class, but if you have several enum class it becomes against the DRY principle. You could say: "only create one enum class with all your values", that would be against the purpose of the enum class, avoiding asigning a non valid or duplicate value.

#2. std::map::operator[]
When using that operator passing a Key that doesn’t exists, it will create the Key

#1. std::string
This class is missing (or added really late) several functions that are available in alternatives like wxString or QString, this functions include startsWith, contains, tokenizing, converting from float with specific locale

#BONUSTRACK. The C language
Sooner or later you will need some advanced feature like databases, compression or network and the option to use a mature library written in C will be one of the best options. The bad side being that you will be mixing C++ and C idioms, it wont be pretty. Then there is the option to use a wrapper, but those get deprecated sometimes without reason.

P.D. I really like this language this are the few thing I don’t really like.