I have noticed people speak about AI. My perception of A.I is code written such that a program can learn and simulate human behavior or even write its own code. I want to know if this can be done with java language on an IDE and if so an example code would be nice( code that can write its own code).
-
1AI is not about code that modifies itself, it's rather about making programs that write other programs. – niculare Jul 18 '14 at 09:43
-
We all use code that writes code every day: the compiler. We write our code in a .NET language (or Java in your case) or whatever, then through some IL magic, we eventually get down to machine code. If the computer already knew what it *wanted* to do, that could just be another layer of abstraction on top of that, and that's not too difficult to imagine. – Matthew Haugen Jul 18 '14 at 09:47
3 Answers
This can be done in any general-purpose language; there is nothing inherent to a computer language which would make the resulting program either able or unable to "learn" because learining is a much higher-level concept.
Also note that learning is not exactly a clear-cut concept: any program whose behavior changes based on previous input could be argued to have "learnt" something.
Historically, LISP has been perceived as a language particularly well-suited for AI work, and indeed was the primary language of the AI movement of the '80s. An important reason for this is that it is particularly easy to make a program which writes LISP programs. This not to say that a Java program couldn't be made to do the same; it would just be far less convenient and require much more library support.

- 1,833
- 9
- 14
What you refer to is called http://en.wikipedia.org/wiki/Self-modifying_code and is not the same as AI. It was often used in the assembler days for performance optimization (for example removing a conditional statement after it is sure it will never be executed again) but I have never seen it used in Java, even thought it surely is possible. See also Self modifying code in Java.

- 1
- 1

- 11,100
- 16
- 60
- 118
You might want to take a look at machine learning. This branch of AI revolves around systems which learn from data given to them. If you really want to learn, there is a course available on machine learning on coursera.org.

- 1,416
- 1
- 15
- 24