Posts tagged: php

goto in PHP

xkcd

I had a class in middle school where we did a little bit of programming. I don’t remember much about it, and the programs we wrote probably weren’t more than 25 lines. The one thing I do remember is that we used gotos. No object-oriented programming, not even functional programming.

The reason I mention this now is that I was talking one of my colleagues today, arguing PHP’s case, as he supported Python, and I mentioned that as of PHP 5.3, PHP now has a goto operator. He was really hoping that was a joke, and now probably takes the language significantly less seriously.

There are plenty of criticisms of goto, not the least important of which is Edsger Dijkstra’s Go To Statement Considered Harmful. The crux of most arguments, though, seems to be that goto statements are not inherently semantic and as such aren’t appropriate for modern structured languages.

I’m not using PHP 5.3 yet, so I can’t say that I’ve used goto already, but I don’t see why having a goto operator can make a language intrinsicly bad. There’s some code that looks gacky however you try to write it, and in some cases a simple goto may actually make it easier to read and understand, even if it also has its share of bad uses.

Looking over some comments on goto use, one of the concerns I find most interesting is that of the kitchen sink mentality. Personally, I enjoy PHP because I can have one language and use it for procedural, functional, or object-oriented code–whatever I feel is most appropriate at the time. But, yes, this can also lead to poor coding standards and huge misunderstandings between, say two developers who are both writing code in PHP but with two completely different programming paradigms.

How well a language like this works for you depends on how you use it, and I think I can use it effectively, but if others prefer to work with just one subset at a time–that’s totally fine too. Anyhow, I plan to take a look this summer at this awe-inspiring Python that everyone around me keeps evangelizing (except for Jared, who loves Rails), so who knows? Maybe I’ll be enlightened then.

Moving to WordPress / bbPress

After many months of planning and procrastination, I finally used Spring Break to move my site from plain php for content and SMF for the forum to WordPress with bbPress. As much effort as it took, I have to say that either it was much easier than other conversions and integrations I’ve experimented with or the experience from those previous experiments has really paid off.

For the most part, I followed affacat’s instructions on his successful convert from SMF to bbPress, trying it out first on my own machine of course before ready to go live:

  1. Install bbPress 0.9.0.4 and WordPress 2.7.1. I chose to put bbPress in a subdirectory of WordPress. Set up the database integration as part of the bbPress installation and delete any posts created on install.
  2. Install the latest phpBB with the necessary converter to move my existing members and posts to bbPress.
  3. Install Jaim’s phpBB to bbPress converter. I had to change bb_users to wp_users, and delete the first user and forum from the SQL because there are already a first user and forum in bbPress. I’m not sure what the topic_resolved key was from, so I removed that option. Then I copied and pasted the code from bbPress into this tool to generate my topic and username slugs. (There may have been other changes also that I didn’t keep track of.)
  4. Finally, I imported the SQL into my database.
  5. Install and activate SuperAnn’s WordPress plugin for WordPress / bbPress cookie integration.
  6. Activate other plugins.
  7. Post the first blog entry and new forum thread to announce the updates.

Man, it feels good to finally have the base I need to build up my site.

Ringbinder theme by Themocracy