Live data from Hacker News

How AI based programming could work

bjenik.com

51–60 of 61 posts

Re: How AI based programming could work

#51
post #5

Earlier quoted context omitted.

Why Prolog? I have never noticed that Prolog was any better than other computer languages at reading one's mind!

Prolog, or at least logic programming languages, were thought to be the wave of the future of programming in the 80s. They, of course, turned out to be a massive bust.

>> They, of course, turned out to be a massive bust.

What was supposed to be the wave of the future was the Fifth Generation Computer Project [1], initiated in Japan. Its ambition was to create machines that ran Prolog natively, as in, in special-purpose hardware. What turned out to be a "massive bust" was any attempt to use special purpose hardware in the face of rapid increases in both speed and power by general-purpose hardware (ie, x86). The same fate awaited Lisp Machines [2] and similar projects.

Prolog and generally logic programming hasn't really gone bust at any point. The point of Prolog was to use first-order logic as a computer programming language. That worked just fine, and works just fine nowadays still, although of course automated theroem proving must always rely on heuristics in order to be practical.

As to the issue of efficiency, most Prolog interpreters today are based on the Warren Abstract Machine, an efficient virtual machine for Prologs. There are other designs besides it that are also equally efficient.

Prolog has not really ever had an issue with efficiency ever since the early seventies. In fact it was a previous attempt at a "pure" logic programming language that had the efficiency issues, PLANNER [3]. Prolog was created specifically to be an efficient logic programming language, sacrificing purity for pragamatism.

I calculate it will be at least 2070 before we hear the last of it, of course.

_______

[1] https://en.wikipedia.org/wiki/Fifth_generation_computer

[2] https://en.wikipedia.org/wiki/Lisp_machine

[3] https://en.wikipedia.org/wiki/Planner_(programming_language)

Re: How AI based programming could work

#52
post #32

Earlier quoted context omitted.

Prolog, or at least logic programming languages, were thought to be the wave of the future of programming in the 80s. They, of course, turned out to be a massive bust.

You are factually correct But, a key problem was the runtime (in)efficiency of the prolog implementation engine. Maybe today with x1M more powerful computers it is worth trying again ? Neural networks were abandoned in the 80s and made a massive comeback with a. more compute power b. convolutional networks In fact, maybe a ML-optimized VM will make higher-level languages useful again ;)

No, the problem was not that Prolog was too slow. The problem was that it was too stupid.

Prolog's strict left-to-right, depth-first search strategy allowed the implementations to be, in fact, quite fast. But that same strategy also kept it from being more than a small step toward true declarative programming, because Prolog programmers have to understand the order in which subgoals are tried. For example, consider a goal that can be satisfied by either of two clauses, which we'll call A and B, and where every problem instance can be solved by exactly one of these; however, clause A always completes (either succeeding or failing) in constant time, but clause B, if invoked on an instance that would cause it to fail, goes into infinite recursion (an easy thing to do by accident in Prolog). It's imperative (ha!) for the Prolog programmer to make sure that clause A is tried before B.

This kind of thing comes up all the time in Prolog programming. On the one hand, you have to be aware of the order of operations so you don't cause infinite recursions (or, short of that, cause your program to take exponential time); on the other, Prolog programmers frequently exploit the left-to-right, depth-first strategy by using the operator known as the "cut". The cut is a non-logical operator in the sense that its semantics can be expressed only by reference to the Prolog search order.

Programs written in a true declarative language might superficially look a lot like Prolog programs, but the implementation would need to be much smarter -- doing things like figuring out the correct order of operations on its own. (I think machine learning might actually turn out to help with this.)

Anyway the problem with your suggestion that we just need to throw more hardware at Prolog should be evident by this point. It doesn't matter how fast your machine is if your algorithm is exponential in the typical case (never mind if it contains an infinite recursion!).

Re: How AI based programming could work

#53
post #32

Earlier quoted context omitted.

You are factually correct But, a key problem was the runtime (in)efficiency of the prolog implementation engine. Maybe today with x1M more powerful computers it is worth trying again ? Neural networks were abandoned in the 80s and made a massive comeback with a. more compute power b. convolutional networks In fact, maybe a ML-optimized VM will make higher-level languages useful again ;)

No, the problem was not that Prolog was too slow. The problem was that it was too stupid. Prolog's strict left-to-right, depth-first search strategy allowed the implementations to be, in fact, quite fast. But that same strategy also kept it from being more than a small step toward true declarative programming, because Prolog programmers have to understand the order in which subgoals are tried. For example, consider a…

>> The problem was that it was too stupid.

It's ... a programming language? It's Turing complete. Nobody said it's intelligent.

>> It's imperative (ha!) for the Prolog programmer to make sure that clause A is tried before B.

That is one of those cases where Prolog takes the pragmatic approach to allow efficient computation rather than sticking to "pure" semantics of the kind that tends to make a big mess of things just to keep things "clean" (like, oh, I don't know... monads?).

Btw, I've written reams and reams of Prolog in the last five or six years. The fact that your code has two readings, declarative and imperative is only a problem if you allow your mind to remain stuck in some purist definition of declarative programming that looks beautiful but doesn't really work.

If you accept that we live in an imperfect world, have to contend with primitive computers and limited resources of all kind, then Prolog is fine and miles and miles ahead of anything else in terms of declarative semantics. Even lisps have magickal and mysterious stuff like eval etc.

In actual Prolog programming practice the imperative reading means you can actually debug your code and follow it around as it falls over your own bugs. A purely declarative program would also be purely undebugable.

The dual semantics is only a problem if you don't understand the language. And in what language is that not what you'd expect?

>> Prolog programmers frequently exploit the left-to-right, depth-first strategy by using the operator known as the "cut".

No, let's say things the way they really are. The cut is there to allow a branch of the depth-first tree to be, well, cut. Correct, its semantics are purely imperative. Its real use though is to stop unnecessary searching and backtracking and therefore make your program more efficient.

It's not there to "exploit" anything. The fact that it can be exploited is troublesome, but so is all sorts of stuff in programming, like buffer overruns or sql injection. It sucks, but ... imperfect world, scarce resources etc.

>> your algorithm is exponential in the typical case

What? Why does your algorithm have to be exponential if it's in Prolog? What the hell are you on about?

Re: How AI based programming could work

#54

Suppose you have an AI that generated some code for you, but it doesn't do exactly what you want. Now try to debug it... what if programming wouldn't involve defining exact steps, but instead just roughly defining what we have and what we want and maybe giving a few hints, and having the computer generally do the right thing - wouldn't that be awesome? I experience enough frustration with things like debugging genera…

Don't we already have a similar situation today with the compiler and application stacks? I'm not writing my business logic in assembler -- I'm writing it in Java, maybe pulling in some third party libraries, using Spring, and then running on the JVM. All kinds of opportunities for things not to work as I expect and then I have to figure out why.

The difference is that, as the article points out, traditional programming languages are far more 'exact' - large systems can become difficult to debug, but that largely arises from the complexity of layered abstractions, whose behaviour is still exact. AI-based systems not only add the complexity of abstraction, but also with their inexactness.

Re: How AI based programming could work

#56

Earlier quoted context omitted.

No, the problem was not that Prolog was too slow. The problem was that it was too stupid. Prolog's strict left-to-right, depth-first search strategy allowed the implementations to be, in fact, quite fast. But that same strategy also kept it from being more than a small step toward true declarative programming, because Prolog programmers have to understand the order in which subgoals are tried. For example, consider a…

>> The problem was that it was too stupid. It's ... a programming language? It's Turing complete. Nobody said it's intelligent. >> It's imperative (ha!) for the Prolog programmer to make sure that clause A is tried before B. That is one of those cases where Prolog takes the pragmatic approach to allow efficient computation rather than sticking to "pure" semantics of the kind that tends to make a big mess of things ju…

I guess my use of the term "stupid" made my post sound more pejorative than I meant it to be. I have enjoyed writing Prolog programs on occasion. Some of my best friends are Prolog programmers!

But I was trying to explain why Prolog is not the declarative language that we all hope for (well, a lot of us do, anyway) and that it initially appeared, to some, to be. And I think the answer to that is exactly what I said. That doesn't mean it's not a useful tool!

> [The cut is] not there to "exploit" anything. The fact that it can be exploited is troublesome, but so is all sorts of stuff in programming, like buffer overruns or sql injection.

Whoa! "Exploit" is a general term; it doesn't just refer to security vulnerabilities. Dictionary.com offers this definition for the verb: "to utilize, especially for profit; turn to practical account: to exploit a business opportunity". (The definition I would offer is "to take advantage of", which can mean to make use of a vulnerability, but doesn't have to: you can take advantage of a convenient feature of a program.)

So when I say people "exploit" the search strategy by using the cut, I mean only that they gain benefit from it; if the search strategy were not so well-defined, the cut would be unusable.

> Why does your algorithm have to be exponential if it's in Prolog? What the hell are you on about?

If you try to write a significant Prolog program without understanding the search strategy, as if it really were a declarative language, your program will wind up being exponential or worse. Merely throwing hardware at this problem won't fix it. That's all I'm saying. I agree I didn't say it well the first time.

Re: How AI based programming could work

#57
The workout then could to start with get started with a single neuron relating to the feedback and also the production and dynamically removing and adding them right up until being nearly some tolerance of effectiveness. A completely new part - once again with a single neuron - could then be generated choosing yet another metric. Maybe something like if one layer is a lot bigger than both of its neighbors. During the long-term I hope it can be much better to depart from the part construction. http://www.crazysales.com.au/ Particularly when moving in direction of fully commited hardware as an alternative to float-crunching on GPUs. Aside from that, a number of the more advanced themes might not exactly be also conceivable with a tidy coating system.

Re: How AI based programming could work

#58

Earlier quoted context omitted.

> The thing I would like to get working is telling the net "here is a ton of different buttons, grids, lists and a lot of other UI stuff, and there are all our products - I want to maximize revenue - do whatever you like to get there". As you referenced in your footnote, this goal is a little like the goal of putting a man on the moon, if the year is 1900. One could the make the case that something resembling an AGI…

IMHO talking about AGI here sounds like "all or nothing" type of thinking. Almost all problems can be formulated as [perhaps very hard] machine learning problems of 3 basic types https://en.wikipedia.org/wiki/Machine_learning#Types_of_prob... . Every ML problem has a lot of algorithms that can be applied to it to solve it. Previously unsolvable problem (e.g. learning playing atari game from pixels) can become solvabl…

Sure. I think what the OP was playing around with was whether we could generalize from, as you said, "expert knowledge of the problem[s] and good algorithms" so that AI could replace components in the incumbent programming paradigms. Agreed, when the end problem is well-defined and you know how "do" machine learning, the world is your oyster.

Re: How AI based programming could work

#59

Interesting idea, but to be honest I think it will never take off in a large scale. If you want to write a vague and generic piece of code that can figure out by itself what it is that its outputs ought to be with regards to its inputs, you are, with effect, creating artificial intelligence. This, in turn, requires teaching. What if suddenly you have new pages on your website? Your AI program thingy wouldn't be able…

My thoughts exactly. AI isn't something that can replace "hard computing". That would be the equivalent of saying that we could replace computer with human doing stuff manually - all we need to do is train that human to not make mistakes most of the time.

I'd be more interested in other way of using AI to automate coding - make it to actually write code. Train it on existing code and let him figure out how to write a piece of code like a programmer would. I think it has much more potential than AI doing the calculations itself.

Re: How AI based programming could work

#60

Earlier quoted context omitted.

>> The problem was that it was too stupid. It's ... a programming language? It's Turing complete. Nobody said it's intelligent. >> It's imperative (ha!) for the Prolog programmer to make sure that clause A is tried before B. That is one of those cases where Prolog takes the pragmatic approach to allow efficient computation rather than sticking to "pure" semantics of the kind that tends to make a big mess of things ju…

I guess my use of the term "stupid" made my post sound more pejorative than I meant it to be. I have enjoyed writing Prolog programs on occasion. Some of my best friends are Prolog programmers! But I was trying to explain why Prolog is not the declarative language that we all hope for (well, a lot of us do, anyway) and that it initially appeared, to some, to be. And I think the answer to that is exactly what I said.…

>> Some of my best friends are Prolog programmers!

:P

>> Whoa! "Exploit" is a general term; it doesn't just refer to security vulnerabilities.

Of course. I didn't mean it in that sense. Buffer overruns can be exploited for non-malicious purposes also. Basically, any quirk of any language or architecture, or really any system, can be exploited for whatever purpose. Let us pause for a second and reflect on The Story of Mel [1] as handed down to us by our forefathers and mothers of old.

So what I'm saying is that the cut is there to stop unnecessary backtracking and not to change the behaviour of your program, but of course there's nothing stopping some poor fool from using it in the latter manner, as indeed I've done too many times in the past myself, being the particularly foolish fool that I am. Prolog programmers even have a term for the two types of cut: "green" and "red", respectively. Any Prolog tutorial or bit of documentation will tell you that the cut is to be used sparingly and only to stop unnecessary backtracking, not to make your program change behaviour. The good ones go to some lengths to give you examples of what happens if you don't stick to the advice. If you screw up after that you have nobody to blame but your inexperience, and that gets better with time.

So the cut is dangerous, but that's all it is.

I learned to program with C# oddly, at the University of Hull in the UK. There, our programming 101 tutor explained why C#, or, hell, Java- and not C or C++. His point was that those other languages are more powerful but because of their power they give you the tools to cut yourself to pieces. He used a metaphor involving a chainsaw, that I don't remember very well (that was back in 2005, 11 years now). But basically his point was that a chainsaw is powerful but you can really hurt yourself with it if you don't know how to use it, so you don't want to start learning ... er, forestry? with one.

Well, think of Prolog as a particularly dangerous language. I will admit this: Prolog is not your friend. It doesn't even try to make things easy for you. It's not an "easy language to pick up and start hacking in immediately". It takes a long time to learn it well and it keeps surprising you in very nasty ways for a very long time.

But- once you've learned it pays back in spades and you can do stuff in it that you can really not do in any other language, like declare grammars and then execute them, and use them to parse strings and generate strings. Or run your code backwards. Or do list appends in single-steps and so on.

Well. Apologies, that got a bit out of hand.

[1] http://www.catb.org/jargon/html/story-of-mel.html

Post reply on HN