Database List


By PHP I mean, of course, the language. (I’m using v4.1.2, but that’s not the point).

By RAD, I mean Rapid Application Development – and not in the way VB seems to have co-opted the concept and promise. Getting something up and running.

Yesterday – don’t ask why – I had the need to have a type of tool that I had used (helped build) in ColdFusion at another job. Basically, a Web interface to a given application’s database, with a view of the database/table schema.

This ColdFusion tool – against a MS SQL Server – had a couple other bells and whistles, including the ability to set comments for a given table (“This stores all user info….”) or column (“article_id is a unique key for each article entered in the system…”).


I needed both more and less.

I didn’t need the comments, but I did need the ability to see – via a Web browser – the following:

  • A list of all databases for a given mySQL database server
  • For each of those databases, the tables said database
  • For each table, the schema (column name, type, nullable, default) for each

Now, there are tools out there (like PHPmyAdmin) that can do whole browser-based DB management, but I didn’t need that much.

I just needed what I listed above: Database, drill to tables and schema. Very simple.

And – as it turns out – it was relatively simple. Yes, took some work to get it somewhat organized, but really not that big a deal.

Highly functional (read-only, as desired), totally self-contained in one file, and compact (less than 200 lines).

Cool. And this includes a little (very little, but some) error-trapping, comments, CSS style and so on. I think this is a very simple code file to follow and modify as desired. Do so.

Here’s an example screenshot – notice the following functionalites:

  • Echos host name (set in file as an ini param)
  • Database selection – defaults (first hit) to first database on server (alpha); an onChange event refreshes the page upon new database selection; maintains state of selected DB
  • The Change DB button is there so a user can keep hitting this button to see any changes to the currently selected database (like a Window F5 keystroke)
  • Selection of a database will reload page with full detail of all tables in said database. Could do differently, to allow drill to tables and then drill to table detail. Coder choice
  • Not pictured: If the selected DB has no tables, only an error message will display, not a non-app error message or other nonsense. Fails gracefully.

And here’s the code; it works for mySQL 3.2.3 on both Linux and Windows (all you have to do is change the host/username/password params).

Database List

// Server defaults

$host = [host name];

$username = [user name];

$password = [password];

// open database connection

$chandle = @mysql_connect($host, $username, $password) or die("could not connect to server");

// Get list of databases; run everytime

$db_list_sql = "SHOW databases";

$db_list_results = @mysql_query($db_list_sql) or die("could not get DB list");

$db_list_rows = mysql_num_rows($db_list_results);

// if database name posted, set; otherwise default to first database

if (isset($_POST[‘my_db’])) {

$my_db = trim($_POST[‘my_db’]);


else {

$my_db = mysql_result($db_list_results, 0, "database");


// get table list for given db

$table_list_sql = "SHOW tables FROM $my_db";

$table_list_results = @mysql_query($table_list_sql) or die("Table list failed");

$table_list_rows = mysql_num_rows($table_list_results);




// if no tables, echo out error message

if ($table_list_rows < 1) {
echo "

This database has no tables



// this will only run if table rows exist

// nested loop: First of tables, for each table, second, display the table schema in tabular form

for ($t = 0; $t < $table_list_rows; $t++) {
$current_table = mysql_result($table_list_results, $t, "tables_in_".$my_db);

echo "


// get columns for given table

$column_list_sql = "SHOW columns from $my_db.$current_table";

$column_list_results = @mysql_query($column_list_sql) or die("column list failed");

$column_list_rows = mysql_num_rows($column_list_results);

// get column info

for ($i = 0; $i < $column_list_rows; $i++) {
$current_field = mysql_result($column_list_results,$i,"field");

$current_type = mysql_result($column_list_results,$i,"type");

$current_null = mysql_result($column_list_results,$i,"null");

if (strlen($current_null) == 0) { $current_null = " "; }

$current_default = mysql_result($column_list_results,$i,"default");

if ($current_default == NULL) { $current_default = "(null)";}

// echo results

echo "


} // end columns

echo "

Column Type Nullable Default
$current_field $current_type $current_null $current_default


} // end tables


// close connection



Obviously (?), such a tool should only be deployed to an admin area of a site – and there are layers of functionality, security and complexity that one can add to such an app.

But I’ve worked with a lot of coders who were just that: coders. NOT programmers.

A tool such as this is helpful; they don’t have to pop open a database tool (or command line) to query a given database to find out if a given table has a column called “user_profile” vs. “userprofile” or if a given column was int vs. char vs. varchar(255) vs. [longer text].


Even if not, a good exercise.

Bush and Broadband

According to a recent Reuters’ report, President Bush is pushing for universal broadband Internet access as part of his re-election platform:

“We ought to have universal, affordable access to broadband technology by the year 2007,” Bush said in a speech focusing mostly on homeownership. “And then we ought to make sure that as soon as possible thereafter consumers have plenty of choices…”

  –  Bush wants cheap high-speed Internet access for all by 2007, CNN, 3/26/2004


Define “universal” and “affordable”.

And – while I support the underlying message (should be like access to radio/TV signals) – this is not exactly high up on the priority list of most Americans.

Until I see some details about this proclamation, I will remain skeptical and view it as a campaign stunt.

I.e. If one had a job, the “affordable” part would be less of an issue (if no job, whatever “affordable” is, well, it isn’t).

I.e. If one had a well-paying job, the “universal” aspect would be less of an issue (with bucks, you can get most anything).

Comes down to jobs…

Tunnel Vision

In a recent entry, I remarked that I was not surprised but frustrated that commenters on an article about MS and bundling issues on Kevin Drum’s Washington Monthly blog turned into a Slashdot-type thread.

Instead of discussing the issue at hand – bundle, who gets to decide? (government, courts, producer, marketplace or some combo) – it turned into a thread that was all about bashing MS, touting OSS, saying people should dump Windoze into the river and get a Mac and so on.

Some valid points raised, but…this was not the time nor place for same.

I wrote Drum and asked him why he thought the thread went off the road in such a precarious manner. His reply:

Every single post about technology turns into a Mac vs. PC thread (or Linux

vs. PC or everything vs. PC). It usually doesn’t take more than three or four comments before it starts.

  –  Kevin Drum e-mail, 3/25/2004

In other words, he’s sort of given up on the expecting intelligent discourse when tech issues are raised. They always seem to degenerate into some sort of technological jihad.

This reminds me of Eric Raymond’s recent rant – again, commented on in this blog – about OSS’s poor track record with user interaction.

The thread running through each of these articles is pretty simple: Many tech folks – even those who are actually pushing products out there for us to use – are blind. They don’t get that much of this tech stuff is incomprehensible voodoo to most of the world; they can’t seem to look in a peripheral manner to see the big picture or the gradients of gray.

I.e., if an article mentions Microsoft, it’s time to slam MS and promote Linux/Apple/OSS etc. Whatever the article’s topic.

I.e., people want choice, even if it’s to pick “WAN, LAN or Build Own TCP/IP stack” via a wizard for network connectivity.


I’m all for choice; I’m all for getting MS to – somehow – toe the line and behave in a legal manner (moral manner? what percentage of capitalistic companies behave morally??).

But there is this relatively small group that is making all the tech decisions for everyone, and this small group has, in many cases, blinders on. This small group does not know better.

Evidence? Call Myth-Busters!

Myths busted (People = the vast majority of the world):

  • People want choice: No they don’t; they want something they can work cheaply, interchangeably (think .DOC or .XLS files) and that doesn’t require learning. They don’t want to have the choice to download a plug-in to view this or that. It should be installed by default. If not, bugger off.
  • OSS is better because the source code is available: Most people don’t care; they will never look at the source code, even if they run Linux. Take this a step further: For most People, ‘source code’ is…uh, what??
  • MS is devil spawn: Both in the U.S. and E.U., Microsoft has been found guilty of major infractions. Fact. Yet MS has brought (yes, ‘at what cost!?’) a certain degree of standardization to the desktop (the People’s computer). The Web has taught us that this is a good thing. I love that I can send someone an Excel spreadsheet and be pretty damn confident that the recipient can open it. As Martha Stewart would say, that’s a good thing.
  • OSS is free – as in Freedom, not (necessarily) as in Beer: People: “Huh?” and “Big whoop…”

Obviously, this is simplified, but it’s a good snapshot. Most people don’t care about the “religion” of technology; too many technologist seem to fall into the religion trap. At the same time, these examples leave out the potential benefits – invisible to People – that OSS can bring, for example.

But the invisibility is an issue: If People don’t see it, they won’t care. And few like to be educated so they can see the formerly invisible, especially if they don’t care about the course (in this case, tech).

Use a car analogy: I don’t really know how an automatic transmission works, but I want my car to have this. I prefer to drive only cars with same (and clutches everywhere thank me…). There are good, solid reasons to use a manual transmission: I don’t care. Which takes less experience/learning? Automatic.

I’m done.

Ditto for computers. People want to take the computer home, plug it in and…bingo. All done.

And this, my friends, is how you start a flame war!

Text vs. Not Text

Many of the powerful features supplied by Web scripting languages (and use beyond the Web) is the ability to handle text.

Move. Push. Pop. Array to string; string to array. RegEx to add/split/replace and so on.

Powerful stuff. Different levels of “powers” for different languages, but – overall – text handlers are available and impressive in most Web languages.

More difficult once one hits a non-text item, for example, an image.

There are a whole bunch of ways to approach this issue (depending on the language, database/not and so on), but here is one generic example: Assume one has a databased app that stores the text (headline, full article) of a some online news story.

Assume, as well, that the article (or its CMS – content management system) allows (optionally) one image to complement the story that is not databased (except for pointer) but resides in the file system.

Pretty basic.

Yet, while text-based info can be validated against some text-based rules (trim item, must be more than 10 chars and less than 255 chars, cannot be a dupe for its column [headline, full article] and so on).

Images? Little more complex.

  • Is provided image (via upload) valid?
  • Is image a [list or not of acceptable image types]? I.e., is image a JPG?
  • RE: Previous point – is the test against the file extension (i.e. a text file with a “.jpg” extension) or a real test as to what the file is (i.e. “text.txt” is really a JPG)?
  • Any rules on file size? – Height, width, file size
  • Any rules on what to call the uploaded image? I.e. should “rose.jpg” be transformed to “[article_id].jpg” or does each image get it’s own directory? (Can’t have two different “rose.jpg” image in same directory)
  • Transformations: Is the upload supposed to resize/resample [different format] a valid image upload? Copy those images (full-sized, thumbnail for example) where?

Each of the above points is relatively trivial; taken together, it’s a lot of trivial decisions (only JPG?) and conditional logic.

Way messier than text handling. Yes, best handled – as I have done – with different functions and so on…but still…messier.

Full disclosure: I just finished a “update” area of a Website that permits an image upload (along with lots of text stuff). The image processing/trapping – for one image on a page that has a half-dozen text areas and various mappings (to other areas) – is roughly 20 percent of the code.

In this particular case, I was/wasn’t doing the following – this is not rocket science:

  • Uploaded image must exist (PHP)
  • Uploaded image must be a JPG (ImageMagick)
  • New image overwrites existing image (so no unique issues)
  • Standard – but messy – process to resize a given image to 1) full-sized and 2) thumbnail images on given (local) server
  • Upload those full/thumbs to remote server
  • Defaults are set for the processing of full/thumb images

OK, there are defaults set for text, as well – usually NOT NULL and length is not more than [max] characters.

Images are different. Why?

  • Different defaults – MORE defaults – need to be set (dupes, type, width, height, color depth…)
  • Text rules are usually resolved via submitted values (POST values); images require examination of uploaded (or not) file.
  • Text rules may require examination of uploaded (POST) text and database text. Images (or any uploaded file) usually requires the same AND file structure examination (example: Yes, “article_name” = x in the database; but – for an image – one has to check to see if “article_image” is a dupe or whatever in the database AND file structure (unless storing as blobs, which has it’s own overhead)


UPDATED: 3/27/2004 I cut short this entry due to fatigue yesterday. Here is what I left out:

While it’s true that you can – and should – build tools to handle the different (i.e. non-text) datatypes, that’s part of the issue: You have to build them.

For text, most language offer a plethora of tools (regEx, split, arrays and index/substring functions alone handle most of heavy lifting) built in – to different degrees with different languages.

Extensive image – or other file – handling mechanisms are either missing or pale in comparison to the text tools. To a degree, this makes sense – most data processing is text processing, and text often needs to be massaged (parsed, for example), file uploads are usually just an upload/validate that file is [such and such] a file, rename and move. There is not much massaging of the file innards; there is often much monkeying with text strings.

Yet there is a dearth of tools for image processing/validation built in to many languages (I’m not certain, but I think Java does a good job of natively allowing image access – sizes, type and so on).

For other languages – such as PHP or Perl – a (wonderful/brilliant) third-party tool – Imagemagick – allows all sorts of image manipulation/validation (see the IBM tutorial).

While third-party tools can either extend a language’s abilities – or replace native implementations with a better toolsets – these tools must then be available on whatever server the code is deployed. This can often be a huge issue.

For example, get The Suits to sign off on installing a free, open-source (yeah, no support contract/contact) program like ImageMagick on a server. Or you have your own personal site on shared hosting, and the company won’t install this tool. In either case, you could be screwed.

Native support is virtually always preferable, for the preceding reason (it’s there, guaranteed) and for performance issues. Another layer of abstraction over existing code is not the way to go, for the most part.

In addition, non-native tools – be they user-defined functions or third-party products – are not familiar to all developers, so there is that learning curve/slowed production.

For example, all PHP coders know how to grab a substring.

However, if I build an imageDiscovery() function that validates image, passes back the image extension and sets default image HxW and so on, well, that’s custom code that same developer will have to learn if he works on my code/site. Ditto for a third-party tool (such as ImageMagick): The same developer might be used to a different third-party tool, or none at all. Again, learning curve/slowed production.

Ah well, end of rant.

Religion Wars

Kevin Drum – formerly of Calpundit, now of Washington Monthly – usually writes on politics, but in an article today he tackled – in an oblique manner – the browser wars.

What was interesting – to me – is that the article basically zeroed-in the whole issue of bundling products: Microsoft’s contention has always been that it’s not up to judges to decide what goes into a product, it’s the call of the company and the marketplace.

There’s a great deal of validity to this. (Yes, have to consider the monopoly issues; agreed.)

But the comments on this issue (yes, a couple are mine) pretty much focused on how MS sucks, how IE is not compliant, how Opera or Mozilla is the better browser, how OpenOffice is a good replacement for MS Office and so on…

Uh, OK, some valid points, but that’s … uh … not the focus of the article. It’s about bundling.

And people turned it into a Holy/Religious War.

I hate this shit. That’s what’s happening in the Middle East folks; it’s why Richard Clarke is being praised/slammed in Washington D.C. right now.

In a disturbingly overwhelming way, all three issues (MS, Middle East and Clarke) are focused on most anything but the actual issues going on. Just keep twisting the facts…or use one part of one fact to launch on an attack on some unrelated issue…

Maybe I’m just getting too old and cranky; maybe I’m irregular; maybe I’m upset to discover that John Stewart’s The Daily Show isn’t real journalism! Gasp!

Java Jive

I mean the Java language, not the beverage.

I’ve been working in Java for the last few days – just for kicks – and it’s been a mix of highs and lows:


I haven’t worked in Java for about a year, and I’ve never worked in Java for an extended period. So the relearning process – each time – is fun in that it’s great to rediscover this language.

Each time I go back to Java, I have more programming notches on my keyboard, so I better appreciate all that’s gone into this language. It’s considerable.

Having done the Java-installation process before, I didn’t have to do this process for my current machine. Yay. Installation of the SDK is still somewhat a geek fest.

My years of working with Linux – for the most part, straight command-line – are paying off for Java. The lack of a good IDE (see “Lows,” below) don’t hurt that much. I just code in my HTML editor (currently ColdFusion Studio), and compile and run from the (DOS) command line.


I haven’t worked in Java for about a year, and I’ve never worked in Java for an extended period. So the relearning process – each time – is frustrating. I keep wanting to do things I could do before (say, Process C) without learning Process B. Jumping ahead…

I still hate the AWT – sure, I can use Swing, as well/in place of, but the AWT is still essential in many ways (at least for demos that I look at to learn and so on). Struts, currently, are far beyond me.

My favorite IDE – Symantec’s Visual Cafe, very MS Visual Studio like – was sold to someone years ago and they, in turn, sold it to someone else. I think the product is currently either dead or way too expensive (~$3,000?). And my copies (v1 and the Database Developer’s version) won’t run on my main box (Win2000) – they don’t recognize Win2000 as NT. Crap. Visual Cafe kicked but over Sun’s Forte and Borland’s JBuilder (both of which I have installed on my Win2000 box), and Visual Cafe is a much older product. Interesting.

Reflections on Scripting Languages

The Web continues to evolve, and with it the purpose and power of Web scripting languages. I’ve blogged about scripting languages – many times, RE: many issues – in the past; with the rise of .Net and the imminent release of PHP 5.0, perhaps it’s time to take another look at these languages.

Outside of the compiled vs. interpreted language differentiation, I don’t know what the best definition of Web scripting languages is. For example, I consider Perl a Web scripting language (one of it’s many uses), yet Perl is compiled – at run time.

Oh well. Consider this a look at the following Web scripting languages:

  • ASP
  • ColdFusion
  • JSP
  • Perl
  • PHP

There are other contenders – such as Lasso, a horrible, horrible language – but I will stick those in the preceding list. And I leave out the templating systems, except as they may pertain to a specific language (such as smarty on PHP).

All opinions expressed (except as linked, obviously) are my opinions; all errors are mine, as well.


First of all, let me begin by saying that I haven’t done any professional ASP coding – stuff I’ve been paid for – and I don’t have any experience with ASP.Net or whatever the fuck it’s called. So ignore the following if you’re already rolling your eyes.

That said, when I taught myself ASP, I didn’t build a HELLO WORLD page – I built a password-protected, session-enabled CMS that had a visitor section and admin section (add, edit, soft-deleted users and articles etc). So I don’t have a lot of experience, but I know a bit about scripting languages.

When I first began work with ASP, I was surprised that it was so well thought out. When I needed a function – based upon my work in other languages or it just seemed like it should be there, it was.

On the other hand, VBScript just totally blows. I just don’t like it. I do have VB experience (again, minimal), but … so what? I would have vastly preferred to use JavaScript as the logic for the ASP pages (ASP allows this), as JS is such a strong language. However, this doesn’t make a lot of sense – the whole “When in Rome, do as the Romans do…” point of view. The default is VBScript, most (all?) ASP coders are familiar with VBScript and probably not as familiar with JS, and I think there is a setting you may have to make on IIS to use JavaScript (could be just a default change; I can’t recall).

There is a lot going for ASP, however, and – as mentioned – I don’t know the whole ASP.Net framework, and I’ll bet that’s even better than the base ASP language. Also – very importantly – if you’re a dedicated MS house, ASP is probably the best bet: ASP is more tightly integrated into the MS framework than any other scripting language (leaving aside the debate if that’s a good thing or not, OK?).

Bottom Line Pros:

  • Tight integration with MS systems
  • Supported natively on MS’s IIS (no extra costs)
  • Excellent session control
  • Vast library of functions and other tools
  • Can call COM and COM++ objects

Bottom Line Cons:

  • Running on non-MS products (i.e. *NIX) requires third-party products (ChiliSoft, etc)
  • Native on IIS – the overwhelming choice of deployment – and IIS is a relatively porous server
  • Logic language – VBScript – is weak
  • User-defined function ability appears limited to COM objects


This is probably the language that I’m most familiar with – I’ve just worked at more jobs where this was the language of choice. Not necessarily an endorsement; not necessarily a ding. Reality. So be it.

ColdFusion – originally a product of Allaire, purchased around 2001-2 by Macromedia – is probably the poster child for simplified dynamic Web development. While other languages may scale better or support more C-type functions better, ColdFusion is the easiest language to hook up to a database and template out a dynamic site.

ColdFusion has excellent – almost transparent – database interaction features. It also makes handling sessions – another huge Web-language issue – relatively trivial. Combined with a tag-based format that reads as English, this makes ColdFusion an ideal language to allow newbies to begin experimenting with database-driven sites.

Not surprisingly, the strengths of ColdFusion also work to its detriment: Simplification reduces the ability to do the complex (at least as proportionately easily). One example of this is the most basic: Because CF is so easy to code, there are a lot of individuals out there who are (shiver!) running CF sites who really don’t have programming chops. CF allows this – double-edged sword and all that. It’s hard to find a Java programmer who doesn’t know some basic best practices (uh, say separation of logic and presentation as much as possible). Most CF coders don’t understand this basic concept.

Bottom Line Pros:

  • Easy to use; easy to understand
  • The fastest way – such as for demos, proof of concepts – to get a dynamic Web site up and running
  • Tag-based language makes sense for HTML coders; database access is reduced to simple SQL and asking what is in result row X for column Y. Very transparent for the uninitiated
  • Runs – as third-party app – on almost every platform/configuration

Bottom Line Cons:

  • Simplification at the expense – at times – of the ability to do the complex
  • Requires third-party product (i.e. ColdFusion) to be installed
  • The latest release (no longer numbers ) – ColdFusion MX – is now rewritten on a Java core, which is good and bad: Good, as it allows Java programmers to get access to way more info/extend further; bad, because the regular CF programmer is not Java ready
  • There have been changes that create havoc – for example, v5 introduced the CFGRAPH tag. As of version 6 (MX), the tag is deprecated and is now CFCONTENT, I believe. Deprecated after one release. Doesn’t inspire confidence – will the code I write today work tomorrow??

JSP (Java Server Pages)

As with ASP, I have limited experience with JSP – mainly to teach myself how they work and all that.

There really isn’t a whole lot to say about JSP except the following, which will double as the Pros and Cons of the scripting language:

  • JSP seemed to first appear as a defense against ASP; this defense – leveraging Java in a scripting language, while clunky, worked well
  • JSP suffers from the same problems as Java: Compiled (JSPs are compiled upon first hit [slow]; zippy afterwards); complexity (for scripting developers, OO is hard); requires the whole Java infrastructure to be in place – coding and server – to be used. Often daunting. Sun has fucked up really badly on this, in my (inane) opinion
  • JSP benefits from the same strengths as Java: Many functions, robust OO infrastructure, large support network. And where ever Java goes, so will JSP. So it’s not a static language.
  • Often a third-party product (sometimes free; sometimes not) to run JSPs on a given server: Tomcat, JBoss, any of a handful of servlet handlers and so on.

Note: Russell Beattie has an interesting blog entry about JSP. Kind of a State of JSP entry: The good, the bad, and the fugly…


Before it was simple – or practical – to create a database-driven site, there was Perl. Perl CGIs, along with Unix include files (remember .shtml?), were the dynamic Web.

Today, Perl-driven sites are dwindling; many that are left (such as Slashdot) are holdovers from when Perl was the only way to do things. If these holdovers were launched today, they’d be in one of the other four languages described here, in all likelihood.

Perl, for all it’s strengths, was not designed as a Web scripting language. It was just a simple leap to make it such: Perl excels at text handling/transformation. HTML is a ASCII-text language. 1 + 1 = A dynamic solution. However, the lack of a Web-centric foundation makes Perl somewhat awkward to work with for Web development, especially for code monkeys (as opposed to trained developers).

For example, most scripting languages come built with constructs to handle the basic HTML GET and POST parameters (and so on). Until the Perl CGI module(s) came along, handling these variables page to page (such as a registration form) required a developer to create a custom subroutine to parse and make these variables available. Doable, but not clean or consistent (the biggest drawback).

And while Perl does have database connection tools (through the Perl DBI), Perl’s forte – as mentioned above – is text handling, and is often used in conjunction with flat files (delimited TXT files) as a non-relational database. Perl rocks for such work.

Bottom Line Pros:

  • Ubiquitous. No matter what server you’re on (*NIX or Windows), Perl will be installed. So a user wanting a quick dynamic app – say a guest book – on their site can use/commission Perl and be confident that it’ll work, even if they move to another platform in the future.
  • There are tons of fully functional Perl scripts floating around that one can use/modify to get a site app up and running in a hurry
  • Probably the strongest language for handling any sort of text transformations (Python is supposed to be strong this way, as well. I’m just not familiar with it)
  • Very fast language
  • Incredibly powerful search and replace functions (RegEx etc)
  • Free – open source. And there is a strong open-source community behind Perl, creating new modules and so on
  • No matter the scripting language a developer knows, there is a better chance that this developer knows some Perl than any other second scripting language. It’s that ubiquitous

Bottom Line Cons:

  • Not designed as a Web scripting language, and it shows. This is a serious liability
  • While Perl is not too hard to pick up, it’s hard to master: A well written Perl script can look like a bunch of punctuation thrown up on a page.
  • RE: Preceding point – As a very non-English language, it can be hard to maintain, especially non-commented code
  • Hard language to really master well enough to do a whole site (well) in the language. This is not true of, say, ASP or PHP


PHP is currently my favorite language. It combines the Web-centric designs of ColdFusion and ASP with the robust text-handling ability of Perl to make a language that is not without its flaws, but one that is ideal for Web development.

PHP was designed from the get-go as a Web scripting language: PHP originally stood for Personal Home Page (today, PHP = PHP: Hypertext Preprocessor…yeah, just rolls off the tongue…).

As mentioned, it combines the best of many languages, including Java, into its framework. With the C-like syntax and expected higher-level functions (example: all the math functions), PHP can – out of the box – handle almost any Web task needed.

And with a little extra effort/expertise, PHP can be tweaked with non-standard options (such as ClibPDF) to handle virtually anything you can throw at it.

I thought that PHP would die out – be drowned out, if you will – in the tidal wave of (somewhat) proprietary scripting languages (ASP on Windows side, JSP on *NIX side). I was quite wrong. PHP seems to have grown in importance and visibility. It’s interesting.

One major downside of PHP is the way the language keeps changing: Moving forward is OK, but it seems like everytime I look up a function (at the great online resource, there is a note limiting it’s use: (PHP 4 >= 4.1.0).

The leap from v3.x to v4.x was huge and to leave v3 users behind was a good more. But the mess is that there are a lot of v4 functions and so on that don’t work unless you have version 4.x.y, which is somewhat problematic. At it frightens me to see what the new version – 5 – will bring (currently a release candidate; so almost there).

Bottom Line Pros:

  • It’s designed and built out as a scripting language. While some are extending its use as a shell-scripting language, it’s a Web scripting language first. This is a enormous plus
  • Steals – uh, leverages – the best of other languages (C, Java, Perl) so the syntax/structures are familiar to coders and just about every function/structure needed is available
  • Rapid coding is possible. Java/JSP may be more robust(?), but PHP is much faster to get up and running. Only ColdFusion is faster in this respect
  • Fast language, scales well, runs on *NIX and Windows
  • Open source; lots of contributions; the language continues to advance

Bottom Line Cons:

  • The updates don’t seem too well thought out – lots of updates/additions that require newest/newer version of PHP
  • Trying too hard to be all things. For example, the function disk_free_space() is the same is the function diskfreespace() (the latter is an alias). Will one be deprecated in future releases? Which one? Did I pick the wrong horse (alias)? Also a maintenance issue.
  • It is an open-source product, so there is no company behind it guaranteeing its future (such as MS behind ASP)
  • Reminiscent of Perl in many ways, but without the bare-bones structure of Perl (which is also a good thing, as Perl can be so damn punctuation heavy)
  • Pet peeve: The array variable – same as regular variable. In Perl, an array called foo is identified as @foo; in PHP, it’s $foo (same as non-array variable). Yes, there are functions to show the difference, but – from a readability/maintenance standpoint, the Perl notation is preferable, to me.


The first thing to take from this (very rough) comparison is a given that I approached this exercise with: Languages are not right or wrong, they are just potentially convenient.

The best car? For what? Road rally or taking 12 kids to soccer practice?

Ditto for languages.

That said, some rules of thumb for choosing/using a scripting language:

Scripting Language Choice(s) – Rules of Thumb:

  • Yes, it’s hard, but do some research to determine what will work best for your now (basically most of the scriping languages listed above) and in the near future (harder; hints below)
  • Of the listed languages, only ColdFusion may expire: ASP has MS behind it; JSP Sun/the Java Community; Perl…too pervasive and useful to die (not grow? Possible: Doubtful, but will still rock); PHP is OSS, and it has struck a nerve with developers.
  • ASP is great for MS-only shops with a lot of VB or C++ experience, so you can tie in COM objects
  • Java is THE server language for non-MS shops; JSP is (sometimes logical) face to beans/servlets and so on. As long as Java is around, so will JSP
  • Perl is not a Web scripting language (at foundation level). I will always (?) use Perl, primarily for scripting, log file transformation and so on, but I don’t want to do a full Perl site. But that’s me.

Economy of Scale (NOT!)

There are a lot of important advancements that take the status quo and massage it. For example, see the picture at right: A large (4G or so) hard drive that’s coin sized. Wow.

On the other hand, consider the same drive from an evolutionary standpoint.

It’s a Winchester Drive (I wish I knew the origin of this phrase; I don’t. Who/what is Winchester?). These have been used since the 1980s (at least); each year, the drives get smaller and the controllers get smarter.

When I first worked with such a storage device, it was for a library computer the size of a conventional desk, and the drives were Winchester but sorta (?) swappable. Each Monday, the two large platter drives (the size of deli platters) were rotated, and one taken off-site (early “back up”).

Today, smaller, denser, more efficient (pixie dust and all that)…but the same as yesterday.

Today, hard drives are evolutionary.

We need storage medium that is revolutionary.

Flash RAM and so on. Moving parts do not make it in a solid state world.

I love what Toshiba is doing. But would it not be better without moving parts??

Jobs As Commodities

There are a lot of issues surrounding the meta-issue that falls under the rubic of Overseas Tech Industry Outsourcing, but one issue in particular strikes me.

Outsourced jobs – overseas or not – are analagous to the current battle (of sorts) over software.

On one hand, there are the Microsofts and Oracles that are trying – in some cases, desperately – to maintain the status quo: Software is a proprietary product; binary-only distrubution and so on.

On the other hand, there are the RMSs and ERSs and Linuses (Lini?) who are pushing for more open ways to develop software, to break down the patent walls.

You can make a case for either side, but it is hard to disagree that the momentum is currently on the side of the open-source software folks. This is also the side that sees software as a commodity, much like Intel boxes (hardware) are today.

The entire issue of outsourced tech work is the same concept, to a degree. Basically, there is some company or group of individuals who architect things in all cases (hardware, software or software projects) and then others – without the need for higher skills or vision (though they may possess both) – put the things together.

Dell architects a PC, slaps it together from parts for Nvida, Intel and so on.

Linus or a kernel manager creates the Linux version, others contribute this or that little piece or extension to same.

Company X has this software project that needs App A to talk to App B; the architecture/scope is done by a small group and then the 1 million lines of code needed are done by groups…who cares where?

Why should Dell have to make RAM chips?

Why shouldn’t Linux get a print driver for an obscure printer from someone who just wants to do it for kicks?

Why shouldn’t economy of scale work/basic economic reality drive coding? Just because the company is in India doesn’t mean those workers can’t do defined Java tasks as well as American workers.

Fortunately, I have still seen relatively little pushbacks by the tech talkers (i.e. bloggers and tech columnists) about the tech outsourcing.

I have, of course, heard a lot about this from the talking heads who are in political office or who want to get there. To a degree this is understandable – hey, jobs are hard to come by here, so let’s keep what we can – but it can’t ignore reality.

The tech industry can’t afford to fall for the empty rhetoric that is fueling the press releases of the MPAA and (especially) the RIAA. Times have changed, and even if it impacts the industry in a way that you (or you…or you…) don’t like, get over it. The genie is out of the bottle. Work with it or – ultimately – be left behind.