views:

407

answers:

6

I'll be writing an XMPP (Jabber) bot, and I need to decide in which language should I write it. Currently I'm considering Python, Java, and PHP.

Since I'm expecting the bot to be running most of the time (i.e. 23.5/7), are there some specific arguments for or against using one of these languages? (e.g. not "$x sucks", but "$y has good daemon library" or "$z leaks memory")

The bot's purpose will mostly be responding to user input.

If none of these languages seem suitable to you, what would you recommend?

+4  A: 

If you want to service for multiple users at the same time(probably you want), PHP may not be a good choice, since it does not support(or experimentally support) threading, you have to fork a copy of your application for each user.

I recommend Java for this purpose. Sun describes Java as "simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, and dynamic.".

In my opinion with exception of time critical jobs Java best suits for client-server architecture.

eyazici
+2  A: 

Wrote some years ago bot for IRC using delphi. It is much better than interpreter languages - eats less memory, works much faster, and you can be sure that it will have great reserve of speed if you will need add more and more features in future - parsing users phrases, process them. For example my bot particularly logged all chat and performed quick search by user request (user just wrote !search word/phrase - bot performed search and sent to user results as short quotations, so user could select one of quotations and get more posts around it from log). It is almost unimplementable using for example php because it is too slow. If bot is proposed to work under *nix - just use c/c++ :)

If you want to use only languages enumerated in your post - then only Java to my mind. Read above why.

+4  A: 

Of the options you posted, I would have to suggest Java. PHP, for one, simply isn't going to do what you want it to; it's meant to be a web scripting language, not an anything-else scripting language. Python is capable of doing what you want, but I think Java will provide more out-of-the-box support for the functionality you're trying to achieve.

Adam Maras
+5  A: 

I would say Python with the Twisted framework. Twisted is amazing framework for asynchronous networking and most of the time it already has the support for the protocol you are looking for. There's a slight learning curve because of the reactor pattern but once overcome you can do amazing things with the littlest amount of code. As for the IRC protocol twisted already has it, so while I'm not an expert on IRC bots, I would definitely recommend Python and Twisted.

BTW, this is the first one that came up with google: Python IRC bot using Twisted

jedi
+4  A: 

Personally I'd start with the ejabberd codebase and work from there -- for a headless network server agent, Erlang would be the language/platform I'd reach for first, unless there were compelling arguments for another technology. Immutable data and actor-based concurrency pushes all the normal housekeeping code down into the platform, leaving you free to concentrate on the bits that are really what your app is about.

Steve Gilham
+1  A: 

Python Jabberbot

This is a fairly easy way to create a jabberbot with python.

David