I wonder to what extent it would be useful to make a programming language that looks familiar to programmers used to imperative (possibly object-oriented) programming, but which is actually a logic programming language with a whole lot of syntactic sugar and syntactic salt (and maybe some syntactic cinnamon as well). With some care, it should be possible to make the obvious imperative-like things act in the obvious way, while not getting in the way of the logic-programming things where they're an advantage.
- IO — some cross between the mercury !IO syntax and DCG notation. Maybe an exclamation point after the function name means that !IO should be passed in and out. (Of course, this could also be auto-detected, but then (a) the distance from logic programming increases, and (b) minor, seemingly-innocuous changes to implementation of one function will auto-change not only its own interface but also the interfaces of other functions across the whole program.)
- destructive assignment
- local variables — can be dealt with similarly to the !IO syntax. An assignment statement such as "A := A + B" is syntactically transformed into "Anext = Aprev + B". Basically, this takes data flow analysis and turns it from an optimisation technique into a rule of syntax.
- object fields — Either use the mercury !IO syntax, with more care to always show it as one item rather than "di, uo", or something like STM or Actor-model message passing or whatever. I'm not sure what would be best here.
- global variables — Global variables are frowned-upon in any case...
- loops — can be transformed to tail-recursion, in the inverse of the usual optimisation.
- debug-by-printf — Probably best dealt with by adding actual debug functionality... For instance, a statement like "debug A" might mark the variable A as being debugged, causing the built-in debugger to print it to stderr when it becomes instantiated, changes due to backtracking, etc.
Of course, the real biggest problem of a new language is that it will lack libraries and frameworks. Given that Mercury compiles to JVM, perhaps the JVM libraries could be used... except they will be alien to the language.
Or maybe I'm re-inventing Erlang, poorly, although Erlang is based on functional programming rather than logic programming.
⇦ Slow-cooker chicken recipe | ⇨ Bread-maker cake recipe |




