Monday, May 14, 2007

First steps in Python

In my blog Python demystified I reflected on some thoughts about computer programming and the language in particular.

Ever since then I was aware and interested in this language. Remember I said:
Without any decent IDE (like Netbeans for Java) that allows for graphical programming and UI-design, I strongly doubt that Python will ever gain momentum.
Well, I found a decent IDE: ActiveState Komodo IDE.

Except for GUI it has everything, a decent IDE needs: Syntax highlighting, code completion and code folding, integration into version control (subversion), debugging and profiling.

So just as I was to change my attitude and general opinion on Python the snakes ugly head rose from the depth of my notebooks core:

(Briefly): Python allows for object oriented programming. Objects can be created and instanciated. When going out of scope they are subjected to the garbage collector for destruction. So far so good.

I tried on example program from a popular python book - it worked.

I tried to extend the program (for better understanding) - it crashed.

Well, it terminated with an exception.

Further investigation revealed:
Python stores class definition and object instances in a globally accessible list. When program flow exits the current scope, all objects within scope are subjected to garbage collection according to this global list (and in the exact order of appearance within it).

So there is the possibility that an instance "wol" may be destructed before the class definition "Person". Changing the object name to "wolf" brings it after the "Person" identifier in the globals list and thus there is an object still in memory and valid, where the class definition is destroyed. Any following destructor of the objects instance cannot be called. The code is not there any more.

Is it just me that I find these things on my first day with the language?

Other than that I am fascinated by this elegant and slim language. Worth a try.

Genuine Advantage, my eyeball!

I got this note today, that Microsoft tightens its grip on Windows Vista users. Not only will an invalid key disallow activation. An presumably invalid key will render Windows Vista practically useless.
The new Software Protection Platform, built into Windows Vista, makes the user experience noticeably different between a genuine version and non-genuine version of Windows Vista. When it detects a non-genuine version of Windows Vista installed on a PC, the Software Protection Platform will disable key features of Windows Vista, including the desktop, Start menu, and task bar. Windows Vista functionality will be restricted to the default Web browser for one-hour periods.
The practical implication is that your software will not run. Your browser will be available one hour, then the PC will shut down.

Well, you might say, serves you right for using pirated keys?

It turns out that Microsoft themselfs don't know which key is valid and which not. It also turns out that if you use a notebook and stay unconnected for a certain period of time, the "Genuine Advantage" will strike you and you have your one hour browser window.

I could understand that Microsoft will not update pirated versions of Windows. I hardly could understand that my product keys were not accepted online but telephone activation was accepted (I purchased 10 copies of Windows, Office and some Server CALs).

But I decline to see my advantage if MY PC shuts down on a business trip because Microsoft thinks, my product keys are pirated.