Which programming language should I learn?
March 2, 2008 1:57 PM   Subscribe

Which progamming language for email management and filtering, and to experiment with cryptography?

I want to be able to create intelligent email filters (for example, a system that pulls in emails and parses the contents) and other sorting/decoding algorithms and store results in a database.

I don't know much beyond html and a little css, and I'm willing to learn a programming language to do it (although something less rather than more complicated would be great). I run linux as standard, and would prefer something platform-independent or server/internet-based.

Is MySQL best? Ruby on Rails? Perl? or something else entirely.

posted by sparklejess to Health & Fitness (17 answers total) 6 users marked this as a favorite
MySQL = database server
Ruby on Rails is a web framwork.. Ruby might be fine though..
Perl would probably also work.
I think that python would also work..

Most of the more popular languages would work (eg Ruby, Perl, Python, C, C++)

Good luck!
posted by majikstreet at 2:12 PM on March 2, 2008

Python's built-in email package is well-developed. I would advise against starting off with C or C++. You will find it frustrating and it is unnecessary for what you want to do.
posted by grouse at 2:19 PM on March 2, 2008

look into the procmail package; it's built to do what you are looking for.
posted by jenkinsEar at 2:58 PM on March 2, 2008

I'd lean towards Perl because processing text is What It Does, and there are libraries available to do pretty much everything (which takes care of a large part of the crypto).

They'll do your head in at first, but the swiss-army chainsaw of text processing is the regular expression. As soon as you've got program flow (if/else, for/next) nailed, you'll be moving on to regexes. Pretty much any scripting language will have a regular expression library, but Perl's the granddaddy in this regard. It doesn't have quite the geek cred that some of the more fashionable alternatives have, though.
posted by Leon at 3:10 PM on March 2, 2008

I'd start with procmail as jenkinsEar suggests. It will do all the basic stuff itself, and will also allow you to pass messages through shell/perl/python/whatever scripts for more advanced things.
posted by markr at 3:13 PM on March 2, 2008

I'm going to counter-recommend procmail, as kind of an expert in it; it's powerful but cryptic and whatever skills you develop aren't transferable to anything else. And having run database-backed Web sites for 15 years I strongly recommend Postgres over MySQL.

The Ruby e-mail processing libraries are, last I heard, kind of a mess, whereas Perl has been used for mail munging for many years and has many very robust libraries. (The people with whom Perl has no cred only think they're geeks.)
posted by nicwolff at 3:41 PM on March 2, 2008

Alice and Bob recommend Perl.
posted by crustix at 4:18 PM on March 2, 2008 [3 favorites]

If what you want to do is *write programs to process mail*, your choice will be made for you by and large, as several people have noted, by *which languages already have the best implemented library for handling mail*.
posted by baylink at 5:13 PM on March 2, 2008

Best answer: I know python can do everything you want to do, as I have done exactly what you describe. Here are a bunch of beginners, non-programmers, guides to python. I have looked through this version of how to think like a computer scientist and nodded approvingly. YMMV.

Python is completely free, to download and set up but it might require some frustrating noodling to get to work.

To do what you are hinting at you will likely need to use the "email" library. There are database libraries you will need to use as well to save your results. By the time you have "hello world" up and running you might be able to ask another question.
posted by shothotbot at 6:12 PM on March 2, 2008

I can't contribute anything more to this question that hasn't already been said. But I have to wonder why this question was placed in health?
posted by coreb at 6:15 PM on March 2, 2008

Python or Ruby for fiddling with email filters.

If you actually want to write your own cryptographic routines, then go with C. Seriously: Low-level hacking is not the strong point of any of the popular high level languages. Python, Ruby et. al are slow, and they do things that are annoying if you're trying to write numeric algorithms (for example, automatically promoting 32-bit integers to arbitrary precision if they exceed the size limit).
posted by qxntpqbbbqxl at 6:44 PM on March 2, 2008

Actually, Python doesn't automatically promote from its short int type (machine integer) to its long int type (bignum). Python's nice for public-key crypto because it has native bignum support. For the kinds of algorithms usually used for symmetric crypto, none of the scripting languages are very good since the algorithms rely on lots of bit twiddling, but they're all tolerable.

I'd suggest either perl or python, according to your proclivities. Read up on both and see which one strikes your fancy.
posted by hattifattener at 9:00 PM on March 2, 2008

Python doesn't automatically promote from its short int type (machine integer) to its long int type (bignum).

Yes it does:
$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) 
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxint
>>> sys.maxint+1
But if you want to do serious number-crunching in Python, you probably want to use NumPy anyway, which won't.
posted by grouse at 11:51 PM on March 2, 2008

ezpyCrypto is an awesome encryption library for python too. Boils down all encryption and decryption to one simple class.
posted by Mach5 at 5:46 AM on March 3, 2008

Huh. You're right. I could have sworn I've seen integer rollover in python, but perhaps I'm just imagining things.
posted by hattifattener at 9:22 AM on March 3, 2008

Sure, seven years ago in Python 2.1.
posted by grouse at 9:25 AM on March 3, 2008

Response by poster: Thankyou so much to everyone for their comments. It looks like I'm going to spend a week playing with python, then a week with perl and see what works best for me.

As for me putting it in 'health', I must have accidentally switched it in the preview because I'm sure I got it right first time.

Thanks again.

posted by sparklejess at 1:45 PM on March 3, 2008

« Older Where does KDE 3.5.5 keep it's global icons?   |   Nom nom nom woof Newer »
This thread is closed to new comments.