> It's not unsound. Otherwise you'd incorrect results. You could say it's wasteful, because you optimise and then throw away the optimisation.
The optimization is unsound. If it weren't, it wouldn't have to be rolled back occasionally.
If you're talking about the combination of the optimization and the rollback mechanism, it's not unsound, but it's inelegant. A runtime system designed this way only understands your program in a statistical sense (based on concrete execution profiles, which may vary from one run to another), never with the full certainty that static analyses (type checking, abstract interpretation) can give you.
> how many of the bugs in your code turned out to be compiler bugs, vs how many were ultimately your mistakes?
Of course, most were my mistakes. But the very reason why those bugs made it into the final executable is the lack of powerful static analyses in the first place. Curiously enough, when I use languages that make static analyses possible, I write programs with less bugs and they perform better without relying on fancy runtime system tricks.
---
Sorry, can't reply to you guys, because “I'm submitting too fast”. So my replies go here:
@mafribe:
> That's an orthogonal issue.
It's not. Static analyses gather valuable information that can be used to emit efficient code.
> More powerful static analysis is also more time-consuming.
So perform it ahead of time!
> One of the design goals of Javascript JITs is to make web-pages as responsive as possible. That rules out complicated static analysis.
Of course, a browser can't spend much time statically analyzing JavaScript programs, but programs can be statically analyzed (gasp!) before they're deployed.
---
@smallnamespace:
> Why does that matter to anyone?
Because this implementation technique is unnecessarily complex, and a far simpler alternative exists: Know beforehand what your program has to do. Think before you write code.
> Java and C# are both statically, strongly typed languages where JITs are the dominant implementation.
Their type systems can be easily subverted, so they're not “strongly typed” in my book.
---
@smallnamespace: Oops, sorry, I accidentally swapped my two replies to you: this one and https://news.ycombinator.com/item?id=12481956 .