CPPPROGLIB Telegram 5977
🍿 Холивар: Exception Safety

🐊 Услышал вчера на собесе перл века:

Exception safety в C++ не нужна, мы просто не используем исключения


И вот тут я понял, что индустрия раскололась на два лагеря:

Лагерь No Exceptions: Google Style Guide, игровая индустрия, embedded. Их мантра: «Исключения = непредсказуемая производительность»

Лагерь RAII + Exceptions: Стандартная библиотека, большинство enterprise проектов. «Исключения - это элегантная обработка ошибок»

// Версия без исключений
std::optional<Data> parse(const std::string& input) {
if (input.empty()) return {};
// ...
}

// Версия с исключениями
Data parse(const std::string& input) {
if (input.empty()) throw std::invalid_argument("empty input");
// ...
}


Реальность:

90% C++ кода уже содержит исключения через STL. Даже new может бросить std::bad_alloc! 😱


Провокация:

Если ты пишешь код без exception safety, ты пишешь потенциально багованный код. Точка.


✏️ Опрос: Как ты относишься к исключениям в C++?

🔥 Использую активно (элегантно!)
❤️ Избегаю (производительность)
⚡️ Только в STL контейнерах
🌚 Что такое exception safety?

Библиотека C/C++ разработчика
Please open Telegram to view this post
VIEW IN TELEGRAM
26🔥24🌚63



tgoop.com/cppproglib/5977
Create:
Last Update:

🍿 Холивар: Exception Safety

🐊 Услышал вчера на собесе перл века:

Exception safety в C++ не нужна, мы просто не используем исключения


И вот тут я понял, что индустрия раскололась на два лагеря:

Лагерь No Exceptions: Google Style Guide, игровая индустрия, embedded. Их мантра: «Исключения = непредсказуемая производительность»

Лагерь RAII + Exceptions: Стандартная библиотека, большинство enterprise проектов. «Исключения - это элегантная обработка ошибок»

// Версия без исключений
std::optional<Data> parse(const std::string& input) {
if (input.empty()) return {};
// ...
}

// Версия с исключениями
Data parse(const std::string& input) {
if (input.empty()) throw std::invalid_argument("empty input");
// ...
}


Реальность:

90% C++ кода уже содержит исключения через STL. Даже new может бросить std::bad_alloc! 😱


Провокация:

Если ты пишешь код без exception safety, ты пишешь потенциально багованный код. Точка.


✏️ Опрос: Как ты относишься к исключениям в C++?

🔥 Использую активно (элегантно!)
❤️ Избегаю (производительность)
⚡️ Только в STL контейнерах
🌚 Что такое exception safety?

Библиотека C/C++ разработчика

BY Библиотека C/C++ разработчика | cpp, boost, qt




Share with your friend now:
tgoop.com/cppproglib/5977

View MORE
Open in Telegram


Telegram News

Date: |

Image: Telegram. During a meeting with the president of the Supreme Electoral Court (TSE) on June 6, Telegram's Vice President Ilya Perekopsky announced the initiatives. According to the executive, Brazil is the first country in the world where Telegram is introducing the features, which could be expanded to other countries facing threats to democracy through the dissemination of false content. Just at this time, Bitcoin and the broader crypto market have dropped to new 2022 lows. The Bitcoin price has tanked 10 percent dropping to $20,000. On the other hand, the altcoin space is witnessing even more brutal correction. Bitcoin has dropped nearly 60 percent year-to-date and more than 70 percent since its all-time high in November 2021. 2How to set up a Telegram channel? (A step-by-step tutorial) Over 33,000 people sent out over 1,000 doxxing messages in the group. Although the administrators tried to delete all of the messages, the posting speed was far too much for them to keep up.
from us


Telegram Библиотека C/C++ разработчика | cpp, boost, qt
FROM American