3 ms·
So long as the problem you are trying to solve is constrained by the ease with which you can express the problem, this will help. But it will not help when the
by barrkel 15y ago
So long as the problem you are trying to solve is constrained by the ease with which you can express the problem, this will help.
But it will not help when the constraints are elsewhere: memory, network, CPU, heterogeneous interoperability; all still relevant in these times of mobile and distributed computing. When you are operating to these other constraints, you need control - or rather, consistency and predictability - over the consumption of those other resources. It's no good having a magic compiler that can turn your specification into an implementation, if you don't know whether the implementation will run in O(1) or O(n) space or time, what kind of constant factors are involved, and how easily you can tweak the tradeoffs when you hit one constraint or another.
I concur with raganwald's comment: this is more useful for proving, static analysis, testing, etc.
Furthermore, I'm pessimistic that you'll see substantial improvements in expressibility using your approach, particularly when you try to scale it above simple functional (by which I mean stateless input to output) problems. The reason is that programming is an exercise in attention to detail while simultaneously keeping the large in mind; and your focus won't change this fundamental nature. Writing a complete specification for a program rivals writing an imperative implementation in complexity (soup to nuts, I'm not talking about high-level DSLs here, which is an approach equally applicable to the imperative route). I expect a good compiler will swamp you with the inconsistencies of your hidden, unstated assumptions.
For example, I note that your sorting specification doesn't specify whether or not the sort is stable; I think that makes it incomplete, and also it's a tricky constraint to encode.
- jng 15y agoYou are right, and I think you've found one of the weak spots. But I do think that can be treated, and the advantages of the programming-ease will be a good trade-off in many cases with the lost control for efficiency. It's like the switch from assembly to C, or from manual memory management to automatic memory management. You lose something. You gain something else. The new approach is not valid for everything, but for some/many cases, it's much better. Yes, the spec of a complete program will still be a great amount of work. The default resulting code will probably be slow. But you will be able to "describe" the program (in many cases), and you will be able to optimize it later without risking the correctness. Hopefully that can be a great aid and tool in many cases. We'll see, and I hope to have a lot of help along the way doing it publicly! BTW, if what comes out is just a good new approach to static code analysis / formal specification / etc... it will have been worth it. But I do hope to find a usable tool at the end of this quest :)
- barrkel 15y agoI wish you the best of luck in any case. I look forward to reading more about how you expect the transformation logic would work.
- dullcrisp 15y agoHe doesn't have to specify whether or not the sort is stable -- the compiler should only have to satisfy the constraints he imposes. So if he doesn't specify that it must be a stable sort, the sort might be unstable, just as with many sort routines that don't specify whether they're stable.
- barrkel 15y agoThis is what I mean by hidden / unstated assumptions. So on one version / implementation of the compiler, a program may produce correct output, where on another, it produces incorrect output, because of a hidden assumption about the stability of the produced sort. The problem may not be found in testing due to this; and what will debugging the program look like? If this is the kind of issue that can come up in a really simple task, what kind of issues will emerge as things scale up?
- crazygringo 15y ago> Writing a complete specification for a program rivals writing an imperative implementation in complexity > I expect a good compiler will swamp you with the inconsistencies of your hidden, unstated assumptions. Thank you, this is exactly what I came here to say. The entire practice of programming is formally defining how everything works, and the devil is always in the details. The effort of going through those details thoroughly and defining exactly what you want to the program to do in all situations is, simply, the act of programming itself. The best you can do is create languages, libraries, frameworks to help you do it more efficiently.
- MrMan 15y agoi came here to upvote this comment. it touches on the real problems concisely without just sneering about reinventing declarative programming. metaprogramming is worth pursuing, but the considerations hinted at above point to why it is so difficult to realize. one thing everyone who is hating on the idea is missing is that if one compiler somewhere finds a solution on the Pareto front, for a sub-problem, that pattern can be uploaded to the cloud and re-used by other compilers. this would over time tend to help with the practical problem of how to conserve resources in the face of such a hard overall problem.