Should I learn C++ or Prolog?

This is a discussion on Should I learn C++ or Prolog? within the C++ Programming forums, part of the General Programming Boards category; Well im making a AI program and I heard prolog is good for AI. Anyone here know Prolog? I just ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    18

    Should I learn C++ or Prolog?

    Well im making a AI program and I heard prolog is good for AI. Anyone here know Prolog? I just dont know what to use, C++ might be hard for AI. My AI program will have databases, the program will have to search the databases for certain phrases or words etc. Can anyone clue me in on if C++ of Prolog is best for AI? Thanks

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    Quote Originally Posted by coreyt1111
    Well im making a AI program and I heard prolog is good for AI. Anyone here know Prolog? I just dont know what to use, C++ might be hard for AI. My AI program will have databases, the program will have to search the databases for certain phrases or words etc. Can anyone clue me in on if C++ of Prolog is best for AI? Thanks
    Learn both, I'm sure there are ways to communicate to C code from prolog so you can write the database stuff in C++ and the real AI code in prolog.
    I've done some AI stuff in an embedded script language in Java a long time ago. Was a functional language you could just write in your java programs.

    Something like:

    Code:
    Results Result = AIEngine.Execute("(((1 2 +) 3 *) 4 /)");

  3. #3
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Try Scheme.
    There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    18
    You think I should learn both? Isn't C++ powerful enough to handle it all?

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Ahh, Scheme... like a genie bottle. You don't get much, but you can do a lot with the little you have, so long as you don't screw up along the way. At least real hackers don't.


    Isn't C++ powerful enough to handle it all?
    Then go write your killer app in Assembly. It is also, by your definition, "powerful enough". C++ is fast, but not as powerful as some other languages. Given the scope of today's C++ libraries, you might find that most of the low-level work has already been done by someone else and you can concentrate on the high-level work, and can do all the work in a single language. But high-level languages like Lisp and Prolog might not be as inefficient as Laserve suggests, especially if there is some optimizing compiler or interpreter avaliable for them.

    I generally consider using many languages to solve a problem as hackish (no compatibility guarantees) and unproductive (abrupt paradigm switches, steep and possibly unnecessary learning curve), and should only be used as a last resort. Other opinions may differ. Don't base your decision on opinions of only a few people. *


    EDIT: Unless they happen to be very knowledgable or experienced people. Try members with high post counts, or moderators.
    Last edited by jafet; 11-13-2006 at 08:33 AM.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I just dont know what to use, C++ might be hard for AI.
    AI is hard in general, but you'll find that functional languages are much better suited to it.

    >Can anyone clue me in on if C++ of Prolog is best for AI?
    All things being equal, and only given those two choices, I would say Prolog.

    >You think I should learn both? Isn't C++ powerful enough to handle it all?
    You're looking at the usual answer to a "should I learn x or y?" question. However, that answer doesn't really apply to your question because your question is for a specific project, not for general knowledge. However, keep in mind that the majority of software glues together modules written in different languages where each module is written in the language best suited to the problem being solved.
    My best code is written with the delete key.

  7. #7
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    >You think I should learn both? Isn't C++ powerful enough to handle it all?
    Learn what's useful to you. If you're going to stick with AI programming your whole life, then you may choose Prolog (or some other AI language), but if you think AI is not the only thing you're going to need, then choose C++.

    C++ is powerful enough to handle everything. Just that some other languages may be easier to do certain things.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,261
    Quote Originally Posted by maxorator
    >You think I should learn both? Isn't C++ powerful enough to handle it all?
    Learn what's useful to you. If you're going to stick with AI programming your whole life, then you may choose Prolog (or some other AI language), but if you think AI is not the only thing you're going to need, then choose C++.

    C++ is powerful enough to handle everything. Just that some other languages may be easier to do certain things.
    In the same way as you can use a toothbrush to clean the floor, you can use C++ for AI, but it is usually so much easier in Prolog.

    Though in this case I have to say that it is not merely a case of which tool is best for the job. It is the case that you should learn both anyway because it will force you to bend your mind into shape. The two languages are about as different as concievably possible. (or even inconcievably if you have not yet seen Prolog )

  9. #9
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    en.wikipedia.org/wiki/Prolog
    Looks like a glorified Scheme to me, I don't know.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  10. #10
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    It isn't. Scheme is functional, Prolog is logic-oriented. They're fundamentally different.

    I generally consider using many languages to solve a problem as hackish (no compatibility guarantees) and unproductive (abrupt paradigm switches, steep and possibly unnecessary learning curve), and should only be used as a last resort. Other opinions may differ.
    Mine does. A problem should always be divided into subproblems. Then, a different language might offer significant advantages in solving a particular subproblem.
    Look at the real world. Build processes are nearly never written in the same language as the program itself. Many, if not most, compilers have their scanners and parsers written in domain specific languages like Lex and Yacc, and their optimizations in some rule language. Languages differ between backend and frontend (Mozilla, for example, is written in C++ and some C in the backend, but JavaScript in the frontend).

    And so on.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  11. #11
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Yeah, CornedBee, I seriously need more programming EXP points. Maybe they both look the same to me because they're both so different from C++. Ok, better shut up now.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Prolog
    By YankeePride13 in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-15-2005, 02:50 PM
  2. Novice trying to learn C++
    By dead in forum C++ Programming
    Replies: 10
    Last Post: 12-01-2003, 08:25 PM
  3. suggestions please! how do i learn OS / Languages?
    By nchauhan in forum C++ Programming
    Replies: 8
    Last Post: 08-06-2003, 11:17 AM
  4. Wanna learn Assembly?
    By Garfield in forum A Brief History of Cprogramming.com
    Replies: 137
    Last Post: 06-29-2002, 01:49 AM
  5. Learn Win32 API or C++Builder?
    By Flucas in forum Windows Programming
    Replies: 1
    Last Post: 10-18-2001, 01:49 AM

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