TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Big C++ projects that uses Exceptions and RTTI?

15 pointsby kwant_kiddoover 1 year ago
In my career the places I have been that uses C++ (with success) have all been using -fno-exceptions and -fno-rtti. All major open-source C++ projects seem to do the same. Chromium, LLVM, Electron, protobuf etc.<p>I guess if you want to excel at this language and build software (in C++) that people actually use you have to learn to use it without exceptions and rtti?<p>Some projects do use them like CMake. I think bloomberg also uses exceptions??<p>Maybe Meta also uses them but again if you look at another Meta C++ project like Hermes they prohibit use of both rtti and exceptions.<p>Do you use exceptions in your codebase? If you intend to keep coding in C++ are you not better off learning how to use the language without exceptions and rtti?

1 comment

trwsover 1 year ago
It depends a great deal on your situation. Where I work, we have codes up to 3 million lines, they all have exceptions and rtti turned on. You’ll find similar situations all over except at google and in gaming, and to some extent anywhere that last quartile latency is a serious concern. The thing about exceptions is that when you throw none of them they cost almost nothing, but throwing one costs on average about 1000 times as much as returning a value would. It’s a massive hit, especially if you care about latency, so it’s best to avoid them for control flow or anything but truly exceptional situations.<p>RTTI I’d say it’s best to only use in testing and debugging generally, it just plain isn’t reliable for the uses people seem to try to put it to.
评论 #38409196 未加载