![]() |
| | #1 |
| Registered User Join Date: Nov 2008 Location: Dubai, U.A.E.
Posts: 15
| AI Programming language 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 | |
| | #2 |
| Rampaging 35 Stone Welsh 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 | |
| | #3 | |
| Registered User Join Date: Nov 2008 Location: Dubai, U.A.E.
Posts: 15
| Quote:
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 | |
| | #4 |
| Rampaging 35 Stone Welsh 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 | |
| | #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 | |
| | #6 | |
| Registered User Join Date: Nov 2008 Location: Dubai, U.A.E.
Posts: 15
| Quote:
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) | |
| knightjp is offline | |
| | #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 | |
| | #8 | |
| Registered User Join Date: Nov 2008 Location: Dubai, U.A.E.
Posts: 15
| Quote:
| |
| knightjp is offline | |
| | #9 |
| Rampaging 35 Stone Welsh 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 | |
| | #10 | |
| Registered User Join Date: Nov 2008 Location: Dubai, U.A.E.
Posts: 15
| Quote:
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 | |
| | #11 |
| Rampaging 35 Stone Welsh 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 | |
| | #12 |
| Registered User 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 | |
| | #13 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
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 | |
| | #14 | ||
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,099
| Quote:
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:
| ||
| Elysia is offline | |
| | #15 | |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,927
| Quote:
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
__________________ 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 | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |