GNOME Platform Stormclouds
Posted Mar 25, 2004 16:38 UTC (Thu) by mly
Parent article: GNOME Platform Stormclouds
I'm not involved in GNOME development, and I certainly feel that
those who are must solve this in a way that they are happy with.
I'm sure there are a number of Python programmers involved in GNOME
who understand much more about the pros and cons of using Python in
that particular context better than I do, maybe it's obvious that it
can't be used, but I'm really surprised to find the lack of static
typing to be an argument against Python. Sure, I misspell things in
Python and get name errors, but they typically surface quicker than
they would in C, and I mistype less in Python since I type less in
It obviously depends on what kind of code I'm writing, and in what
stage of development I'm in, but I think that I generally have an
edit - test cycle in Python which is much shorter than my edit -
compile cycle in C, and much, much shorter than the edit - compile -
link - test cycle in C. The reason for this is that you typically
have to write five or ten times more in C than in Python to achieve
the same result. Testing as often in C as I do in Python would be
impossible, particularly in a large system: I've been involved in
C++ projects where an application took an hour to build... In Python,
this is not an issue at all.
In general I think Guido van Rossum has been very successful in
creating a language which is helpful to the programmer in a
positive way, making it easy to do things right, rather than
trying to make it hard to do bad things. In C, you must often
do potentially dangerous things such as playing with pointers and
type casting, because the safer way of working is too limited.
There are also a number of well known gotchas in C syntax that have
been solved in Python, e.g. "if x = 0" is a SyntaxError in Python.
You may be wondering why languages such as Python, Perl or Ruby aren't in consideration here. Havoc's paper doesn't do much to explain why languages such as these won't be used for writing system components, because the audience that he wrote it for probably take that as a given.
Might this possibly be a mistake?
Dave Camp's one-liner in this blog post probably explains the thoughs of most developers on this issue: I have a soft spot in my heart for Python (although I have a softer spot for static type checking).
I think this is mainly a matter of getting used to another way of programming. This might be a hurdle in itself, but it's maybe more a learning issue than a technical issue. Besides, there are tools such
as PyChecker and
that can take the role of the compiler. It's my impression after
many years of using both C and Python that Python programs
typically contain much fewer bugs than C programs, and that it's
far easier to find and correct them.
Automated testing can address some of these issues, but a certain type of C programmer might have trouble sleeping at night after shipping a large Python application, with the expectation of receiving bug reports containing NameErrors.
I think most programmers sleep even worse when they have shipped
C applications, with the expectation of receiving bug reports
containing core dumps--and maybe even worse: security holes due to
buffer overflows etc. There aren't a lot of reliable studies on
the subject, but I've never seen any study suggesting that C
programs contain less bugs than Python programs. I've seen some
that suggest the opposite. The problem with Python is not that
Python programs are so buggy. Not at all.
Python certainly doesn't fit in all situations, but for a system like
GNOME, I think the reliance on an external interpreter and the
inability to build native machine code executables seem like small
problems. Making source code or easilly decompiled byte code
available to end users doesn't seem to be a problem in GNOME either.
Considering the wide use of Python in the Linux community, and how
easy it is to learn, I don't think that lack of skilled python
programmers or lack of "support" are issues either.
The only non-religious problem I see with adapting something like
Python for GNOME is performance. If Moore's law and novelties such
as pyrex and psyco doesn't fix this, Python has always been able to cooperate nicely with C++ and C... That should also be helpful in a transition period. But I guess it's still possible that performance
issues in Python would be a real problem for GNOME. I appreciate that
performance is a big issue in GNOME.
Of course, if we'd switch from C to Python to get rid of C's problems with memory management etc, and end up writing parts in C anyway for performance reasons, you might feel that little is gained, but typically, the bottlenecks in programs are small. Instead of 10000 lines of C code for a particular program, you might end up with 2000 lines of Python and 500 lines of C. It's much easier to maintain 2500 lines than 10000, and all the risks of C, with memory leaks etc are roughly reduced by 95% if
there is 95% less C code.
Perhaps a two language solution with Python and C is the easiest way
to go forward from where GNOME stands today?
Maybe Java has improved a lot since I last looked at it, but it certainly used to be a major resource hog, and Java applications that I run regularly in Windows, such as IBM's DB2 ControlCenter are so slow and memory hungry that they are almost useless.
My experience is that Python programs are significantly shorter
than Java programs, and much shorter than C programs, and at the
same time clearer and easier to understand. A large part of the
code that I would write myself in C, is already written by someone
smarter in well tested C if I use Python. In a way, writing Python
can be seen as a very clever way of reusing well written and tested
C code. (After all, the classic Python implementation was started
almost 15 years ago, and it's certainly not been allowed to rot.)
Somehow...I have problems envisioning something that Microsoft came up with as a solution for GNOME... I'm really ignorant on the issue, but
I somehow suspect that C# for Linux might backfire in a nasty way. I'd
just wait for some Microsoft C# patent to emerge as GNOME had turned
into a real Windows contender. Of all aspects of Linux, it's the rise
of a more polished desktop "experience" that is most likely to have
an impact on Windows users. I'm sure MS would do everything in their
power to stop Windows from being replaced by GNOME/Linux as the leading
desktop OS, and Bill Gates have explained publically that he'll use the
legal system to go after Linux if he can, and he's doing it right now
by funding Caldera/SCO. Don't think it'll stop there. No, I don't think Mono will make the programmer sleep any better. :(
If you really think you need static typing and memory management,
you should perhaps look at Eiffel or OCaml? Although I guess OCaml's
inferred typing won't stop you from mistyping a variable name...
to post comments)