July 22, 2007

Python Further Embedded in the Animation Industry

Python's inexorable march towards world domination* continues with the recent announcement that visual effects provider The Foundry plans to incorporate a Python programming interface into the next version of its Furnace product. The UK broadcast industry news article that brought this to my attention also (correctly) says Python is
an extensible programming language, which is becoming widely supported by other application vendors and forming the backbone of many studios pipelines
It seems that Python's origins in "computer programming for everybody" has allowed it to become a default choice for embedded scripting capabilities in many areas. It is fast becoming the standard in the film industry. It would be nice, now the secret is out, to see that industry contributing a bit more to the development of the language and its community.

* Just in case you wondered, there are no such plans!

July 18, 2007

Obscurantism

I may have mentioned before that I have started to use the C# language. Overall it isn't bad - it uses static typing, which I have always found irksome, but the language is reasinably expressive and compact compared with something like Java or C++. Because it is heavily promoted by Microsoft there are any number of tutorial and example web sites, not all of them by programming experts.

Somehow the Java message that it's bad to allow direct access to instance and class attributes appears to have permeated the C# world, I have no idea why. I have just been reading one of the better-written tutorials, which offers the following code as an example if instance creation and manipulation.
static void Main(string[] args)
{
Person Michael = new Person();
Person Mary = new Person();
// Specify some values for the instance variables
Michael.Age = 20;
Michael.HairColor = "Brown";
Mary.Age = 25;
Mary.HairColor = "Black";
// print the console's screen some of the variable's values
Console.WriteLine("Michael's age = {0}, and Mary's age = {1}",
Michael.Age, Mary.Age);
Console.ReadLine();
}
As code goes that isn't bad, and apart from the different comment styles and the declarations it could almost be Python. Unfortnately the author has tasted the Java Kool-Aid, and shortly after this example writes
So each object now contains different data. Note that we directly accessed the variables and we put any values we wanted, right? But wait there is a solution to this problem. We will use properties.

There is no attempt to explain what the "problem" is, and you will probably not be surprised to learn that the "solution" involves making the attributes private to the class and then providing public getter and setter methods for instance users. This turns a five-line class declaration into a 32-line one (though to be fair to the author, he does at least include checking code that demonstrates the value of properties in applying class-based logic during assignment).

I have now read any number of texts where instead of something like
class Person
{
public int Age;
public string HairColor;
}
that allows direct access to the instance variables by client code, readers are encouraged to write horrendous code like
class Person
{
private int age;
private string hairColor;
public int Age
{
get
{
return age;
}
set
{
age = value;
}
}
public string HairColor
{
get
{
return hairColor;
}
set
{
hairColor = value;
}
}
}
which actually offers no benefit over the short version at all. Python users are used to accessing attributes directly in their code, which clearly has performance benefits, and then implementing properties if and when they are required to add logic to the setting or retrieval of attribute values. I just wish that C# users could see that empty getters and setters offer no measurable benefit over direct access to attributes.

July 17, 2007

Misunderstandings

Here's a quote from an article about agile programming which is otherwise quite well-informed:
But because of their simplicity, languages such as Python and Ruby are better-suited to writing small applications.
This is the kind of myth that really needs to be squashed at the source. Unfortunately the source in this case is a journalist who has written an article and moved on with her misunderstanding of the issues and the facts completely untouched.

It's difficult to know how to attack this problem, because even the Python Software Foundation's advocacy coordinator were to contact the journalist in question and correct the mis-impression the damage is already done, and another opportunity to gain the wrong idea about dynamic languages is out there to be used as "evidence" by those looking to press the advantage of some other technique. It must have annoyed David Goodger (one of the Foundation's directors) to be quoted shortly after that misstatement.

In this particular case the author of the article did manage to get a lot right - technologies should come second to business needs, agile methods can save money by delivering business value faster and avoiding large amount of rework, and so on. So the content wasn't all bad, but the misunderstanding of Python's suitability for large projects spoiled it for me.

But then, I (and, I presume, most of thios blog's readers) already know that Python can be used successfully to build very large systems indeed.

July 4, 2007

Developers Migrating Away from Windows

In a research report from Evans Data Corporation we learn that last year's decline in the targeting of Windows as a primary development platform has been repeated. John Andrews of Evans says "it's clear that a shift away Windows began about two years ago, and the data show that this migration is now accelerating. Linux has benefited, but we also see corresponding growth in niche operating systems for non-traditional client devices. The landscape is changing."

If I were a Microsoft shareholder I might be happier if I could see Microsoft engaging more aggressively with the open source community. It's difficult to steer something with the inertia of a large organization like Microsoft, though, so perhaps they are changing course as fast as is practical. Ultimately even Microsoft will have to realize that they can't do everything by themselves, and specifically that they can't dictate standards (e.g. WSDL) to the rest of the world.

Python Magazine Coming Soon

As Brian Jones has just announced, there will be a new Python magazine (imaginatively entitled Python Magazine) out before the end of the year.

It's encouraging that the publishing world is taking Python seriously enough to produce magazines . There's already the online PyZine and the more academically-inclined Python Papers, and I may have missed some.

This will tend to encourage further interest in Python, which I feel is kind of on the brink of mainstream significance. After a mere 17 or 18 years in development Python is about mature enough to become widely adopted - it took UNIX about the same length of time to appear as a commercial operating system.

If you have any ideas about what you'd like to see in Python Magazine, or if you're interested in writing for it, they would be happy to hear from you! I have agreed to provide a regular column, and so I have to get back to putting four months' material together.