News for hackers. Stuff that matters.
Re:LLVM Programmer’s Manual by bigcheesegs on Friday July 22, 2016 @05:31AM (#12142563)
The llvm-project is a compiler. Its developers are well aware of the true cost of exceptions.
Re:LLVM Programmer’s Manual by barrkel on Friday July 22, 2016 @06:36AM (#12142753)
Actually, compilers typically don't use exceptions because they don't usually abort on the first instance of a problem. Compilation has historically been an lengthy batch job, and thus reporting many errors to be fixed between iterations improves user productivity.
Re:LLVM Programmer’s Manual by strcat on Saturday July 23, 2016 @01:10AM (#12148445)
LLVM doesn't take shortcuts like that. It's designed as a set of reusable libraries for use in all kinds of tooling. In many cases it even has to continue going after detecting errors and recording a representation of them, so that it can still produce useful information. That's an important feature for lots of tooling.
Re:LLVM Programmer’s Manual by favorited on Friday July 22, 2016 @02:01PM (#12145389)
I think the point was that LLVM compiler infrastructure has a first-class C++ font-end. They know the ins-and-outs of language features because they are implementing standards-compliant compilers for said language.
Re:LLVM Programmer’s Manual by barrkel on Friday July 22, 2016 @05:07PM (#12146779)
Most self-hosted compilers are written in languages ill-suited to compiler writing. The choice of features used is often a compromise, rather than best practice for either good compiler design or good target language use.

C++ users in particular have strong concerns about things like RTTI and the overhead of exceptions not thrown. The cost of making unthrown exceptions low (near zero) is that throwing exceptions is much more expensive. This turns into a feedback loop, where C++ programs end up performing better if they never throw any exceptions because of the tradeoff.

This feeds into self-hosted compilers. Thing is, certain compiler design techniques can work well with cheap unwinding: constraint solving (more common in languages with better type systems than C++), forward-looking grammar assertions with speculative parsing, IDE-integrated code completion (implement the lexer to add the cursor position as a special token, and jump out of the parser when it's found, where all the context is available to pass along). But C++'s peculiar tradeoffs may make using things like exceptions less than ideal to use for this purpose, not because exceptions are the wrong tool, but because most C++ programs are not compilers and aren't tuned for it.

And OTOH, compilers written in low-level languages like C++ often twist themselves into knots to simulate things like tree pattern matching, multiple dispatch, destructuring binds, etc. Sometimes they even give up and write code generating tools.