Barliman – real-time program synthesis to make the programmer's life easier
github.com
github.com
Would anyone want to ride in a car or fly in a plane written by set of sporadic tests? I wouldn't risk it.
I call it "being a good programmer."
These kinds of tools are the future IMO. It's a higher layer of abstraction. Most programmers have no idea how their programs are actually executed--we write in a high-level language and rely on voodoo to execute it, without a "deep understanding" of how it's really executed, and without writing instruction-level tests. And it works great. I don't see how this is theoretically different, it's just a higher level of abstraction. Of course, its utility greatly depends on the practicality of its implementation (which includes performance)...
> it becomes a list of instructions for codegen
That describes exactly the everyday programming languages that we all use.
Concrete concepts are a good foundation of correct code, no matter how high level they are.
That said, webyrd has shown kanren embedded lambda calc (evalo relation) to find which program would be reduced to some value..
The problem is that this is incredibly computation intense, since the number of possible programs is huge. Right now it's viable for improving small code parts with a know-correct starting point. Maybe some day computers become fast enough to make more viable.
The challenge is that 1) doing it for non-trivial functions and getting results faster than much simpler generative methods that depends on heuristics is a really hard problem (but can work better when we don't have reasonable heuristics); 2) writing exhaustive tests for a lot of the problems we care about is likely to take more effort than writing the code in the first place.
I think if you want something like this the effort is best expended on tools that help you create a consistent, concise and exhaustive model / test-suite rather than code to implement it, with a focus on making it possible for a human to read and sanity check the generated model.
In this case, the tool is basically trying to create a model that matches the tests, it's just that it never makes the model explicit other than in the form of finished code, which prevents us from verifying that the model is correct other than by inspecting the code and/or expanding the tests.
For small functions that might be helpful, but for larger pieces of code, I think it is likely that generating the code directly is likely to lead to code that is near impenetrable and impossible to validate expanding the test suite. E.g. a recurring problem of research in genetic programming has been that a lot of the resulting solutions are hard to understand even very small/simple algorithms. And for bigger problems it's not unusual to end up exposing weaknesses of the fitness function rather than solving the intended problem.
It's still an interesting project. I just think we're really far from having something with wider appeal.
Add a 'z' to the end of the first example and it figures out it needs to 'reverse . drop 1 . reverse' to take a character off the end.
Imagine if it could learn on every open source Haskell codebase on GitHub and then learn in real time while people type.
To oversimplify, in the miniKanren world programs are written using relational logic, wherein there are "variables" and then certain "relationships" between the variables. That is the program specification. Now we can run the specification and allow miniKanren to generate one or more variables that satisfy the relations. Thus a miniKanren program can have more than one answers. One interesting side-effect of this kind of an abstraction is that programs can also be run backwards to generate more programs that satisfy certain relations. That's pretty much what's happening with Barliman.
[0] http://minikanren.org/ [1] https://en.wikipedia.org/wiki/Daniel_P._Friedman [2] http://webyrd.net/ [3] http://okmij.org/ftp/ [4] https://github.com/clojure/core.logic
This was one of the earliest inductive logic programming (https://en.wikipedia.org/wiki/Inductive_logic_programming) systems.