VBscript vs Jscript sometimes it pays to use Jscript

Posted Wed, Jul 20 2005 1:47 PM by Mischa Kroon

For the people using classical ASP there have been 2 mayor languages: VBscript and Jscript.

One would think they offer the same performance, they don't.

One would think they offer the same features, they don't.

Personally I've been develloping in VBscript for quite some time, but sometimes it pays to use a couple of Jscript functions which don't have a VBscript equivelant.

Here's the lowdown on the performance part:
http://planet.nana.co.il/xyxyxy8/theone.htm

Points where Jscript kicks VBscripts buttocks:

Dynamic arrays more then 2x as fast.
Regexps more then 10x the speed.

There are also a lot of other things in the article about why Jscript is better according to the author.

It makes for a good read.

One of the practical examples when you would want to mix them up is sorting array's

Jscript has a built in sort method which you can overload.
Speed difference:

Array Size: 1417 Items
SortArray: 30ms (!)
VB Bubble Sort: 7090ms

Offcourse Bubble sort isn't what one would call the best performer for larger sets but still the difference is clear...
So how would you use sort:

Simple sort:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=83

Sorting with extra's:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=89

Inside the first of these 2 links is also a simple example on how to call / use Jscript from VBscript.

 

Comments

# re: VBscript vs Jscript sometimes it pays to use Jscript

Wednesday, July 20, 2005 7:30 AM by Ramon Smits

I've had some big ASP projects in the past. Most of the time we just passed page functionality to com components. This had compile advantages for errors.

We used VBScript for simple serverside functionality and JScript at the client. This way it was very clear what you were editing.

# re: VBscript vs Jscript sometimes it pays to use Jscript

Wednesday, July 20, 2005 8:37 AM by Mischa Kroon

Hmmm, I've heard that before it just seemed like too much of a hassle to work with the COM components.

Starting and stopping registering etc.

For me it was vbscript + COM when vbscript didn't have the possibility's or when COM would be a lot faster.

# re: VBscript vs Jscript sometimes it pays to use Jscript

Wednesday, July 20, 2005 2:33 PM by Erwyn van der Meer

I've used JavaScript with ASP ever since 1999. Primarily for the object oriented features that VBScript lacked at the time. One thing I sorely missed in JScript was good error handling (that was before try/catch was introduced). So once in a while I had to write a VBScript wrapper object around a COM component that raised errors to convert them to something more usable from JScript.

I managed to convince our entire Microsoft web development team of the customer I work for to switch to JScript for ASP development. We didn't produce many COM components because we found that we were more productive in JScript and performance was acceptable. IDE support was not as good as in VB6, but that was offset by not having to compile and deploy COM components.

Nowadays we do web development with ASP.NET/C#. Now we have both: great IDE support and almost no deployment issues.

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 7 and 1 and type the answer here: