Hacker News new | ask | show | jobs
by Peaker 3091 days ago
Programs could be explicit about those constraints, encode more of them statically and check them statically.
3 comments

Everything has a failure rate. This introduces another set of heuristics (and another false-{positive,negative} rate), another set of potential implementation bugs in those heuristics. What if being able to run the program on a particularly memory-limited computer could save the universe, even more slowly than the project manager originally wanted it to run?

Statically encoding something like a memory constraint sounds very hard for all but the simplest algorithms. What about a randomized algorithm that sometimes uses more heap? How do you get around not knowing how much it's going to use without running it?

Allocate for the worst case use in the bss. The program's static size indicates explicit memory requirements.
That's Design-by-Contract. On checking side, one can generate tests from specs, static analysis, turn them plus code into verification conditions to feed to solvers, or inputs to theorem prover for handling complex stuff. Eiffel implements DbC with test generation. SPARK Ada does automated and manual proofs. Ada 2012 added contracts but idk tool support. Many languages have ways of emulating this functionality, too.

What you're describing is essentially a proven, lightweight, formal method for improving software quality. Many commercial apps use it.

indeed, very few programming languages actually do that, and you're probably running the language on top of another language that has flawed guarantees on those constraints. Or hardware. How do you guarantee your program hasn't gone rogue if you can't guarantee the bits in your memory.
Yeah, this would be the question for fault tolerance and the whole world of distributed systems that inevitably comes with it.