Debugging a Web Page

Album Cover: Graduation

"Y'all pop the trunk, I pop the hood (Ferrari)."
Kanye West / Good Life

Posted on March 02, 2005 8:56 PM in Web Development
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

Although I have been designing and developing websites for over 10 years now, it wasn't until about my sophomore year of college (about 5 years ago) that I began dabbling in dynamic web programming. At that time, the webdev department at my school had purchased a ColdFusion server and was looking for excuses to put it to work. Because I worked in that department all 4 years I attended college and had a bit of a reputation for dabbling in new technologies, I was one of the first to start looking at what ColdFusion had to offer and how it could make our jobs simpler.

It wasn't long before I became at least semi-proficient in the language and began to turn my head in the direction of other web programming technologies. ASP was next in line, and it wasn't long before I had hooked my personal website and the Pleasure Unit website up to an Access database and dynamically served the pages using that particular language.

Little did I know at that time that I would soon be swept off my feet by another up-and-coming language, PHP, while working on what eventually turned into the Performance Library Database during my senior year. When work on that project wasn't consuming all my time, I managed to port my home page and the Pleasure Unit site to this new language, given that I wouldn't have to be tied to Access anymore and the language was just so darn cool. I was never a big fan of ASP to begin with.

Since graduating college, PHP has been my web programming language of choice, and there's little chance of that changing anytime soon. If anyone asked me what language they should use to learn dynamic web programming, I would answer "PHP" before they even finished their sentence.

This leads me to the point of this post, though (talk about long-winded!). In the past few weeks I have been programming in ASP .NET and there are some major differences that distinguish programming in that language from programming in any of the aforementioned languages. I could go into detail about each one at this point, but the main one I want to focus on is debugging.

If you've ever been in a situation where your PHP page wasn't quite doing what you expected, you doubtless found that your only real recourse was to turn up your error reporting and start plugging in print() or echo() calls all over the place in your code.

Having debugged software in the various versions of Visual Studio before, whenever I run into this type of situation, I wish that I could simply debug my PHP code in a similar manner. If you develop a web page (or site) in ASP .NET, you can.

I have to admit, the first time I did it, it seemed really weird. When you've been debugging by hand for 5 years and all of a sudden you have the ability to trace through your code line-by-line, catch exceptions, etc., it's really a strange feeling. It's by no means a bad one, though, and it's quite easy to get used to.

As I said earlier, there are many other trade-offs I could talk about here – like code separated from presentation and the "single-form" ideology, to name a couple – but I think that the debugging distinction is interesting enough to stand on its own.

ASP .NET could throw in a whole slew of other tricks and still not turn me away from PHP, but that doesn't mean I'm not open-minded about the whole thing. As is common in software and web development, there are often technologies that are ideal for some situations and not for others. The more we learn about the tools at our disposal, the more efficient we become as developers.


nordsieck on March 02, 2005 at 11:19 PM:

I think that it is interesting how intertwined peoples' conception of a language is with said langage's tools and libraries.

I remember attending a Microsoft deal-y at UW when .NET was just comming out. Everyone was saying how great C# was because of the really great libraries it had... . Well, I suppose that microsoft languages aren't the best example as it is much harder to separate implementation from specification when there is a single source... sans mono. I thought that that was kind of wierd... it seems to me that C# didn't add that much over C++ - managed code was the big thing (don't get me wrong - that is HUGE). And that all the stuff that Microsoft was bragging about - the libraries - could have been implemented in C++ just as easily (perhaps even easier, as they wouldn't have had to create the language and associated tools first).

Anyhow... if one googles for "php debugger", there seem to be a few tools that have similar functionality to what you are looking for... just cursorily, dbg seems to be the best of them, although trustudio looks like it might be good as well... and at least one version is free (eclipse rocks).

And, since I can't resist starting a flame war, there are two versions of python Jython and IronPython that use the Java Virtual Machine and Microsoft's CLR respectively, so you could potentially use those companies' tools to work on python scripts, in addition to what is avaliable from third parties.


Bernie Zimmermann on March 03, 2005 at 6:40 AM:

Thanks for the great response, nordsieck. I've always had a feeling there were tools out there for doing actual debugging of PHP code, the only problem being that there aren't enough people using them to show me they're worth their weight. I think I've used dbg before, and it wasn't my cup of tea. I've also messed around with Eclipse before, and there was much left to be desired (it felt too much like a Java app) in my opinion.

As far as the benefits of C# go, try building an app in C++ that posts data to a website, utilizes Web Services, or uses regular expressions heavily. Then, when you give up, try it in C#. Microsoft has built a strong language in C#, it's just a shame it has that whole Java-esque feel to it (before you can run my app X, you need to install interpreter Y).

Don't worry about the potential flame war, even though I've never used Python I have nothing bad to say about it. In fact, I consider that to potentially be the next frontier for me to explore.

Thanks again for the great feedback.


nordsieck on March 04, 2005 at 3:59 PM:

A short rant first followed by more calm discussion:

I guess I wasn't very clear about my point with languages - although your response pretty much proves my point.

I think that languages in and of themselves are mostly the semantics, choices in typing, choices in primatives, memory management models(1), etc. Basically the kind of thing that really defines how people write code, not what code they write.

What you seem to include in the language is all the associated tools - libraries, compilers, debuggers, etc. which augment a language, but are not integral to it. Is CPAN part of PERL?

To illustrate my point - the language brainfuck is quite limiting; it is probably the (well... one of the - there are probably hundreds of clones created at a college near you) simplest turing complete language out there. However, one could concevably create a large set of libraries for BF and achieve similar level of functionality (sans coding difficulties stemming directly from the actual BF language) to C# within the visual studio .net framework (well... at least C# on the mono platform; I think it would be much easier to leverage POSIX's everything-is-a-file than try to work out archaic Windows mumbo-jumbo).

As another example, which I mentioned previously, Jython (python which produces java bytecode) is still the python language, but it can use and extend java libraries and objects. This is a clear example of the difference between tools and the actual langauge, as all of the python tools are discarded and the java ones are used instead (well... some of them, anyhow).

When you say "try building an app in C++ that posts data to a website, utilizes Web Services, or uses regular expressions heavily" you are making my point that people see the language as the whole package - not just the pure language. All the examples that you mention can easily be implemented outside of the language. Indeed - PERL is the only language that I know of where regular expressions are native to the language (although I don't know many languages, so that is not surprising). Posting data to websites, web services and regular expressions are all functions, objects or services which reside in a large set of standard libraries that happens to ship with C#. My point was that that same set of libraries could have been cooked up for C++ instead.

I am not trying to make the case that there was no reason to go to C# - I think that the language definately improves on C++, most notably in the memory management area, as well as structured commenting (I am sure that there are a large number of other advantages, but that is all I remember from Microsoft's presentation 2+ years ago). What I am trying to bring to your attention is the difference between the language per se and all the accompanying tools.

Well... that's enough of a rant for today.

I'm glad that you found some of the links that I dropped helpful. I tried to learn php, but found it too confusing (ironic, no?) so I have no idea of the quality of the tools. I suspect that making quality debuging tools for php (or any interpreted language) is easier, as the interpreter is already made (for stepping through a program instruction by instruction); all one would have to do is intellegently insert some hooks into the interpreter and slap on a good GUI. This is certainly not trivial, but if someone can do it for C++, it should be able to be done for PHP - especially if there is demand.

I am not sure about the whole demand side of the equasion, especially with PHP. It strikes me that PHP, to an even grater extent than PERL, is so unstructured that the design of the language effectively prevents large projects without a great deal of physical code segmentation. It is arguable, then that the market for such a development suite is great enough to start a company to create such software (tiger and sugar CRMs are the only large applications I know of written in PHP). An open source implementation is certainly possible, but then again - who would have the skills to create a quality debugger for PHP and have the desire to do so as well; it seems like a most unusual itch to scratch.

To finish it off, I'd like to do a bit of python evangelism: besides memory management, I think that the structured indentation and strict, dynamic typing are python's best features. Well, that and the excellent standard library.


Post Comments

If you feel like commenting on the above item, use the form below. Your email address will be used for personal contact reasons only, and will not be shown on this website.


Email Address:



Check this box if you hate spam.