lilman Posted July 22, 2007 Share Posted July 22, 2007 I want to learn how to develop bots. I am familiar with PHP, but I have heard to build a bot, you should use Perl. I was wondering if anyone could enlighten me a little more. Which do you think is better, does PHP limit the type of things your bot can do? Quote Link to comment Share on other sites More sharing options...
trq Posted July 22, 2007 Share Posted July 22, 2007 If you comfortable with php use it, there isn't really anything Perl can do that PHP can't. Quote Link to comment Share on other sites More sharing options...
neylitalo Posted July 23, 2007 Share Posted July 23, 2007 there isn't really anything Perl can do that PHP can't. I'm just going to hang around a while and wait for effigy to pop in. And on the perl vs. PHP argument - I'd say use perl. PHP is relatively inefficient, and the vast majority (all, possibly) of unix-like operating systems will have perl, but it's very likely that they won't have PHP. Perl is nearly a unix necessity. Quote Link to comment Share on other sites More sharing options...
effigy Posted July 23, 2007 Share Posted July 23, 2007 *pop* I don't know if PHP's PEAR has excellent tools like WWW::Mechanize to help you lay a powerful foundation. If you're going to do a lot of parsing and data manipulation, I personally would choose Perl. What exactly do you want this bot to do? P.S. For PHP vs. Perl, see this topic. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted July 23, 2007 Share Posted July 23, 2007 I would agree that perl is much better suited for bots. Ruby is also a nice language for writing bots. If you are writing an irc bot you can look at this one that I wrote a long time ago http://www.phpfreaks.com/forums/index.php/topic,123057.msg508186.html#msg508186. It is a really basic bot but it should give you a decent starting point. One thing that I have noticed is that the php bot is a lot harder on the server then my Ruby bot. Quote Link to comment Share on other sites More sharing options...
Azu Posted July 24, 2007 Share Posted July 24, 2007 I don't know if PHP's PEAR has excellent tools like WWW::Mechanize to help you lay a powerful foundation. Curl And you don't need PEAR for it. Quote Link to comment Share on other sites More sharing options...
effigy Posted July 24, 2007 Share Posted July 24, 2007 I don't know if PHP's PEAR has excellent tools like WWW::Mechanize to help you lay a powerful foundation. Curl And you don't need PEAR for it. I meant excellent. I haven't used CURL, but after skimming the docs the UI looks terrible and it still seems to fall short of what Mechanize is capable of; perhaps I'm missing something. Quote Link to comment Share on other sites More sharing options...
Azu Posted July 26, 2007 Share Posted July 26, 2007 UI? What UI? It's code. Quote Link to comment Share on other sites More sharing options...
effigy Posted July 27, 2007 Share Posted July 27, 2007 Or CI (Code Interface?) My point is, it isn't designed well and, as aforementioned, seems to lack capabilities. Quote Link to comment Share on other sites More sharing options...
Azu Posted July 30, 2007 Share Posted July 30, 2007 Okay, you win, PHP sucks. But I'm still going to keep using it because I think it rules. Quote Link to comment Share on other sites More sharing options...
neylitalo Posted July 31, 2007 Share Posted July 31, 2007 Okay, you win, PHP sucks. After you use it long enough, and after you experience perl, python, and other scripting languages, you'll slowly come to the realization that PHP is, indeed, inferior from a technical standpoint. (I suppose that, too, is subjective, but I haven't heard a single knowledgable person say that PHP is better than perl or python.) Quote Link to comment Share on other sites More sharing options...
Azu Posted July 31, 2007 Share Posted July 31, 2007 Well PHP can do pretty much everything that is needed for running most websites, and it's fast to code in since it already has most of the functions you'll need built in. Wouldn't it take longer to make the same site in say python or perl? Quote Link to comment Share on other sites More sharing options...
neylitalo Posted August 1, 2007 Share Posted August 1, 2007 Wouldn't it take longer to make the same site in say python or perl? You're right, there are some parts of PHP that have advantages over perl, and the same functionality in PHP and perl would probably be much easier to write in PHP. (And I've never actually heard of python being used for web sites, but it's definitely possible.) For example, PHP has database connection support built into it, but with perl, you need to use an external module. And I suppose I ought to say what I should have said a long time ago - I'm referring to their proficiency from a scripting point of view, not necessarily web sites. When I write any script, I use these languages, in this order: bash, python, perl. I never use PHP, and I use bash and python before perl for the simple reason that I'm more familiar with them. PHP is very clunky and inefficient for regular scripts. I imagine this could have saved a lot of discussion if I'd said it in the first place, but I suppose someone may have learned from it, so it's not all bad. Quote Link to comment Share on other sites More sharing options...
effigy Posted August 1, 2007 Share Posted August 1, 2007 How does python compare to these? Quote Link to comment Share on other sites More sharing options...
neylitalo Posted August 1, 2007 Share Posted August 1, 2007 Python is... interesting. In most languages, whitespace is trivial, nothing to be worried about. Sure, proper indentation is nice, but it's not required. NOT the case in python. Indentation is a crucial part of python syntax, and how it knows where a particular loop, method, class, etc., starts and ends. For example: #!/usr/bin/python class Person: def __init__(self): self.firstname = "" self.lastname = "" def set_firstname(self, value): self.firstname = value def set_lastname(self, value): self.lastname = value def main(): person = Person() person.set_firstname("John") person.set_lastname("Doe") That's very rudimentary, but you get the idea. Once you un-indent, you leave the current construct. Another quirk is that methods in a class always take a reference to the owning object as the first argument, but the reference is not passed in the actual method call. One thing that I really like about python (but takes some getting used to) is the ease with which you can read code. It's written very naturally, with relatively few non-alphanumeric symbols. For example, to write a basic condition: some_bool = True if some_bool: print "The variable some_bool is not false." if not some_bool: print "The variable some_bool is false." Note the complete absence of parentheses around the condition, and you simply write "if not" instead of "if !some_bool". Regarding efficiency: I haven't run any tests, but for all practical purposes, python and perl are very comparable when you use them for scripting. When you bind python to GTK or Qt, however, it starts to slow down - but that's to be expected, with an interpreted language. One little thing that I imagine helps in the efficiency arena is that when you first run a python script, it compiles it to a binary, and as long as you don't change the script, it transparently uses the byte-compiled binary every time after that. (Every time you run the script, it compares the file's mtime to a value stored in the binary, and updates it if it's required.) Regarding functionality: Just as there are hundreds of modules written for extended functionality in perl, there are hundreds of packages that provide bindings for python. PyGTK allows you to create GTK apps with python, dbus-python allows you to send and monitor dbus signals, and so on and so forth. I'm sure there are more written for perl, but I have yet to encounter a situation in python that I haven't been able to find a pre-written solution. And regarding objects in python: I think its OO support is excellent, although, as with perl, I haven't really tried anything too tricky. Quote Link to comment Share on other sites More sharing options...
Azu Posted August 3, 2007 Share Posted August 3, 2007 I thought bash meant like a command prompt? How do you write a program in that? And thanks for the clarification about python/perl ^^ Quote Link to comment Share on other sites More sharing options...
effigy Posted August 3, 2007 Share Posted August 3, 2007 I thought bash meant like a command prompt? How do you write a program in that? Bash is an interactive shell (command prompt), as well as a scripting language. Quote Link to comment Share on other sites More sharing options...
neylitalo Posted August 3, 2007 Share Posted August 3, 2007 For example, the traditional "Hello, world!" program, written in bash. (With a few added features, just for fun) #!/bin/bash if [[ -n $1 ]] ; then times=$1 else times=3 fi i=0 while [ "$i" -lt "$times" ] ; do echo "Hello, world!\n" i=$((${i} + 1)) done return 0 In bash, 0 is the value returned when a script has executed successfully. Edit: Holy infinite loop, Batman! Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted August 3, 2007 Share Posted August 3, 2007 And I've never actually heard of python being used for web sites, but it's definitely possible. I'm quite sure that I've seen a page on Google ending with .py somewhere... Quote Link to comment Share on other sites More sharing options...
neel_basu Posted August 6, 2007 Share Posted August 6, 2007 And I've never actually heard of python being used for web sites, but it's definitely possible. I'm quite sure that I've seen a page on Google ending with .py somewhere... Google uses both PHP and Python you will see it analytics answers.py Quote Link to comment Share on other sites More sharing options...
Azu Posted August 7, 2007 Share Posted August 7, 2007 Which is faster for websites? PHP or Python? Quote Link to comment Share on other sites More sharing options...
neel_basu Posted August 7, 2007 Share Posted August 7, 2007 Which is faster for websites? PHP or Python? Both of them are Interpreted language. I've never used Python . What I can say is PHP is Much Much more faster than perl and thats the main cause for which so many developers switched to PHP from perl. in case of CLI programms there is not any big difference of speed in any language. although I've hard that python is also fast like PHP . VNC itself is actually made by perl and its GUI by Java (in Linux). But why dont you use C++ ?? C++ TCP sockets are easy and reliable. Quote Link to comment Share on other sites More sharing options...
effigy Posted August 7, 2007 Share Posted August 7, 2007 What I can say is PHP is Much Much more faster than perl and thats the main cause for which so many developers switched to PHP from perl. Really? I think there are many other reasons. Quote Link to comment Share on other sites More sharing options...
Azu Posted August 7, 2007 Share Posted August 7, 2007 Which is faster for websites? PHP or Python?But why dont you use C++ ?? C++ TCP sockets are easy and reliable. I think that it would take a long time to learn all of the C++ that I will need for my web applications, and that it would take a lot longer to write the code for them in C++.. Quote Link to comment Share on other sites More sharing options...
trq Posted August 7, 2007 Share Posted August 7, 2007 in case of CLI programms there is not any big difference of speed in any language. Actually, PHP is very slow when compared to other cli tools, Bash, Perl, Python and Ruby. And just to let you all know, there are probably more web sites written in Python than you realise. it actually has very good support (modules / frameworks) for web developement. Just take a look at mod_python, Internet proticols & support, zope and django. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.