Hacker News new | ask | show | jobs
by jfmengels1 1962 days ago
Sure, but under some assumptions. Assumptions like that some piece of code won't be transformed by a macro, that reasonably looking code like `a.b` doesn't have side effects, etc.

It's not that it's impossible, but that 1% (or 5%, 10%, ???% depending on how the project is structured and whether it uses a lot of side-effects or dynamic properties) can be enough make your program crash if the assumption turns out to be wrong.

Another example that you could go for, is can you determine whether a property of an object is used or not. If you have a language like JavaScript where you can do `object[propertyName]`, that turns out to be very hard. In a pure functional language, that is comparatively pretty straightforward to detect.

2 comments

Of course. Thus, "the soundiness manifesto". If you want to eval() your entire program to be something completely different just to spike your analysis tool, go ahead. But in the real world these cases are minimal and asking developers to make some annotations to help out in these cases isn't arduous.

Notably this is largely a problem with JavaScript and Ruby. There are plenty of non-functional languages where we don't need to havoc wildly to handle ordinary program behavior.

The javascript example gets further compounded by doing something like `object["prefix" + variable]`.

I've seen some very large companies abuse JS object proxies so that code is nearly impossible to follow even with the best IDEs and someone who's excellent at grepping.