Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Metaprogramming is a good example of this, but it's not enough 'automatic' for my taste. I find inductive logic programming (ILP) and genetic programming a lot more interesting. Most researchers dropped these notions (in the 90s) mostly (for generic software purposes) as they are too slow and impractical, but I think, with faster computers, new insights and completely new hardware (memristors) on the horizon, they might get back in fashion to enable actual automatic programming instead of 'just' DSLs and DSL related code generation.


Here's an example of a recent tool that automatically generates code from a declarative specification written in linear integer arithmetic with operations on sets: http://lara.epfl.ch/w/comfusy. There is a plugin available for the Scala (2.7.7) compiler.

Assuming you want to break a number of seconds contained in variable secnum into hours, minutes, and seconds, you would write something like this:

  val secnum: Int = Console.readInt
     val (hours, minutes, seconds) = choose((h: Int, m: Int, s: Int) => (
         h * 3600 + m * 60 + s == secnum
        && 0 <= m
        && m < 60
        && 0 <= s
        && s < 60
      ) )
Code that computes the hours, minutes, and seconds will be generated at compile time (it's not interpreted).


This is super interesting but I am really curious about its performance assuming they dont just bruteforce it to exhaust all combinationss. Tons of portfolio optimization problems can be specified very succinctly just like above but the actual computation can be quite tricky. If you had to break up a hundred dollars to invest in google amazon and rest in a riskfree interest bearing bond the optimal constraints look just like the choose function above...so i can declaratively write out the sharpe but maximizing the sharpe is fairly nontrivial. I am going to check this out right now.


It's such a shame though that this kind of research usually stops when the author is done with his/her thesis. A lot of worthwhile papers and software are out there and together probably enough to create a small revolution in software development, but the problems are very hard and usually it's not even concrete enough to define the problem that well. So it would need a lot of these researchers combined to do something great; besides maybe DARPA, I don't see much interest in that at the moment unfortunately.


I think it's much better than brute force search. The example above produces the following code:

  val (hours, minutes, seconds) = {
    val loc1 = secnum div 3600
    val num2 = secnum + ((−3600) ∗ loc1)
    val loc2 = min(num2 div 60, 59)
    val loc3 = secnum + ((−3600) ∗ loc1) + (−60 ∗ loc2)
    (loc1, loc2, loc3)
  }
Note that it works for constraints expressed in (parameterized) linear arithmetic and with operations on sets (like taking cardinality, union, intersection...).


Very interesting, thanks for that.


Another intriguing approach in the same family as ILP and GP is some recent work on just doing exhaustive search, but over heavily type-constrained Haskell code, with the semantic information being used to greatly narrow the search space: http://nautilus.cs.miyazaki-u.ac.jp/~skata/MagicHaskeller.ht...

and paper: http://nautilus.cs.miyazaki-u.ac.jp/~skata/skatayama_pricai2...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: