C Board  

Go Back   C Board > Cprogramming.com and AIHorizon.com's Artificial Intelligence Boards > General AI Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-23-2008, 04:04 AM   #1
Registered User
 
knightjp's Avatar
 
Join Date: Nov 2008
Location: Dubai, U.A.E.
Posts: 15
AI Programming language

Hey,

New to this site. Actually new to programming in C and its variants too. I wanna get into programming in AI but, and I went through alot of articles n forums on the net trying to find out which language is the best for it.
I hear that Lisp is a very suitable option along with Prolog. These stand as the usual choices and then I noticed that some use Java and C/ C++, out of which C is faster.
I have a just couple of questions about AI programming.
Which programming language is faster? If C/C++, which variant is the better to go with?
knightjp is offline   Reply With Quote
Old 11-23-2008, 06:57 AM   #2
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,927
Programmign languages have many features that make one 'better' than another for a specific application. If execution speed is your primary concern then I highly recommend C/C++ or Assembly. Assembly is ultimately the fastest, but it generally takes a lot of in dept knowledge about teh target processor to take full advantage fo it. Barring that, C/C++ is probably the fastest for programmers. LISP, ADA, etc. are all very good languages for formal AI development as they have a lot of features that are specific to AI. They should be fairly close to C/C++ in execution speed if you have a modern professional compiler. If you are doing AI in a purely research environment, then one of those is probably better due to the lower development time involved, but for real world applications I recommend C/C++ as it gives you access to a lot of other features, libraries and API's that LISP and ADA wont necessarily.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is offline   Reply With Quote
Old 11-23-2008, 07:18 AM   #3
Registered User
 
knightjp's Avatar
 
Join Date: Nov 2008
Location: Dubai, U.A.E.
Posts: 15
Quote:
Originally Posted by abachler View Post
Programmign languages have many features that make one 'better' than another for a specific application. If execution speed is your primary concern then I highly recommend C/C++ or Assembly. Assembly is ultimately the fastest, but it generally takes a lot of in dept knowledge about teh target processor to take full advantage fo it. Barring that, C/C++ is probably the fastest for programmers. LISP, ADA, etc. are all very good languages for formal AI development as they have a lot of features that are specific to AI. They should be fairly close to C/C++ in execution speed if you have a modern professional compiler. If you are doing AI in a purely research environment, then one of those is probably better due to the lower development time involved, but for real world applications I recommend C/C++ as it gives you access to a lot of other features, libraries and API's that LISP and ADA wont necessarily.
Thanks for the info.. Now just to confirm what you are saying, Lisp, etc. are good and the easiest for AI programming. However C/C++ is more complex, executes faster and has more added features.
I tend to agree that Assembly would be the best. However it might not work for me.
I work on a mac. My current mac is one of the old PowerPC types and I'm looking to be able to port my program into a new Intel processor one later on.
knightjp is offline   Reply With Quote
Old 11-23-2008, 07:46 AM   #4
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,927
C/C++ is generalyl the most portable, although as long as you have a LISP compiler for both OS's your LISP code should port too. The real issue is whether you will eventually want yoru application to do mroe than just AI, for example, if you are writing AI that will go into a game, then you should probably choose a language that is good for both game development and AI development. On the other hand, if learnign 2 languages isnt an issue, you could always learn both adn write the AI in LISP and the game in say C/C++ then just link in the LISP LIB. This is why in general I recommend C/C++, because while it may not be 'Teh Bestest' at a given task, it is damned good at everything.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is offline   Reply With Quote
Old 11-23-2008, 08:32 AM   #5
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
AI also covers a huge area of different subjects, such as playing chess, targeting the player in a game, understanding human language (that is, English, Japanese or some such, as different from computers understanding PROGRAMMING LANGUAGES such as C), expert systems that can sort out what parts of information is relevant to a proble (e.g. helping a doctor diagnose an illness).

All of the above problems have several different solutions that may require different language features and algorithms to solve the problem.

Languages are like cars. If you ask "what car is best" we could answer "A Ferrari", but if you ask "I have half a ton of large boxes to transport, which car is best", then the answer is ABSOLUTELY NOT "A Ferrari". On the other hand, if you ask "I'd like an expensive, flashy car to attract rich, young females and that goes fast around a race-track", then Ferrari is one of the possible "right" answers. Likewise for languages, the size, type of problem and expected performance vs. development time will determine which is the "right" language.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.

Last edited by matsp; 11-23-2008 at 08:36 AM.
matsp is offline   Reply With Quote
Old 11-24-2008, 08:31 PM   #6
Registered User
 
knightjp's Avatar
 
Join Date: Nov 2008
Location: Dubai, U.A.E.
Posts: 15
Quote:
Originally Posted by matsp View Post
AI also covers a huge area of different subjects, such as playing chess, targeting the player in a game, understanding human language (that is, English, Japanese or some such, as different from computers understanding PROGRAMMING LANGUAGES such as C), expert systems that can sort out what parts of information is relevant to a proble (e.g. helping a doctor diagnose an illness).

All of the above problems have several different solutions that may require different language features and algorithms to solve the problem.

Languages are like cars. If you ask "what car is best" we could answer "A Ferrari", but if you ask "I have half a ton of large boxes to transport, which car is best", then the answer is ABSOLUTELY NOT "A Ferrari". On the other hand, if you ask "I'd like an expensive, flashy car to attract rich, young females and that goes fast around a race-track", then Ferrari is one of the possible "right" answers. Likewise for languages, the size, type of problem and expected performance vs. development time will determine which is the "right" language.

--
Mats
I like the illustration of the ferrari. I'm well aware of the reason one programming language is chosen over another for a particular task. The thing is.... I was told that any language can be used to do AI, but some will be easier than others.
Considering development time is not an issue with me (as this is a personal hobby project) and my program will be something of a robot like thing.

I got the idea from watching Albert in "The Absent-minded Professor" (see attachment)
Attached Images
   
knightjp is offline   Reply With Quote
Old 11-25-2008, 03:15 AM   #7
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
So, you still need to figure out what sort of AI it is - some forms require a lot of calculations (so Fortran, C or C++ would be good candidates), others are decision based (which at least is easier to write in Prolog or some such), yet others deal with huge lists of items that need to be worked on in some way, and a language that has "lists" as it's basic functionality is a good candidate here - LisP stands for List Programming [of course, almost all AI are a combination of these things - but there's one of these that are the MAJORITY of the work].

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 11-25-2008, 03:55 AM   #8
Registered User
 
knightjp's Avatar
 
Join Date: Nov 2008
Location: Dubai, U.A.E.
Posts: 15
Quote:
Originally Posted by matsp View Post
So, you still need to figure out what sort of AI it is - some forms require a lot of calculations (so Fortran, C or C++ would be good candidates), others are decision based (which at least is easier to write in Prolog or some such), yet others deal with huge lists of items that need to be worked on in some way, and a language that has "lists" as it's basic functionality is a good candidate here - LisP stands for List Programming [of course, almost all AI are a combination of these things - but there's one of these that are the MAJORITY of the work].

--
Mats
As far as my plan is, the AI will be something like an operating system that can operate my computer with only a verbal command from me. Which is why I was thinking that C would be a good candidate as the heart of the Mac OS is a Unix platform written in C code.
knightjp is offline   Reply With Quote
Old 11-25-2008, 09:54 AM   #9
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,927
Its true, any Turing complete language can be used for AI, or any other problem for that matter, but as mentioned some will be easier to use for spcific type of AI. So choose your problem, then choose the most appropriate AI algorithm to use, then choose the best language for that algorithm. That is the opimum solution, hoever, since learning a new language entails some overhead, it generally falls down to what is the best language to learn for solving any problem that happens to crop up, in which case C/C++ is IMO the obvious choice, but then im biased.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is offline   Reply With Quote
Old 11-25-2008, 08:30 PM   #10
Registered User
 
knightjp's Avatar
 
Join Date: Nov 2008
Location: Dubai, U.A.E.
Posts: 15
Cool

Quote:
Originally Posted by abachler View Post
Its true, any Turing complete language can be used for AI, or any other problem for that matter, but as mentioned some will be easier to use for spcific type of AI. So choose your problem, then choose the most appropriate AI algorithm to use, then choose the best language for that algorithm. That is the opimum solution, hoever, since learning a new language entails some overhead, it generally falls down to what is the best language to learn for solving any problem that happens to crop up, in which case C/C++ is IMO the obvious choice, but then im biased.
I would tend to agree. I guess I'm looking for a language that I could do anything with; whether it be AI, database or any other project.
Java is a candidate, but I'm not too keen on it. I tried Applescript, but when compared to C, the executing time is slower. C & Assembly were my obvious choices and after debating between the two I chose C. I guess I'm biased too.... lol

Last edited by knightjp; 11-25-2008 at 08:40 PM.
knightjp is offline   Reply With Quote
Old 11-25-2008, 09:22 PM   #11
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,927
Part of my decision comes from the fact that I grew up with computers that were really really slow so to get anything approximating throughput from them it was necessary to scavenge every possible processor cycle. This is part of the reason I learned assembly (years before i learned C/C++) and later C/C++. Obviously as my projects became larger I needed a high level language like C/C++ but my roots are in assembly and languages that try to abstract the programming environment too far away from the metal just make me think 'what's the point?'. I know a lot of people have problems with memory management, but after doing memory management in assembly on a 6502, memory management in C/C++ seems incredibly simple. For me keeping track of whether an object has been dereferenced into oblivion would put more bugs into my applications that it woudl remove by saving me those rare times when I forget to deallocate the object explicitly in a deconstructor. Ive been doing it so long now that its just second nature. Then again, I am in MENSA, so maybe I just have fewer problems learning these things. There was a time when I was actually anti C++ because at the time it entailed a lot of overhead and ran slower than C.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is offline   Reply With Quote
Old 11-25-2008, 11:07 PM   #12
Registered User
 
knightjp's Avatar
 
Join Date: Nov 2008
Location: Dubai, U.A.E.
Posts: 15
You learned Assembly? You must be a master. Do you think that it will be good for AI? Or is it too complex?
knightjp is offline   Reply With Quote
Old 11-26-2008, 03:49 AM   #13
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Quote:
Originally Posted by knightjp View Post
You learned Assembly? You must be a master. Do you think that it will be good for AI? Or is it too complex?
Assembler can do anything - but it's hard work, because a simple C statement easily becomes 5-10 lines of assembler code. And if you think that C is not a very "safe" language, assembler is much worse - you REALLY need to keep track of all your types and what goes where yourself.

I wouldn't say that it's a good language for AI in general.

Assembler should be used:
1. When something CAN NOT be done in a higher level language (context switching in the OS for example, where you'd have to store and restore specific registers to make it work)
2. When it is PROVEN that the compiler generates slow code for a small portion of the whole application, and there is no easy way to make the compiler produce better code.
3. When the application is so small that it can be written in a few hundred lines of assembler, and memory is critical (e.g. tiny embedded projects).

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 11-26-2008, 06:54 AM   #14
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
Quote:
Originally Posted by knightjp View Post
As far as my plan is, the AI will be something like an operating system that can operate my computer with only a verbal command from me. Which is why I was thinking that C would be a good candidate as the heart of the Mac OS is a Unix platform written in C code.
I would recommend C++ if your platform supports it (and if you choose to go C/C++), because it's higher level than C, and higher level always means making it easier for you. As well, it is a somewhat modern language with powerful features and tools - but the best thing is that in case you need to go lower, then C++ is backwards compatible with C and hence you can do those lower parts in C, too. Or you can compile them using a C compiler, if you wish.

And let's be fair about one thing - the myth that C is faster than C++ just is not true. They have advantages and disadvantages and are thus about equal in speed.

C and C++ can sometimes also deal with assembly, although it's tricky and requires safety guidelines.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 11-26-2008, 02:14 PM   #15
Rampaging 35 Stone Welsh
 
abachler's Avatar
 
Join Date: Apr 2007
Posts: 2,927
Quote:
Originally Posted by knightjp View Post
You learned Assembly? You must be a master. Do you think that it will be good for AI? Or is it too complex?
as matsp states there are some caveats, but he forgot my favorite -

4. To make your collegues gape in wonderment.

and

5. When you can do in 12 lines of assembly what it will take 1 lines in C/C++, e.g.

Code:
__asm pusha
__asm mov         ecx , 0x00100000
__asm mov         eax , GPU_Array
__asm mov         edx , Inputs
__asm mov         esi , 0x00000010
loop_start:
__asm add         eax , esi
__asm movapd    xmm0 , [edx]
__asm add         edx , esi
__asm movapd    [eax] , xmm0 
__asm loop         loop_start
__asm popa
why would you do that you ask? because it lends itself to optimizations that are not possible in C/C++, because it produces faster code, because it obfuscates what you are doing, and because it produces different results than a simple CopyMemory(), specifically it will throw if you try to use unaligned memory which may indicate an error condition on the GPU.
__________________
He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet
abachler is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why C Matters DavidP General Discussions 136 01-16-2008 09:09 AM
chess ai contest Raven Arkadon Contests Board 7 07-09-2005 06:38 AM
AI Contest Proposal MadCow257 Contests Board 4 03-13-2005 03:27 PM
Language of choice after C++ gandalf_bar A Brief History of Cprogramming.com 47 06-15-2004 01:20 AM
Game Design Topic #1 - AI Behavior TechWins Game Programming 13 10-11-2002 10:35 AM


All times are GMT -6. The time now is 05:45 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22