29 points · by otoburb · 14y ago · 40 comments
This is categorically false. There are plenty of static analysis tools that can determine if programs written in turing-complete languages will halt. They can't do it for every program, but they can do it for large numbers of useful programs.
Simple counterexample: python is turing complete, yet it is possible to mechanically analyze and determine a whole lot about this program:
print "Hello, World!"
Yes, that's a stupid example, but it demonstrates that the premise of this article is false.As further example that the author misunderstands the issue is the quote: "That, or viewing your website means I have to pore over every line." If good static analysis tools can't figure it out, it is less likely that a person will.
Static analysis tools running on Turing complete languages are a useful tool. Sometimes they answer "I don't know" at which point you will have to decide if you trust the author or not, but the vast majority of code out there is fairly tractable.
[edit] It is true that it is a mathematical impossibility for all possible programs in a turing-complete language to be analyzed, but that doesn't mean that there don't exist programs that are analyzable and has little bearing on whether or not real-world programs are analyzable.
But they're heuristic, which means if their use ever becomes widespread it will be very easy for malicious software writers to defeat them on a case-by-case basis.
But not about arbitrary programs you download from the Internet. For such programs you need to require either that they include a custom proof, or that they're written in a non-Turing complete language so that you can check safety yourself.
But in any non-trivial interactive application, termination can’t be a guarantee. The user may not ever cause the program to halt, and indeed, you want a game to run without end. Perhaps you could use a form of FRP: only the reactive part of a program would run continuously. But what would you gain?
We don’t need to make a language where programs are provably innocent. We need to make a language where assumed-guilty programs are provably imprisonable! An ordinary statically typed functional language would do just fine.
Solving the halting problem doesn't mean all programs end - it means you can automatically determine whether an arbitrary program ends.
>The author wrote of total functional programming, a paradigm in which all functions and programs are provably terminating.
So then what are you concerned about? Either use TFP, if indeed all your programs terminate, or have a different non-Turing complete approach, in which case you can still write infinite loops.
1. what kind of security properties do you want to verify. I cannot think of one that could not be checked at runtime when the dangerous function is called with actual parameters.
2. turing completeness has nothing to do with security. Before Haskell had IO it was totally safe but still turing complete.
Throw it on the pile of Things That Could Be The Next Big Thing, Maybe--right on top of declarative programming and highly-concurrent programming.
1. You need to refine your argument. I suspect your main point is philosophical and political, but you detract from it by setting up a nebulous security argument. The security concerns you describe are non-issues. Turing completeness says nothing of the available IO primitives, hence why people counter with sandboxing. Solving XSS is as conceptually simple as having any js-initiated request include the identity of what initiated it (in the case of XSS, the other site), and server frameworks having a whitelist of such initiators. But in general, a user shouldn't be even worried about cross site scripting as they're not meant to have control over it - their only input is whether to rely on the total security of a specific site.
2. Executable blobs are the lowest common denominator (any concept can be realized in them) so new concepts tend to be implemented in them rather than engineering a more declarative format. Furthermore, users are lazy and auto-updating of software (in this case, on every page load) is a net win. However, apt-get also gives me these very nice properties.
3. This is where the philosophy comes in - users should be in control of the software they use! Web 2.0 is actually proprietary software 2.0! Browser extensions can modify the applications to some extent, but are fighting an uphill battle due to the difficulty in analyzing Turing-complete blobs. I presume this is your real motivating factor in wanting to change the expressive power of scripts, but as long as the code has more expressiveness than a simple declarative format, you can never actually tame it. (Imagine a server framework that re-obfuscates the client-side code every hour).
4. One fundamental issue to address is naming the code so that end users may gain control over administering it. One doesn't install a new version of CAD software in the middle of a project, as their goal is to finish the project and not get bogged down figuring out how to use a new version. I only dist-upgrade when I'm willing to accept a few days of shaking out changes. Contrast with the current web, where a site will make unilateral changes and the only recourse of users is to complain. One should be able to locally 'roll back to the previous version of this site', and the site should support that by decoupling their code and data model.
5. Another major issue is data store and "network" independence. If one doesn't like the changes site A is making to the software, they should be able to switch to a competing site B, and have their data and connections intact - akin to several programs using the same file format. This of course requires fundamental site openness, with is directly counter to the standard web-hollywood business model of becoming the middleman in an n^2 network, so I expect eventual disruption rather than gradual change.
However, this doesn't mean it's feasible, and if the language is useful it's probably not. You can pick an NP-complete problem with a large input data set and make halting depend upon the outcome. It will take a very long time to determine if such an application halts or not, since you have to solve the NP-complete problem.
Of course, if you care only about states the application could potentially reach, instead of those it actually does reach, you could do this much faster. However, if you know which states are undesirable, you can check if you are reaching them during runtime as well.
Another important advantage is query optimization. Programs in non-Turing complete languages can be automatically analyzed, not only to determine their security implications, but also to rewrite them in optimal form. In a good NTCL with an optimizer, you don't care how (in)efficient your algorithms are - they're automatically upgraded to their theoretical fastest speed.
The only sure way to prove that a function is safe, turing-complete or not, is to restrict the system calls it can make.
I agree that if you provide domain-specific non-turing complete languages, it's more likely that you will be able to grok it and pull it apart, but it doesn't let you prove that any arbitrary function doesn't reach a line you don't like for all user input.
To say that you don't know anything about it while claiming it will solve our problems is ... dishonest at best.
And you misunderstand the halting problem - you can perfectly well write never-ending programs in a non-Turing complete language. The only difference is that you can tell whether an arbitrary program ends or not.
I don't think that you understand the implications of the halting problem. You are claiming that use of a Turing incomplete language will make automated verification of programs possible, and that this automated verification will save us from web pages doing things that we do not want. I will suggest that any solid academic would not think highly of your argument.
Here's a simple experiment that might help you understand an important flaw in your argument. Determining the range of a short program takes a small amount of time, a longer program takes longer. TPS is a restricted language which allows for programs of any length, as long as they will eventually halt. If I write a huge, complex program, and it will take forever minus a day to halt, how long do you think it will take to verify? Spoiler Alert! Longer than you will wait for a web page to load.
The way that we use computers as society is not very academic. If you want to build a web browser that doesn't browse the web, you will find yourself quite lonely.
int main () { return 0; }
I can easily prove that it will halt. There are some classes of programs that provably halt, and some classes that provably don't. Proving that a program halts doesn't mean anything about solving the halting problem, and it doesn't say anything about the Turing-completeness of the language.
So I'm not sure what I think about this yet, except that it's interesting to chew on.
it's not what you are searching for but it might be fairly easy to turn it into what you describe.
the creator of elm-lang, Evan Czaplicki, told me he'll opensource it rather soon. of all functional-JS buzz out there, this one makes most sense to me.