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.