13 Replies - 1695 Views - Last Post: 01 April 2014 - 09:43 AM

#1 Mrwebblog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-March 14

Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 10:58 AM

I'm coding a personal project that is intended to have a class or object that can evolve, let's call it "Robot." Robot needs to be able, given a command, to create classes, fields, and functions, and the ability to write logic into those objects for their operation (but do this all generically).

To do this, I've found myself programming classes such as if statements and while statements. Then I have an object which represents a function type called "Method" take any number of those logical statements as parameters for it's own execution logic. I feel like what I am doing is redundant or that I am accidentally writing a programming language in the process of making this machine that can write it's own code.

I realize this is a vague description. I am learning the requirements as I develop it, but I can answer any questions that will help explain. My main question is if anyone recognizes this process and can identify it (or if it is redundant), and if a language other than Java is specifically suited to this type of project.

I also need to be able to pass functions as parameters (currently using an interface Executable to do this).

Is This A Good Question/Topic? 0
  • +

Replies To: Is Java the right language for AI, Machine Learning project

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10466
  • View blog
  • Posts: 38,789
  • Joined: 27-December 08

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 11:17 AM

Since Java is a strong, statically typed language, I highly doubt it will serve your purposes. Even with lambdas, I think you're pursuing something in which Java is ill-suited. I will move this to Software Development for better discussion as to more appropriate tools.
Was This Post Helpful? 1
  • +
  • -

#3 infernorthor  Icon User is offline

  • D.I.C Addict

Reputation: 187
  • View blog
  • Posts: 876
  • Joined: 07-February 14

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 11:35 AM

You need to write code, and then call the compiler. And load/run the new code. I don't think Java can load during run-time.

What you are asking is more of the realm of the Operating System. You should at learn how they load programs, handle processes, function stack. You are probably better using a language for the operating system.
The above usually depends on user input. Like IDE you click the button to start the compiler. No reason you couldn't automate that.

I assume you are looking into AI.
You should look how program optimization works, done during compiling.
And how to figure out time complexity. It wouldn't be good to have an AI that doesn't stop, or can't find a solution.

You code play hop scotch.
Run->GeneratesCode ->CompileIt -> Run-> GeneratesCode etc.

This post has been edited by infernorthor: 28 March 2014 - 11:36 AM

Was This Post Helpful? 1
  • +
  • -

#4 Mrwebblog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-March 14

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 12:38 PM

Thanks for your replies, I understand what you are saying.

Java has the ability with ClassLoader or using the bytecode manipulation tools to do what you are saying though.
Linux for example is written in C, so I see no reason why C would be better than Java right now.

The way I am solving the problem of having to reload classes is writing serialized objects to a file..
I don't need the robot to necessarily modify itself, but it's contents.

@macosxner101 Is there a language you would recommend?
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9088
  • View blog
  • Posts: 34,135
  • Joined: 12-June 08

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 12:59 PM

The way I am solving the problem of having to reload classes is writing serialized objects to a file..
I don't need the robot to necessarily modify itself, but it's contents.

What sort of contents? How far off the reservation do you plan on allowing the content to change? That is to say - can you codify the variation of changes to a scheme of some sort?
Was This Post Helpful? 1
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10466
  • View blog
  • Posts: 38,789
  • Joined: 27-December 08

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 01:03 PM

Quote

Java has the ability with ClassLoader or using the bytecode manipulation tools to do what you are saying though.

I'm familiar with ClassLoader. I worked with it a few years back. It's not fun to do.

Python and MATLAB seem to be the languages of choice for AI and Machine Learning nowadays. I'd probably begin looking there. Note that I'm very much *not* an AI expert, so take it with a grain of salt.
Was This Post Helpful? 1
  • +
  • -

#7 Mrwebblog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-March 14

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 01:11 PM

View Postmodi123_1, on 28 March 2014 - 12:59 PM, said:

The way I am solving the problem of having to reload classes is writing serialized objects to a file..
I don't need the robot to necessarily modify itself, but it's contents.

What sort of contents? How far off the reservation do you plan on allowing the content to change? That is to say - can you codify the variation of changes to a scheme of some sort?


The content can change in immediate members of the main Robot class (if I understand your question right).

Quote

codify the variation of changes to a scheme
--> that's what I'm working on
Was This Post Helpful? 0
  • +
  • -

#8 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 01:12 PM

I would recommend Python for this kind of thing. There are an absolute ton of very good existing AI libraries already out there ready for you to use if you should so need to (or you can of course make your own).

Everyone I know who's doing research into machine learning seems to also be using Python nowadays. It's no coincidence that most people in this field are using it.
Was This Post Helpful? 1
  • +
  • -

#9 Mrwebblog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-March 14

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 01:13 PM

Java is just making that process difficult.. but so would Lisp.
For this project, it seems like I need some odd combination of OO and functional programming.
Was This Post Helpful? 0
  • +
  • -

#10 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7644
  • View blog
  • Posts: 12,890
  • Joined: 19-March 11

Re: Is Java the right language for AI, Machine Learning project

Posted 28 March 2014 - 07:32 PM

We should probably distinguish between the terms "Machine Learning" and "AI", and also distinguish between those and what you're talking about doing.

Machine learning, basically, is a complete misnomer. The term suggests that the machines are learning something - but it's really more that you're learning something by using the machine. It bears no resemblance to "intelligence" at all. Although you can use machine learning algorithms to make surprisingly sophisticated discriminations, there is no attempt to recognize any generality or extrapolate from what is "learned". So for example, you can write a machine learning system and train it to recognize images of faces by their numerical similarity to a training set you've selected, but you can't train it to know or care what a face might be. We're still talking about a tool that has to be completely guided in its application - the fact that its output is a recognition of a numerical pattern that happens to be related to an image is no more sign of any intelligence than the fact that a certain ancient Greek algorithm can recognize a numerical pattern that happens to belong to number theory is a sign that a machine running an instance of Eratosthenes' sieve is going to start reading Tolstoy and debating ethics with Derek Parfit.
Don't get me wrong - machine learning is awesome and cool in all sorts of ways, as a tool and as a mathematical achievement and as a demonstration of the pervasiveness and strength of pattern in all sorts of areas. It's just got nothing to do with artificial intelligence, or any kind of intelligence apart from that of the designers of the systems. Interesting stuff, but it has nothing at all to do with what you're talking about doing.

AI, on the other hand, is a branch of cognitive science, which uses computers to model theories of cognition in order to test them - basically, they're setting up a wind tunnel for the mind. This is closer to the sort of thing you're after, and this is where a lot of the popular techniques of the functional programming world were developed. You should look at some of the Lisps, perhaps at Abelson and Sussman's Structure and Interpretation of Computer Programs course for a sort of retroactive distillation of the programming model that was developed in MIT's AI Lab. To follow along with those guys, probably you'll want to learn a lisp or two, though you might end up using a more modern language with a more Algol-style syntax. A lot of the stuff you'll learn here will feel right at home to you.

But when I look at what your actual project, it's not clear to me that you're doing GOFAI, either. In fact, the more I read your question, the less I'm sure I understand what it is you're after. Possibly your ideas might converge with some of those in logic programming, I'm not sure. In any case, it would be possible to do this in Java. I agree with the general consensus that Java's not the obvious first choice, but there's no reason it wouldn't be possible. The trouble is, you might end up proving Paul Graham's law, and implmenting sizable portions of a Lisp in the process of implementing this in Java. So maybe you'd learn a lot - maybe you'd learn more than you're looking for, in fact, and you' prefer to just get on with your project and not do quite so much learning.
But I don't think Lisp is necessarily your best bet either. Python? Maybe, but python doesn't really provide the sort of fluidity of function composition that I think you're looking for. My gut instinct suggests that you should consider Scala, which is a solid functional language that runs on the jvm. From what I've done with it - which isn't a lot, I admit - it feels like it might suit your needs.

Quote

For this project, it seems like I need some odd combination of OO and functional programming.


This isn't an odd notion at all - but Scala certainly fits this bill. Ruby might also be an interesting direction.

This post has been edited by jon.kiparsky: 28 March 2014 - 07:35 PM

Was This Post Helpful? 3
  • +
  • -

#11 Mrwebblog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-March 14

Re: Is Java the right language for AI, Machine Learning project

Posted 29 March 2014 - 12:56 AM

View Postjon.kiparsky, on 28 March 2014 - 07:32 PM, said:

you might end up proving Paul Graham's law, and implmenting sizable portions of a Lisp in the process of implementing this in Java.


just had that realization, when I was implementing an object with a car and a cdr.

I am familiar with scheme (lisp) to a degree, but I will look into Scala. Thank you for your recommendations. I could have described the project a little better, as a Natural language computer. Java is proving to be a pain, since pass by value. I think C is an option I might attempt, but I need to find out how to write serialized objects (or the C equivalent).
Was This Post Helpful? 0
  • +
  • -

#12 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Is Java the right language for AI, Machine Learning project

Posted 29 March 2014 - 05:32 AM

Quote

Java is proving to be a pain, since pass by value


That's usually due to design problems rather than issues with the language itself.
Was This Post Helpful? 1
  • +
  • -

#13 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1951
  • View blog
  • Posts: 4,052
  • Joined: 11-December 07

Re: Is Java the right language for AI, Machine Learning project

Posted 01 April 2014 - 09:32 AM

If I understand correctly, you want to write one program (let's call it Skynet) that uses an AI technique to write other programs (let's call them Arnie). There are two languages to consider here: the one you use to write Skynet and the one you use to write Arnie. They don't have to be (and probably shouldn't be) the same.

When you are writing Skynet, things that matter are the libraries available, your familiarity with the language, what the community uses and language features that suit the problem. The relative importance is contextual but any general purpose language will do the job just fine. Java is fine, Python is fine, so is Scala. I'd probably get a working solution faster in Java due to familiarity.

For Arnie, I would want a language that has very few building blocks. If you choose Java, Python or Scala then you'll only end up using a subset of the language anyway. You probably want something that is Turing equivalent but not much more. Smalltalk and LISP are, at their core, very simple languages. You could probably find a suitable dialect of either.

What might be better is designing your own small language that is made up of executable (or evaluable) chunks. Skynet could then compose variations and evaluate them.
Was This Post Helpful? 2
  • +
  • -

#14 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1951
  • View blog
  • Posts: 4,052
  • Joined: 11-December 07

Re: Is Java the right language for AI, Machine Learning project

Posted 01 April 2014 - 09:43 AM

I neglected to explain that the language I recommend you make up doesn't need to be written in text but composed of objects (or functions and lambdas). For example, ((2 * 5) + 3) / 10 would be a mathematical expression written in text. Composed of objects it might look like this:

Expression exp = new Divide(new Add(new Multiply(new Decimal(2), new Decimal(5)), new Decimal(3)), new Decimal(10))


The text is easy for humans to write, read and manipulate but the object hierarchy is easier to manipulate in code.
Was This Post Helpful? 3
  • +
  • -

Page 1 of 1