Wednesday, March 12, 2008

Effusive Python Fan Love Pt 1 - Some Early Impressions

Just as Morgan Spurlock conducted an experiment where he put his health at risk by eating nothing but McDonald's food for 30 days, in 2005 I started an experiment where I put my career and sanity at risk by taking a job focusing on the use of Microsoft products. As part of that misadventure, I did some scripting with VBScript, a horribly malformed abortion that was at one point the scripting language of choice for ASP, the Microsoft Web Framework before ASP.NET MVC (way to go Microsoft, innovating by putting that MVC thing Xerox PARC came up with in 1978 in a product in 2008), before ASP.NET 3, ASP.NET 2, and ASP.NET aka 'the last web framework you'll ever need to learn'.

VBScript is such an abomination even Microsoft is now posting articles advising the faithful as to how to convert from it to Powershell, but a better option is to choose a proper scripting language, like Python.

Calling Python a 'scripting language' seems wrong, with the negative connotations of dabbling and sloppy (or malicious) code tied to 'scripting'. It's one of the approved languages within Google, who also hired the creator, Guido van Rossum (he works on it 1/2 time). Iceland's CCP games use a variant called Stackless Python well-suited to concurrent programming for their massively-multiplayer online game, Eve Online. It's also used in Civilization IV. So it's not something limited to sysadmin 10-minute throwaway scripts in any way, shape or form.

I learned Python a couple of times (and then went off and did something else, forgetting what I learned) before returning to it recently as part of the big Microsoft backlash (although Microsoft have hired the IronPython guy to work for them, and are wanting to have Python available as a development option for Silverlight Development via their DLR (dynamic language runtime). Until recently, Perl was the go-to scripting language, because writing code in Perl was like talking to the computer and asking it to do something. It was that effortless. It was, yes, fun! I decided to give Python a go in the ongoing interest of staving off senility and general brain rot.

This meshed well with my recent purchase of a MacBook, because Python 2.5.1 is already there. This site appears to be a good resource for Mac Python people, and the author recommends building from the source and going from there, something I may do in the future, but everything seems fine for my needs now.

Editing-wise, I played around with a few different editors before opting to go with Komodo Edit, from ActiveState and free. I have had fewer woes with improper indentation with Komodo Edit than with some other editors I've tried, and it has the nifty auto-completion. Eclipse has a plug-in called pydev, but Java skeeves me out more often than not.

As to fun out-of-the-box things I've noticed with Python, number one for instant gratification is the interactive interpreter. If you're unsure what a snippet of code will do, you just type python and are popped into an interpreter, which you can feed lines of code interactively and see what happens. It is part of the speedy development aspect of Python. Not only is the compile cycle gone, you get instant turn-around for little snippets or ideas.

Another nifty thing is easy_install. A killer feature of Perl is CPAN, a central repository for modules people have created, containing code they've written to solve problems lots of other people will likely need to solve, removing the need for wheel re-invention. While it's not quite at the level of CPAN, the Python Package Index is handy, and easy_install is great, because if for example you read an article about BeautifulSoup, the Python module to parse possibly poorly structured HTML (in other words, 99% of HTML occurring in the wild), you would type:

>easy_install BeautifulSoup

...and away you go.

So far I can report programming with Python IS fun, so apparently I don't hate programming after all, just programming involving the use of Microsoft products or overly cumbersome Java frameworks with xml configuration files from hell. Java pretty much evolved from 'cool new thing' to 'your father's Oldmobile' right before my eyes, and nowadaze so much Java development is outsourced/offshored/rightshored/whateverthefucktheycallitnow anyway I don't recommend it much for Americans, especially young Americans. At any rate I'd rather use a language as a means to an end rather than an end in itself, and Python fits that role nicely.

No comments: