views:

1130

answers:

9

I want to have some work done on the Network front, pinging numerous computers on a LAN and retrieving data about the response time. Which would be the most useful and productive to work with: Perl or Python?

+6  A: 

Either one should work just fine. If you don't have experience with either, flip a coin. No language is inherently productive; languages allow people to be productive. Different people will benefit differently from different languages.

In general, though, when you know your specific task and need to choose a tool, look for the libraries that would make your life easy. For Perl, check out the Comprehensive Perl Archive Network. There are modules for just every networking thing you might need.

Python probably has very similar tools and libraries; I just don't know what they are.

brian d foy
+2  A: 

Hello, I know Perl better than Python, so my choice would fall on Perl. That said, I'd argue that on low level tasks (like pinging computers on a network and things like that) they are rather equivalent. Python may have a better object-oriented support but for scripting (that happens to be what you need) the power of Perl is quite obvious. The large pool of tested modules (some of them are even object oriented) that you find on CPAN usually can do everything you need and they can even scale well if you use them appropriately.

tunnuz
+11  A: 

Go with Perl.

You'll have access to a nice Ping object, Net::Ping and storing the results in a database is pretty easy.

Saiyine
+1 for mentioning Net::Ping. I've had great results with it.
Leon Timmermans
Agreed, Net::Ping is excellent - it gives you the freedom both to do standard ICMP ping as you'd expect, but also pinging via TCP/UDP, and checking that you can connect to a given port, and makes the whole thing dead easy.
David Precious
+20  A: 

I agree that it is pretty subjective which programming language you use - essentially I would rather get the job done as quickly and efficiently as possible which making it supportable - so that depends on your infrastructure...

Can I suggest that you look at Nagios rather than re-inventing the wheel yourself?

While Nagios might require a greater learning curve in terms of configuration, it will be worth it in the long run, and if you can't find a plugin to suit your requirements, then it is easy to write your own. Joel Spolsky has written an interesting article on this.

Mark
This is a good suggestion. This is a solved problem. Use nagios or cacti. If you have special requirements, both tools support use of a custom script for data collection; in which case you can use python or perl.
Ryan Cox
+1 Nagios. It can be easily customized and you aren't totally reinventing the wheel.
Jeff Bauer
Even though it's not always practical or a good idea, there is nothing like the learning experience of crafting your own.
Corey Goldberg
Paul - who sits next to me - says that nmap (http://en.wikipedia.org/wiki/Nmap) might be more suitable for your needs. And there is a perl nmap parser too: http://search.cpan.org/dist/Nmap-Parser/Parser.pm
Mark
A: 

I'd say that if you need something quick and dirty that's up and running by this afternoon, then perl is probably the better language.

However for developing solid application that's easy to maintain and extend and that you can build on over time, I'd go with python.

This is of course assuming you know both languages more or less equally well.

Perl can also easily programmed to be maintainable and extensible, not all the Perl code is line noise.
tunnuz
Perl's like C in that regard: yes, it's possible to write incredibly obtuse, difficult to digest, and write once programs in either language, but there are guidelines out there to avoid those pitfalls for each language. Perl's got more features, so it's got more pitfalls too. :)
Robert P
I know it's possible to write readable easy to maintain Perl, I've even met one guy who actually can do it (and far too many who think they can). I still hold the perl's main strength lies in writing quick programms and that it's a lot easier to write good maintainable code in python.
+1  A: 

Whichever you know better or are more comfortable using. They both can do the job and do it well, so it is your preference.

gpojd
+10  A: 

Well, I work in both Perl and Python, and my day job is supporting a network monitoring software. Most of the import points have already been covered, but I'll consolidate/reiterate here:

  1. Don't reinvent the wheel - there are dozens of network monitoring solutions that you can use to perform ping tests and analyze collected data. See for example

  2. If you insist on doing this yourself, this can be done in either Perl or Python - use the one you know best. If you're planning on parsing a lot of text, it will be easier to do this "quick and dirty" in Perl than it will be in Python. Both can do it, but Python requires an OOP approach and it just isn't as easy as Perl's inline regex syntax.

  3. Use libraries - many, many people have done this task before you so look around for a suitable lib like Net::Ping in Perl or the icmplib in Python or this ping.py code.

  4. Use threads or asynchronous pings - otherwise pinging is going to take forever for example see this recipe using threads to run pings simultaneously. This is particularly easy to do in Python using either approach, so this is one place Python will be easier to work with IMO than using Perl.

Jay
+1  A: 

Thanks a lot people. Would look into the options you guys mentioned and then will proceed.

+2  A: 

I don't know Python, so I can't comment on what it offers, and I agree with those who suggest Nagios or other existing systems.

However, if you decide to roll your own system with Perl, Consider using POE. POE is a cooperative multitasking and networking framework.

POE has a steep learning curve. But you will be repaid for you effort very quickly. POE will provide a solid foundation to build from. Much of the client code you will need is already available on CPAN.

daotoad