Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am fairly new to web-application development. I just can't shake the feeling that it takes me forever to do anything of even remote complexity. In c++ and java I could write the same applications in a matter of hours.

On the web debugging is painful (especially if complex json-ajax) is involved. IDEs suck. The languages let everything through without errors until it is doesn't work anymore and you are stuck looking for a bug without any error or warning to guide you (and no real good way to step through the program).

Can someone guide me to reading material and/or technologies that would help me find a way to stay sane when developing complex web-applications?

Perhaps the answer is to use a good framework (zend?). At work we are not really using a framework except for database models generators and basic add/update/delete page generators.

share|improve this question
    
To clarify I am mainly talking about server side php debugging not JavaScript. –  zhenka Aug 30 '11 at 2:09
2  
Maybe you could update the title and tags to reflect the clarification? –  psr Aug 30 '11 at 3:18
    
You could write your web application in Java? –  user1249 Aug 30 '11 at 7:40
3  
Stepping through a code in a debugger is the worst possible debugging technique (and for some reason it is hugely overrated). Embrace the power of asserts, contracts and logs. –  SK-logic Aug 30 '11 at 8:11
1  
@Raynos, there's a number of contracts frameworks for nearly all the dynamic languages (but I have not seen anything like this for PHP, to be honest). en.wikipedia.org/wiki/… –  SK-logic Aug 30 '11 at 9:51

6 Answers 6

up vote 4 down vote accepted

If you're not using Firefox and firebug already, you should do so. Firebug's debugger is just full of awesomeness (not that Chrome's isn't, they're largely the same), but I tend to go with Firefox because of OS projects such as mozrepl, which allows you to script Firefox rather than using browser-spawning automated test suites such as Selenium.

So, for client side, either Chrome or Firefox have great built-in debuggers (filled with watch panes, performance monitors, all the good stuff that you've come to know and love in C++/Java).

As for server-side, if you're using PHP, then I strongly suggest using DBG. If you're not tied to PHP, then I'd also strongly suggest moving to Python and using PDB. PDB, coupled with cProfile just makes development life a lot easier.

If you're accustomed to GDB at all (C++), then both PDB and DBG should be crazy easy to pick up and run with. Both can also be integrated into editors like Eclipse, Netbeans and Vim.

share|improve this answer

XDebug could help you debug in a fashioncloser to what you're used to with VS (the latest versions of Wampserver ship with Xdebug (both server and client), if you're looking for an easy development install that installs everything you need except a text editor).

Also, if PHP isn't your thing, try another language: you may be happier with Python, Ruby/Rails, ASP or Perl.

Also, you could write C++ CGI modules instead of PHP scripts, though I would advise to try PHP some more, it's quite handy once you get the hang of it.

share|improve this answer

Some tools that I use to improve my development are:

Visual Web Developer 2010 (part of Visual Studio 2010)

You said IDE sucks. With this you now have one of the best IDE out there, and if you used to code in C++ I bet you already know VS. I use the express version which is free and I don't need more.

JS Fiddle and Codepad

Great to try out HTML/CSS layouts, and JS scripts. Codepad is great to tryout your website in server-side languages.

Firefox + Firebug (or other browsers equivalents)

Debugging scripts is far easier using the browsers. You also have a complete tree-style DOM you can manipulate as you wish and changes will be applied in real time.

Use a framework

There are various frameworks for every web language out there. They offers you a set of functionalities well tested that ensures cross-browser compatibility, save you a lot of time of debugging, and "write less do more". I suggest looking into jQuery and YUI for JavaScript coding.


Console Log

To track your debugging progress, use a Debug Console, integrated in most browsers. In JS, using console.log('something to write'); will add a text entry to the debug console, this way you can add useful information to your code for debugging purposes and keep track of your code execution.


Boilerplate

Now don't get me wrong. I know you are into web application development and not normal website. But the fact is, it's still a website, and you still need to take care of the most important issue you have: cross-browser compatibility. This is a solid template which will give you a solid base for your HTML pages, and much much more...

CSS Reset

If you're not using Boilerplate, which comes with his own CSS reset, you may still want to make sure your pages looks correctly among browsers. A CSS Reset will ensure this. My favorite is YUI CSS Reset, together with CSS Base and CSS Fonts.

share|improve this answer

Using a framework like Ruby on Rails helps ease the frustration a great deal. It has pretty good error reporting, and thanks to ActiveRecord working with models and databases is a snap. As long as you follow the philosophy of convention over configuration, you can prototype complex web applications pretty quickly with RoR.

I'll second Firebug, although the Developer tools for webkit work nicely as well.

Edit for resources:

Here's a great place to get started for free.

www.railstutorial.org

share|improve this answer

You could always use java or C++ (or ruby, or python, or scala or...) if you really can't stand PHP (which is understandable. A lot of people don't like it.)

If you want to stick with what you're currently using, make sure you're using firebug (though the google chrome dev tools are about to get a lot more awesome) with the FirePHP plugin which will allow you to have a full view of the PHP state and any errors that occur.

Further, make sure you use the PHP Error handling functions in use (but remember to remove them again before you go live, because they're also a great way for malicious users to find out the internals of your app)

As for IDE's, you could always try the Eclipse PHP Developer Tools or use the more dedicated Zend Studio.

share|improve this answer

I program differently in dynamic languages. There is no compile-time checking, but neither is there any compile-time delay. So I write a tiny little bit of code at a time, and then test it. I start with a blank page, and add one element at a time, testing as I go. I commit each little change to revision control as soon as it works. That way if I screw up I can just revert to the previous working state and have another go. On the server side I have found dynamic languages to be much more productive than Java, because I have to write and read so much less code, and because I never have to mess around with server restarts.

share|improve this answer
    
+1) That is the same approach we used also in our team. Web Development has several diffrences compared with desktop applications. But in general a develop and test criterium is the one that let you better find potential errors in the new code. –  Luca Aug 30 '11 at 7:57
    
You don't have to mess around with server restarts with Java if you choose a good framework like Play Framework –  Jonas Aug 30 '11 at 8:40
    
@Jonas - It's true that restarts are not due to a Java limitation, but AFAIK none of the popular JEE implementations will dynamically reload classes. Hot patching works sometimes, but really it's a hack. –  kevin cline Aug 30 '11 at 12:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.