@madpilot makes

Debugging JavaScript in Internet Explorer

As anyone who has ever received the dreaded Object doesn’t support this property or method error in IE can attest, debugging using everyone favourite browser is a right, royal pain in the heiny. Using Firebug in Firefox really has spoilt us as frontend developers (Hey, what am I talking? These ARE BASIC TOOLS that every other development platform has had since Ada Lovelace was in small britches, but I digress), so what is a cross-platform developer to do?

Little known fact outside of the .NET world: Visual Studio has a complete JavaScript debugger built in, which allows you to set breakpoints, add watches, mess around with variable values and more importantly, gives you better error messages, and actually highlights the line where things went wrong.

  1. Download and Install Visual Studio Express Edition (which is free as in beer).
  2. Create a new Web Site – call it what ever you like, it’s just a placeholder
  3. Hit “Run” (or F5) on the blank problem – a local server should start, and IE7 should load a blank page
  4. Change the URL to the page you want to debug. Once the page is loaded the debugger is good to go – in fact, if your page has any errors, Visual Studio will get focus, and politely tell you as such
  5. To add a break point, flick back to Visual Studio Express and open the JavaScript file you wish to add the break point to, and then refresh the browser – once context hits the point, you will be able to step through the code.

Whilst still lacking a DOM browser (Firebug Lite might be able to help out with that), this takes some of the fun out of debugging JavaScript IE, from the point of view that it is now actually possible.

Enterprise Rails

Anyone in the Rails community would have read Zed Shaw’s rant about Rails. For those of you who don’t know Zed, he wrote Mongrel, which is the default web server library used in Rails. It has blown up and been discussed on just about every list, including Rails Oceania. I’m not going to discuss what he said, or his tone, as it has been done to death, and he seems like the type of guy that you need to know to understand where he is coming from.

What did hit home from me was what he said out enterprise Rails. To frame this correctly, have a listen to the first half of this podcast from RailsConf.

As a rubyist, I could never understand why projects like JRuby or IronRuby existed. Why would you want to run another language in a different virtual machine? After reading and listening to Zed, the answer is obvious – integration for enterprise. If you look at existing enterprise systems they will run on technologies such as Java and ASP.NET and with good reason: Support. You can go to certified training courses and become a certified engineer, which makes hiring for these large corporates easy. There is also a a large number of consultants that have based their business models on these technologies. These guys know things like Tomcat and IIS – they don’t know (or care) about Mongrel or Lighttpd or even Apache.

Web 2.0 is not going to be around forever – regardless of whether you think the web-o-sphere is in a bubble at the moment, it will cycle at some point, and there is going to be a hell of a lot Rails developers out of jobs. Software-as-a-Service will alleviate some of this, but there is one BIG area that has been ignored – and that is corporate and government applications. The beauty of targeting this audience is that it is big and constant – their will always be big business that need IT systems. There is a number of reasons why this segment has been ignored by Rails coders that Zed rattles off – issues with connecting to legacy databases, lack of LDAP/central login system access – but these are technical issues, which are easy for programmers to fix.

I think the bigger issue is the complexity culture of enterprise systems – DRY isn’t something is in their vocabularies, so we don’t like to talk to them, because it makes our lives harder, and they don’t want to talk to us, because they don’t think the systems we build will do what they are asking. Having said that, I’ve seen enough hacked up Access databases in government and the education system to realise that this is complexity, for complexity’s sake.

Things like JRuby and IronRuby are going to make the the integration side of things easier – now we need to start getting back in to the corporate space.

SaaS is basically the same thing as ASP – ASP is what it was called during the last dot-com boom.

Indenting highlighted source code with WordPress 2.0

Ok, after going away and thinking about the problem, I came up with a quick and dirty (But seemingly effective and compliant) way of doing the indenting. It does require a small modification to the GeSHi code. I’m going to use an empty inline tag (ins tag – which stands for insert – how appropriate…)

Open the geshi.php file (See my previous post about code highlighting in WordPress 2.0 if you have no idea what I’m talking about) and find the indent function. Search for all the nbsp elements and replace with:

  1. < ins class=“in” > < /ins>

Now open the insertcode.css file and the style.css (in your theme) and add:

  1. ins.in {margin-left: 15px;}

Voila! indenting. The output looks like this:

  1. < ?php
  2. echo “hello” . world();
  3. function world() {
  4. return “world”;
  5. }
  6. ?>

A few more notes: html and xml highlighting is pretty well broken unless you add a erroneous space between the angle bracket and the tag (See this example) and don’t try to use special characters. I’m currently tweaking the colour coding classes to make them look nicer too. I’ll post these when they are done.