Friday, April 13, 2007

TV on a Cell Phone?!

I guess I first really noticed this while watching American Idol on my real TV. They were advertising that you could watch video clips on your cell phone. Lately I've seen and heard commercials for Verizon's VCast videos. They're talking about it like it's the greatest new technology on Earth. Hooray! You can take video with you! See what you can watch 48 hours in advance!

I find the whole thing ridiculous.

Not only are cell phone screens way too small to be useful as a streaming video player but is it really necessary to have video available to you at all times? Has our society gotten so dependent on not being bored that we have to have something entertaining every second of every day no matter where we are? We gotta have iPods in our ears at all time, cell phones that can surf, IM, and play videos, GameBoys and PSPs to play games, and Blackberrys so we can do business anytime anywhere. Ever wonder why, as a society, our attention spans are getting shorter and we seem to have much less patience?

I don't. We're training ourselves.

Tuesday, April 03, 2007

When is the last time you had fun programming?

Ask yourself that question. Be honest with the answer.

If your answer is something similar to, "It's been a long time since I had fun programming," you owe it to yourself to check out the Python programming language.

Even though I have my doubts about dynamically typed programming languages in general, I have to admit that learning to program in Python, and programming in Python, is just plain fun. It's easy to get started: Just download and install Python, and hop into the interactive interpreter. There's an excellent Python tutorial to help you get started, and even a free, high quality online book.

The Python interactive interpreter is a big part of what, for me, makes Python so much fun. It reminds me of programming BASIC on the Commodore 64 in the early 1980s. The Python interactive interpreter gives you that kind of instant gratification. (With suitable apologies to anyone under 30 years old, who probably has no idea what I'm talking about.)

For example, let's say you're starting to learn about Python lists. Instead of flipping back and forth between an editor and running your Python program to check the results, you can experiment with Python lists right in the interactive interpreter. Here's an example:

>>> mylist = ['one', 'two', 'three', 'four']
>>> print mylist
['one', 'two', 'three', 'four']
>>> mylist[1] = 'TWO!'
>>> print mylist
['one', 'TWO!', 'three', 'four']

This kind of experimentation in the interactive interpreter saves a lot of time. It's also a good way to learn how different functions behave in Python. Here's another example:

>>> myfile = file("hello.txt", "r")
>>> line = myfile.next()
>>> print line
hello world
>>> myfile.close()

You can even ask the interactive interpreter for help on objects and methods:

>>> help(file.close)
Help on method_descriptor:

close(...)
close() -> None or (perhaps) an integer. Close the file.

Sets data attribute .closed to True. A closed file cannot be used for
further I/O operations. close() may be called more than once without
error. Some kinds of file objects (for example, opened by popen())
may return an exit status upon closing.

The standard Python library is also quite comprehensive. You'll find support for just about anything you might need to do. For anything not built into Python by default, you can probably find a Python library that does what you need.

The community support for Python is impressive, too. If you have a question about Python, type your question into Google and you're likely to get a relevant result in your first search results page. You can also ask the friendly people at comp.lang.python on Usenet (though, admittedly, some of them are misguided and solidly in the "Python can do no wrong!" camp, or the "Why would you want to do that anyway?" camp -- you can identify and ignore them pretty easily, though).

In case you're worried or wondering, Python is plenty buzzword compliant. Dynamically typed, garbage collected, object oriented, etc. It's also very portable: You can run Python on your Java Virtual Machine (thanks to Jython) and on your .NET runtime (thanks to IronPython), as well as running the standard Python interpreter. Projects are well underway and making nice progress that enable you to compile Python to native code, as well.

If your corporate software development has you singing the blues, and you feel like bringing back some of that magic you used to feel when writing software, give Python a test drive. The worst that can happen is you waste a few hours, and the best that can happen is you'll discover a new, favorite programming language.