DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 5th February 2009
idefix idefix is offline
Port Guard
 
Join Date: May 2008
Location: Flanders-Belgium
Posts: 16
Default Java and AI-programming

I'm interested in AI, especially now that the www is a gigantic knowledge pool. I thought I'll learn C in order to experiment with getting "knowledge" from the internet and use it in a program. However, someone told me to take a higher level language like Java, because C is for system programming. Java is very good in accessing the internet, html processing,... all things I will need. In C I will have to program everything myself. Even a string in C is actually just an array of chars (ints)...

However, as soon as I began learning Java, I had the feeling Java is too bloated. Just simply testing 2 objects for equality, forces you to write an error-prone equals method.
Input and output is organized in a tremendous amount of classes: Digest Outputstream, Deflater OutputStream, Checked OutputStream, Buffered OutputStream,....
I think I won't be able to memorize the language, it's just too big. On the other hand C is smaller, but you have to write everything yourself.
What's your opinion about this? Is C suited for AI-programming? Is Java better?
I'm a hobbyist, not a professional, if that's relevant.
Reply With Quote
  #2   (View Single Post)  
Old 5th February 2009
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by idefix View Post
I'm a hobbyist, not a professional, if that's relevant.
It is. Because you need to find something that feels/seems natural to your sense of logic such that you stick with moving forward. What we often see is people with a great deal of exuberance at the beginning fade due to a lack of a clear goal which propels them through the hills & valleys of the learning curve they need to surmount. So if C seems more natural to what you want, use it. If not, use a different language.

Java isn't the only alternative. I would suggest Python because it is devoid of a lot of syntactic clutter that bogs a number of people down. You should also consider Perl because it has a mature third-party library where some modules specifically target Web spidering.
Quote:
...someone told me to take a higher level language like Java, because C is for system programming. Java is very good in accessing the internet, html processing,... all things I will need.
Java is a reasonable alternative. Some call it bloated because their perspective is biased from experiences in different languages. All languages have to market themselves to become institutionalized, & Sun chose to throw in lots of libraries. Maybe some target your goals, & most likely a number don't. Java is a big language today, & no one knows all of its libraries. Knowing it all shouldn't be your goal. What should be your goal is to learn what is needed to solve problems in the domain you are interested.
Quote:
What's your opinion about this? Is C suited for AI-programming? Is Java better?
I'm not convinced this is the right question. My suggestion would be look through the CPAN modules for Perl & see if any meet your needs. If any do, then the answer is much more clear. You can find CPAN at the following address:

http://cpan.org/
Reply With Quote
  #3   (View Single Post)  
Old 5th February 2009
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

It depends on what you want to do with AI. There is a big difference between AI intended for scientific purposes than AI intended for games. I have more experience in game AI than traditional AI, so I will speak on that.

As for AI for games, the majority of game development is done currently in C++. You can use any language (some are certainly less ideal, though), including Java or C (two popular alternate choices for game AI).

Is C suited for game AI? It is for more traditional games, like board games. For example, in my game AI class I wrote a good checkers game in C.

If you are more comfortable in Java, there is no problem learning game AI in Java. The big thing is to learn the AI algorithms, with the actual language you use to implement them of secondary importance -- as it is in computer programming in general.
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #4   (View Single Post)  
Old 6th February 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

I would have to second the Perl / Python bit; they are both excellent languages for dealing with the Internet and processing data. Perl is arguably one of the most expressive languages ever made (if there is anything more expressive for general programming, it would probably have to be ASM or LISP). Python can often be used to produce maintainable code that also gets the job done painlessly, although the maintainability part depends on the monkey.


Perl is however a huge language syntactically, and Python has many standard modules to choose from. Java is a very simple language to learn IMHO, but like virtually every major language -- it pays to have a "stdlib" reference on hand. With C, the UNIX manual pages serve the purpose well enough (and a few Richard Stevens books won't hurt). Python & Perl provides pydoc and perldoc respective, both with great online docs. Java is also documented online -- use the parts you need, don't worry about memorizing java.foo.bar;

C is a very small language, and I know of nothing smaller... unless you want to start comparing some instruction sets & assemblers with it.


If you want to study AI, rather then just explore on your own; you'll probably need to learn some Lisp sooner or later. A good way to pick up a little lisp would be to grab a copy of the Scheme standard and SICP.



C often boils down to write your own or find code written by someone else; there are many great libraries (and many not so great ones) for most common tasks. The C-Strings for example, very simple and very useful, complete with many common functions0; but they are also a pain in the ass occasionally. C++'s std::string, Javas String, and Pythons str can often be more expedient -- in Perl, look for regular expressions.


Every language is like that, just pick what batteries you need and learn them.




Quote:
Originally Posted by idefix View Post
[in Java] Just simply testing 2 objects for equality, forces you to write an error-prone equals method.
Input and output is organized in a tremendous amount of classes: Digest Outputstream, Deflater OutputStream, Checked OutputStream, Buffered OutputStream,....

What's your opinion about this? Is C suited for AI-programming? Is Java better?
Although I've never read his paper, I'll essentially quote Fred Brooks: there is no silver bullet, and add to it: use what works, and what works for you.


Some love C, some love QBASIC, whatever works ;-).
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #5   (View Single Post)  
Old 7th February 2009
idefix idefix is offline
Port Guard
 
Join Date: May 2008
Location: Flanders-Belgium
Posts: 16
Default

Hi guys,

I think I'll follow the Python advice. Amazing how one can fetch the content of a web-page in 3 lines:

Code:
import urllib
fp = urllib.urlopen("http://www.google.be")
s = fp.read()
And the good thing for me is: this is all clear, it reads like plain English!

THANKS for the advice!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
c programming - Modules corey_james Programming 3 6th November 2008 08:49 PM
Learning Programming Crypt Programming 35 27th October 2008 04:54 PM
GUI Programming bsdnewbie999 Programming 6 17th August 2008 12:19 AM
C programming - Lint corey_james Programming 14 16th May 2008 11:05 PM
Java socket programming question 18Googol2 Programming 3 3rd May 2008 11:50 AM


All times are GMT. The time now is 06:10 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick