Note: This entry changed quite a bit in the 24 hours after it was published. I discovered a lot of stuff I’m ashamed to say I didn’t know, I posted several updates to the end of the post, and I eventually changed the title.
Quick survey: if you are a “traditional” ASP programmer (non .Net, so ASP 3.0 or below), what language do you program in: VBScript or JScript?
I’m guessing VBScript will win by a huge margin. I always programmed in VBScript back when I was working with ASP — it’s considered the default langauge for ASP.
Back then, I was only vaguely aware that there was even another option, and I certainly didn’t want to soil myself with those silly brackets and semicolons — those were for the goofy Linux crowd (of which I am now proudly a member).
When I made the move to PHP, I felt liberated by the language — the best example being array handling. You see, VBScript’s array support is utterly laughable. You have to declare the number of elements beforehand, then redeclare if you need to add to them (and make sure to use the “preserve” keyword, or else you’ll lose all the data…). Worse yet, to get a hash or associative array, you have to use a Dictonary object. It’s ridiculous.
In PHP, arrays are gorgeous, fluid creatures that let you do anything and everything. They’re one of the most powerful features of the language. They give you simple ways around complex problems, and I don’t think I’ve ever written a decent-sized PHP app that didn’t use them extensively. I use the array functions in PHP more than any other library.
Based on arrays alone, I can’t believe I wasn’t programming ASP in JScript instead of VBScript. ECMA Script has good array support — not as good as PHP’s, but you can do associative arrays easily, there’s a “push” method for tacking things on the end of an array, they can hold anything, etc.
(And I won’t even get into the fact that ECMA has “try – catch – finally” blocks. “On Error Resume Next” is just absurd by comparison.)
There are so many problems that I could have avoided by abandoning VBScript. Why didn’t I do it? I asked Joe — who programmed ASP with me for a long time — and he didn’t know why we didn’t switch either.
(It’s not an infrastructure issue, since making page execute in JScript rather than VBScript is just a matter of doing this at the top:
You could do this and not tell anyone. For that matter, you can make one page of an app execute in JScript and all the others in VBScript, if you want. No one would know the difference.)
If you’re a ASP / VBScript programmer, why don’t you switch? That’s not rhetorical — please tell me: what is stopping you from programming in JScript? Are there deficiencies in JScript I’m not considering?
Update: I found this page which lists the strengths and weaknesses of both languages when programming ASP.
It’s interesting to look at the weaknesses. The first one for VBScript is — not surprisingly — “Unforgivably Bad Array Support.” But JScript has it’s problems too: “Stunningly Inadequate Formatting Facilities” and “Lousy Date/Time Support” are both very true.
Another Update: I’m learning a lot. It turns out you can even install other languages into IIS and use them under ASP. You can do this with both Perl and Python.
Look at this page (a Microsoft page, even) to see examples of using Python with ASP. In this case, “ASP” merely becomes (1) the framework to execute the pages within IIS, and (2) the five intrinsic objects that get handed to the page (Request, Response, Session, Application, and Server) before execution.
Yet Another Update: I’ve changed the title of this entry to “ASP Doesn’t Equal VBScript” because that’s really what I’ve distilled this to after all these updates. A final example: ActivePHP. Yes, you could use PHP as a language for ASP. Seriously. I found a thread over at Zend where some guy says you could do this with ActivePHP:
<%@lanugage=ActivePHP%> <% $Response->Write("hello"); %>
The time for “traditional” ASP has obviously passed with the advent of .Net, but I’m frustrated that I never truly understood the separation between framework and language with that platform. I could have been a much more effective developer.