Why PHP?

PHP seems to have a bad reputation.

If you search the web, you’ll find tons of rants on how PHP is terrible, flawed by design, and some even less flattering stuff. But I don’t share the sentiment. I think that PHP’s main crime was being attractive to too many crappy developers.

My Love/Hate affair with Java

I learned Java back in the mid-to-late 90s. Beans was still considered new and Swing was expected to be the next big thing.

I loved it. It was simple, elegant and worry-free. Write once and let JVM worry about the rest. What could possible go wrong?

IMO: it was overused (and a bit bloated).

Take the Eclipse IDE, for example. Sure, nowadays it works fast enough on any decent computer. But 10+ years ago, it was more resource hungry than what most affordable PCs could deliver. Would I choose to write an IDE in Java? Maybe today I’d consider it, but it wouldn’t be my first choice.

Around that time, lots of stuff was being written in Java. Everybody had to know Java if they wanted to have a job, and we’d get freshly-minted programmers insisting that they could do device driver development in Java.

So I learned to hate Java.

Enter PHP

I was convinced to learn PHP mainly because of the expected speed of development. I wouldn’t have thought to program in anything other than Perl at the time, but a friend talked me into it for a small side project. I loved how fast and easy it was to do something useful with MySQL.

The “register globals” incident

Yes, this was one big design mistake. I’ll even admit it: at one time I did rely on register_globals. Guilty as charged. Maybe we didn’t know any better. But even if the PHP group changed this more than 15 years ago, it seems like the detractors haven’t forgotten.

Yes I have written crappy bits of code (other than the register_globals). Many of those crappy bits are still in the current codebase. And yes, I feel kind of ashamed.

There is no absolute “best” language

In the same way we can’t (and shouldn’t) use Java to write low-level software, we shouldn’t use Assembly language to write a cross-platform word processor.

Lots of people have a “favorite” language and will defend it fiercely. But languages are tools and some may be better that others given a specific purpose.

Whether due to laziness, ignorance, or just for fun: you can write crappy software in any language. You may want to complain about that weird way PHP handles dynamic typing, or comparison operators… and you may be right.

I might even agree with you if you decide to choose another language for your next project.

And if it’s not your choice to make, best I can do is recommend that you use version control, stick to a coding standard, and test early.

Every language sucks. And every language is beautiful.

Seriously.

So… why PHP?

The way I see it, PHP is great for rapid development of (non-critical) websites.

I don’t allocate a lot of time to this site’s development, so I need to be able to get a complete function or block of code done in a very small amount of time. PHP is good for this.

It’s about moving forward.

Hello world!

Some years ago, a page named Irony.com used to have all sorts of generators; but then one day it all disappeared. I wanted to have something I could rely on.

And this is how I got started with the rpg20.com site.

Monsters

The monsters database is what started it all. When WoTC released the SRD, I thought of writing a script that converted the document to a more manageable medium. I was already thinking of PHP and MySQL.

Before taking a dive into this endeavor, I searched the web. Turns out that some guy named John H. Kim had already done exactly that. And best of all: he was willing to share it.

I downloaded the monster and spell databases and uploaded to my page. After a quick hack, I had a usable UI. I then added a search function, list by CR option, filter by HP/CR, and not so long ago: terrain and climate search.

Images and maps

Then I thought about generating images. One of the things I remember most fondly about Ed’s Irony.com was that it generated an image of a town/village. So I thought I’d give it a try.

Ugly map
Ugly map

But the thing is… I think I’m terrible at drawing maps. So this has been something I’ve had a hard time doing: visual improvements.

But I told myself that dungeons should be pretty straightforward. And they look cool. And I love mazes. So I went ahead and made a dungeon generator.

image of a generated dungeon
A generated Dungeon

Evolution

I think I only had the monster/spell databases and the dungeon generator when I showed the page to a friend. He asked if I intended to put something in the room… descriptions, encounters, anything. A few minutes later my dungeon generator had monsters. Not long after that, it started having treasures.

But then I started thinking: I could have a region map that has one or more cities (and cities have taverns, right?), and maybe a dungeon somewhere, and there could be caves in a mountain.

So I’m at the point in which I have a ton of plans and not nearly enough free time to work on it. Ah, well… I still have fun even if it progresses slowly.

The code

These tools are online-only and most of them written in PHP. I don’t have any plans to develop offline-tools at the moment because it’s a bit more complicated: I’d have to compile for Linux, Mac, and Windows (I don’t own a Mac); any minor change requires to recompile everything; people don’t always know which version they’re using; etc.

Will this page dissapear? Well, it might some day. But before that happens, I’d release this code someplace else.

What’s the license for my code? I haven’t decided yet, and nobody’s asked so far… I guess I could use GPL to make sure modifications are shared back… But I guess I’ll decide as soon as someone’s interested in it.