Skip to content

2004

Moronic 12 line .sigs are evil

Particularly on a mailing list. Indulge me in this analogy:

Picture someone coming into your home one day, armed with a megaphone. They walk up to you and start to read out their signature, speaking through the megaphone. Annoying huh? Now picture them leaving and heading to the house of one of your colleagues and repeating the process.

Hang on, isn't that the same thing as "direct mail" (aka: spam)?

Now, you might forgive someone for doing this once (maybe they are a newbie), but when they next have something to say, and do it again, it's really really annoying.

Nettiquette suggests that you should not use more than 4 lines for your signature. I agree, but (after a few years experience) I would even go further; you don't need a signature at all, except perhaps during an initial round of communication with a new client. Why? Once they know who you are, shouting your name and other junk at them isn't interesting.

If you really need to advertise which company you're working for on an open source mailing list, set the Organization: header in your MUA so that it includes that information in the meta data. There is no need for any other information. If someone wants to know more, they will email you and ask.

If you have a .sig, please please please get rid of it, at least when you post to mailing lists.

GOTO isn't evil

In reference to Sara's patch to implement GOTO in PHP:

It saddens me that people are so easily brainwashed by their teachers/peers. Sure, from a high level perspective you don't need a GOTO statement, and the argument that it, when misued, can lead to unreadable code is a good one.

However, I feel that the inverse argument can also be true: complex code with lots of nested if statements and control loops can be also be hard to follow when you need to "get out of jail" fast. Without goto you often need to resort to tricks (in C) such as "do { ... break; ... while (0)", or if you have nested switch's inside loops, create a flag variable and take several steps out of each nesting level. There is no way in hell you can convince anyone of sound mind that those tricks make the control flow easier to understand than a GOTO.

No doubt the anti-goto brigade will campaign that the code could be split up into different functions etc. etc. etc., but it is quite often the case that real programmers need to have this stuff in one function; just take a look at kernel code written in C, for example.

Arguments against GOTO on the following grounds are, IMO, just a bit short-sighted:

  • I think GOTO is bad because some guy wrote a paper on it
  • I was taught not to use it. (But don't know why; it's supposed to be bad, or something).
  • I was taught not to use it because you can use something else.
  • You can use exceptions instead; who cares about performance

Regardless of who wrote the paper, or what you were taught, or your disregard for performance (which does have a big impact in the real world; Exceptions are expensive), GOTO is sometimes needed to get the most out of your code. I'll even go so far as to say that most of the people making these anti-goto comments have no practical experience either of using goto, or with dealing with someone elses misuse of goto; if you don't have experience, please shut the hell up :-)

GOTO is one of those tools that you don't always need, and one where it is hard to define precisely when you should use it (<insert anecdote about professor who determined only one extremely rare case you can't handle without goto>). It boils down to what is appropriate for the task (and language) at hand.

Use your brain and evaluate the project--don't just blindly follow what others have said in the past; make up your own mind. If you truly believe that a goto makes a certain section of code more readable, go ahead and use it. If you deduce from benchmarks that exceptions, nested loops with flag variables or whatever are too slow or otherwise too expensive, you have have a perfectly valid reason to use a goto instead.

I'll sum up with a "GOTO doesn't kill code, bad programmers do". Just because misuse of GOTO can be harmful, it doesn't mean that it shouldn't be part of your toolbox, and for that reason I would welcome a GOTO statement in PHP.

More on PDO

Just published today on the Oracle Technology Network is my article on PDO, giving an overview of what it is, installation, sample code, portability and so on.

Although it has a focus on Oracle, pretty much everything covered there should be portable to the other available pdo drivers with minimal changes (essentially just the parameters to your connection), if you are writing portable SQL.

Please do read it, even if you're only mildly curious, as the stipend I earned from writing the article effectively paid for some of my time working on PDO. As it was actually written a few weeks back (OTN has a long publishing process), the "Future of" section is missing details of the iterator (eg: foreach) support that Marcus keeps nagging me to merge in.

PHPScript

PHPScript is PHP's own ActiveScript interface. In practical terms, this means that you can use PHP from within any application that can host ActiveScript engines. The list of known hosts includes, and is not limited to:

  • Windows Scripting Host (WSH), cscript.exe/wscript.exe
  • "Classic" Active Server Pages
  • Microsoft Scripting Control, and by extension any application that loads that control
  • psvActiveScript Control for Delphi applications
  • Weaverslave an IDE
  • Kapsules a desktop widget engine

Installation

  • Download and install PHP 5
  • Download PHPScript and put it in your c:\\php5 directory
  • run regsvr32 c:\\php5\\php5activescript.dll

Usage

Windows Script Host

Create a .wsf file like this:

   <job id="test">
       <script language="PHPScript">
           $WScript->Echo("Hello");
       </script>
   </job>

or invoke your .php script directly from cscript.exe or wscript.exe using the //E:PHPScript option.

ASP (untested)

    <%@language=PHPScript %>
    <%$Response->Write("Hello"); %>

Script Controls

Set the language property to PHPScript

Script Components / IE

note: it is very dangerous to deploy PHPScript inside IE

Simply use <script language="PHPScript"> for your script tags.

Developers Notes

If you are developing code to run under PHPScript, you need to keep in mind the following differences from regular PHP:

  • echo doesn't have any practical effect. You need to call methods of the host to output information. You may still use output buffering etc., it just won't go anywhere if you flush it.

  • global objects added by the host are created as super-globals, so you need not reference them using the "global" statement.

  • PHPScript will not search for a default php.ini file. It will look instead for php-activescript.ini inside the folder of the .exe process that launched it.

ActivePHP

People seem to have only just noticed this thing, but it's been around for ages (2 years!). Yeah, it's probably broken in PHP 5 in a bunch of places. It's experimental, YMMV. Yes, I care if it doesn't work for you; maybe not enough to use up my spare time (not that I actually have any) debugging windows problems, but everyone understands that you get what you pay for, right?

Wrong

Our brief conversation took place the day before his somewhat "unfriendly" posts. I received 2 emails, not 6.

Andrew:

OpenSource is about contributing, so why not contribute something useful to the rest of the world instead of angry vibes and misrepresenting the people that have already donated so much of their time?

If you want to help yourself, take a look at the CVS and compare PHP 4 with PHP 5. It sounds like there is a buglet in the registry entries; it did work under PHP 4 with WSH, so why not start by comparing those parts?

PS: threaded PHP is a bad idea waiting to crash. That's one of the reasons why we strongly recommend that you don't use threaded SAPI under windows (and even under unix if you can avoid it).

Electric Sheep

It's gotta be the coolest screensaver ever, electric sheep is a continually evolving flame fractal animated screen saver, where your idle cpu cycles are used as part of a distributed computing network to render frames towards the next phase in the evolution (known as sheep).

The name is a little strange, but if you consider idle cpu cycles as dreams, and consider the novel "Do Andriods Dream of Electric Sheep", you'll get the idea. (If you're more into movies than books, "Blade Runner" is for you).

It is a little slow to pick up the first "sheep", but that appears to be a bandwidth problem on their central server. Perhaps they should also distribute the sheep downloads among mirrors, or even peers (Bit Torrent style)?

Anyway, the coolest thing about this screen saver is that is subtly changing the whole time; I have it running on a spare computer next to me and its fascinating.

Bouncing around the USA (again)

A couple of years back, we attended the wedding of my sister-in-law (Aimee Macauley) in Hawaii. We decided to extend our stay and were treated to a big cock-up on behalf of United Airlines that involved flying from Hawaii->SFO->Boston->NY->NY->LHR, instead of the somewhat more sane Hawaii->SFO->LHR.

Well, I've just been visting George (for business, and as it turns out, pleasure too) and my "travel-luck" (those are Dr. Evil finger-quotation-marks) strikes again. The flight from BWI to Boston was delayed enough by some weather (presumably the same lightning storms that delayed my inbound flight a couple of days earlier) to mess up my connecting flight back to LHR (you know; the important one).

This time I'm flying American Airlines and I have to commend them for much nicer service than United. I'm currently sitting in Chicago O'Hare waiting for my alternate flight to LHR. My arrival time has been delayed approx 5 hours, but it turns out that this actually a better schedule for both myself and Juliette+Xander; I get more time to "sleep" on the plane (Dr. Evil finger-quotes again), and they don't have to get up at 4am to collect me from the airport.

Back from LinuxTag

After a surprisingly long day of travel (each leg of the journey isn't that long, but the whole is greater than the sum of its parts), I'm back home in England.

I did't take any photos this year, but if you're curious, Tobias has rounded up a whole bunch.

I'd like to thank ThinkPHP for sponsoring my journey and stay at LinuxTag again this year; the critical mass of PHP brains at a conference usually results in something new for PHP, and it is good that ThinkPHP recognize and help this to happen.

So what's coming out of LinuxTag? We had a database meeting again this year; last year it spawned PDO, and this year we (most of the major PHP database extension maintainers) sat down and refined some aspects of it. Other cool stuff is hinted at here, and will be very useful if used wisely.