(followup III) Leopard Annoyances – Apache/PHP

Back in February 2008 I wrote about my unhappyness about Apples inability to build a usefull PHP for Leopard (OSX 10.5), which forced more or less everyone who would be using PHP on Leopard to use a 3rd party build. And as far as I remember this was also the case with Tiger.

Now finally after years of waiting Apple have finally decided to compile PHP with GD (graphics manipulation library), enabled.

GD Support => enabled
GD Version => bundled (2.0.34 compatible)
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.2.37
WBMP Support => enabled
XBM Support => enabled

One can say that Apple actually delivers, but why did it have to take years…..


Learning Python

I’ve been learning something new this week (which happens on a regular basic), but this time it was very official, I actually went to a training.

It was decided, that I had to learn Python, which is a [stag]programming language[/stag], and yet another of the scripting ones – we already have Perl, PHP, Ruby, and so forth, which meant that I actually was in some sort of pathetic way was looking forward to see what all this was about.

There is one thing which is annoying about Python, and it’s even worse that they have decided not to do something about it. They have not implemented a ‘switch’ statement, they have some obscure reason why;

It is too early to decide. I’d like to see at least one completed proposal for pre-computed values before deciding. In the mean time, Python is fine without a switch statement, and perhaps those who claim it would be a mistake to add one are right.

The whole thing is discussed here.

A switch statement is used to in a very simple way do a selection:

switch( variable )
   case 'a' : do something if variable is a
   case 'b' : do something if variable is b
   otherwise/else : do something if variable is neither a nor b
end switch

Instead they they have decided that ‘if’ is a lot better. The same as above just with ‘if’:

if variable == 'a' then
   do something if variable is a
else if variable == 'b' then
   do something if variable is b
   do something if variable is neither a nor b

Well it does not take long to see that using ‘if’ does work, but it will look like a mess, which is avoidable by using ‘switch’. Well until further notice there is no other option than to use ‘if’ – sadly enough.

But there are good things also, it have a tight integration to the OS, which means that the whole Std. C Library is there (more or less), and also lots of other things is available. On Linux for example there is integration to both KDE (QT) and Gnome (Gtk2), on OSX there is Coca, and Carbon, and an interface or ObjectiveC (PyObjC). The nice thing is that on OSX it’s available from Xcode (integrated development environment). I don’t know about Microsoft Windows, as I don’t have much interesting in dealing with Windows development these days (as I do this for fun).

Everything is an object, but due to the way namespace is dealt with, one end up doing strange things. For example, to use sqrt (square root), one would do;

import math
x = math.sqrt(9)

and not like in C/C++

#include <math.h>
x = sqrt(9)

Of cause there are ways to get around the namespace thing, but it’s slightly annoying.

But in general, it a usefull language, lots of things are using it; like Xen (hummm, yes). It’s easy to do prototyping in, and one could actually use it for application development, there are a enough libraries to make it possible. The designer tools on Linux can generate Python code, so nothing is stopping you from writing stuff in Python.

The best of luck….