Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBScript vs. JScript for ASP

2 views
Skip to first unread message

David Hunter

unread,
Jul 22, 1998, 3:00:00 AM7/22/98
to
This is just a matter of curiosity for me, but are there any reasons for
using VBScript vs. JScript for server-side ASP code, besides programmer
preference? It's important to code in a language that you're comfortable
in, but supposing you were comfortable in VBScript AND JScript, is there any
reason to use one instead of the other? (We currently do all of our
server-side ASP scripting in VBScript, and all of our client-side scripting
in JavaScript.)

I have heard some people on this group say that they use VBScript for their
server-side scripts because of the On Error... functionality, which is
currently missing from JScript, and that's a pretty good reason, I think.
Are there any others? Has anyone tested VBScript vs. JScript for speed
differences between the two scripting engines?

--
David Hunter
Solutions Architect
dav...@mediaserv.com
MediaServ Information Architects


Aaron Bertrand

unread,
Jul 22, 1998, 3:00:00 AM7/22/98
to
Error handling is my big plus - JScript doesn't have much of that. Though
it is also very dependent on what most references and other programmers
before me have been doing. Not many use JScript, so when I was learning,
all samples handed to me were in VBScript, not JScript. One other thing,
which is a very minor issue... if you forget the @language tag, with
VBScript you're okay because it isn't necessary. With JScript it may take
you a couple of runs before you realize what's wrong. :)

I would *think* VBScript would be faster, because the whole setup (ASP/IIS)
is architected to take advantage of that language, but I haven't seen any
concrete numbers. ASP is very fast and I don't think there would be any
major difference (that a human could detect, anyway), regardless of the load
size, between the two languages.

____________________
Aaron Bertrand
"I'm quite illiterate, but I read alot." - JD Salinger


David Hunter wrote in message
<#Zwq3iZt...@uppssnewspub05.moswest.msn.net>...

Allen Strand

unread,
Jul 22, 1998, 3:00:00 AM7/22/98
to
David,

It depends on the task. I do 90% of my coding in VBScript because
it is the native language that Microsoft supports.

The other 10% -- JScript has regular expressions. These are very
powerful for checking form-input. To implement the same thing in
VBScript is a whole lot harder.

On error resume next is a bizzare concept also. You better check
for errors or you will end up with bizzare things. Hopefully Microsoft
will come up with something like the CATCH/TRY concept in C++
for errors. I would recommend that you leave On Error OFF, UNTIL you
have debugged your code. Then turn it ON with appropriate checks
to make certain you are not working on invalid data.

Allen Strand

David Hunter wrote:

> This is just a matter of curiosity for me, but are there any reasons for
> using VBScript vs. JScript for server-side ASP code, besides programmer
> preference? It's important to code in a language that you're comfortable
> in, but supposing you were comfortable in VBScript AND JScript, is there any
> reason to use one instead of the other? (We currently do all of our
> server-side ASP scripting in VBScript, and all of our client-side scripting
> in JavaScript.)
>
> I have heard some people on this group say that they use VBScript for their
> server-side scripts because of the On Error... functionality, which is
> currently missing from JScript, and that's a pretty good reason, I think.
> Are there any others? Has anyone tested VBScript vs. JScript for speed
> differences between the two scripting engines?
>

Richard

unread,
Jul 23, 1998, 3:00:00 AM7/23/98
to
Use VBScript for the following reasons:

1 - IIS 4.0 optomizes VBs and does not for Js
2 - VBs has all sorts of functions that you will have to write yourself if
using Js: even simple ones are missing in JScript like: trim(),
formatDate(), formatCurrency()
3 - the FOR EACH command in Jscript is broken (or missing)
4 - some ADO functions only work for VBs
5 - you can turn VBScript objects into DLLs if necessary

When .ASP first came out we used JScript because we were familiar with C and
wanted to use the same language for both client side and server side
programming. We have then since learned the errors of our ways and now do
all server side stuff in VBScript. HOWEVER we have stuck with JScript for
client side as brand X browsers don't support VBs.

Chears,
Richard


David Hunter wrote in message
<#Zwq3iZt...@uppssnewspub05.moswest.msn.net>...

WebSlinger

unread,
Jul 23, 1998, 3:00:00 AM7/23/98
to
I've had just the opposite experience. I started out doing all my asp's in
vbscript then switched and started writing all my new ones in JScript.
Eventually I went back and rewrote the old ones in JScript as well. I
haven't noticed any performance degradation but I'm certainly interested in
your claim, can you point me to any url's describing any IIS optimizations
for vbs. I would seem to me that the script engine would be a pluggable
component that the server supports as a "black box". If you've downloaded
5.0 of the JScript engine you should have try{}/catch{} style exception
handling that's much nicer than the vbs "on error resume next" type of
thing. I haven't been missing any of the vbs functions, you can do trim()
with JScripts replace... JScript has a for in that's similar to the vbs for
each, just have to use enumerations instead of collections. How would you
turn a vbs object into a dll?

The big gain is that < 505 of the browser market share runs vbs so you
really need to use JScript for the client. It's much nicer to just
consistently use one script language for both the server and client side
scripts, especially in environments like asp where you'll typically have
server and client side script within the same text file...

Richard <rich...@cavucorp.nospam.com> wrote in message
OYojIri...@uppssnewspub04.moswest.msn.net...

fred

unread,
Jul 23, 1998, 3:00:00 AM7/23/98
to
I still think both scripting languages are important. First Microsoft use
JScript heavily in
their ASP pages inlcuded with Site Server Commerce Edition so I wouldn't
favour the speed
argument. Also Microsoft has indicated that ECMA script is the way forward
and this is more heavily based on JScript and will run on both browsers.

Gerry Whelan

Aaron Bertrand <abertrandATwaterworksiaDOTcom> wrote in article
<OWFSUka...@uppssnewspub05.moswest.msn.net>...

Matty F

unread,
Jul 24, 1998, 3:00:00 AM7/24/98
to
Well, i'm not an experienced ASP programmer, but i started out using
VBScript for the simple reason that nearly all the examples that are given
(as far as i could see) were in VBs. Personally, now i know more about ASP,
i would choose JScript because i'm more comfortable with its syntax etc..
etc.. (i'm really a C++/Java programmer) although i don't know anything
about its running speed

Out of interest, does anyone know if it has to be MS JScript or can it be
straight JavaScript? - i'm a bit fuzzy on the differences to these two
scripting languages so...

Cheers

Matt

Matty F

unread,
Jul 24, 1998, 3:00:00 AM7/24/98
to
Oops, sorry, my clock was wrong, this was effectively posted 5 days before
the original post!

zane_...@yahoo.com

unread,
Jul 24, 1998, 3:00:00 AM7/24/98
to
In article <OYojIri...@uppssnewspub04.moswest.msn.net>,

"Richard" <rich...@cavucorp.nospam.com> wrote:
> Use VBScript for the following reasons:
>
> 1 - IIS 4.0 optomizes VBs and does not for Js

Sounds like a new variation of the old "IIS is optimized for IE" joke. Prove
it. (If this is so, why are all of the examples included in VI6 in JScript?)

> 2 - VBs has all sorts of functions that you will have to write yourself if
> using Js: even simple ones are missing in JScript like: trim(),
> formatDate(), formatCurrency()

As another person remarked - I haven't missed them. JS also has better ways
of doing some things.

> 3 - the FOR EACH command in Jscript is broken (or missing)

Look again - for ... in ...

> 4 - some ADO functions only work for VBs

Haven't had this problem ... example?

> 5 - you can turn VBScript objects into DLLs if necessary

If you're talking about cut-n-paste to VB, this is true (sort of...well, not
really.) However, you can take either one and use them to write scriptlets.
(And calling anything a "VBScript object" is ridiculous.)

zane

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

Richard

unread,
Jul 26, 1998, 3:00:00 AM7/26/98
to
I like your response, and you have some good points. I agree that only using
one language would be the way to go. Also us old C language programmers are
much more at home with JScript than VBS.

Maybe you could help me.

How are you doing trim using the replace? maybe I am missing something, but
my VID 1.0 documentation for JScript, I can not find a "replace" command.
Is it listed under a different name? Also could you show me how to
eleminate leading & trailing spaces from a request( field ) without
effecting any spaces in the middle of the text string.

What function do you use to format currency? Our database has a lot of
monitiary rows which are stored in SQL as real numbers. We need to out them
with commas, a decimal point, and two decimals.

What are you using to manipulate SQL date fields for IIS 3.0. We could not
get the following JScript to work with IIS 3.0, BUT IT WORKS WITH IIS 4.0
(or could the fix have been one of the hot fixes applied to our server?).
We need this for IIS 3.0 as that is what MS ships with Small Bus.
var dateMod
dateMod = RS("dateModified")
Response.Write( '<td valign="top" >' + dateMod + "&nbsp;</td>" )

Turning VB Objects into .dlls ->. We wrote a large amount of functions, and
which we shared across ASP pages with include statements. we took the
include files and compiled them under VB5 into .dll and now link to the
utility functions as an methods of an object. example:
dim str
was:
str = str & SQLNumber( request("quantity") )
is now in dll for performance reasons:
str = utilFunctions.SQLNumber( request("quantity") )

We could not get this to work in JScript, hopefully you can show me how to
do it right.
var varx;
for( varx in Session.Contents )
Response.write( varx + ":" + Session.Contents(varx) + "<BR>" ) ;

This is how it works in VBS.
dim item
For Each item in Session.Contents
Response.write( "<p>" & item & ":" & Session.Contents(item) & "</p>")
Next

Thanks for your assistance
Richard


WebSlinger wrote in message ...


>I've had just the opposite experience. I started out doing all my asp's in
>vbscript then switched and started writing all my new ones in JScript.
>Eventually I went back and rewrote the old ones in JScript as well. I
>haven't noticed any performance degradation but I'm certainly interested in
>your claim, can you point me to any url's describing any IIS optimizations
>for vbs. I would seem to me that the script engine would be a pluggable
>component that the server supports as a "black box". If you've downloaded
>5.0 of the JScript engine you should have try{}/catch{} style exception
>handling that's much nicer than the vbs "on error resume next" type of
>thing. I haven't been missing any of the vbs functions, you can do trim()
>with JScripts replace... JScript has a for in that's similar to the vbs
for
>each, just have to use enumerations instead of collections. How would you
>turn a vbs object into a dll?
>
>The big gain is that < 505 of the browser market share runs vbs so you
>really need to use JScript for the client. It's much nicer to just
>consistently use one script language for both the server and client side
>scripts, especially in environments like asp where you'll typically have
>server and client side script within the same text file...
>
>Richard <rich...@cavucorp.nospam.com> wrote in message
>OYojIri...@uppssnewspub04.moswest.msn.net...

>>Use VBScript for the following reasons:
>>
>>1 - IIS 4.0 optomizes VBs and does not for Js

>>2 - VBs has all sorts of functions that you will have to write yourself if
>>using Js: even simple ones are missing in JScript like: trim(),
>>formatDate(), formatCurrency()

>>3 - the FOR EACH command in Jscript is broken (or missing)

>>4 - some ADO functions only work for VBs

>>5 - you can turn VBScript objects into DLLs if necessary
>>

>>When .ASP first came out we used JScript because we were familiar with C
>and
>>wanted to use the same language for both client side and server side
>>programming. We have then since learned the errors of our ways and now do
>>all server side stuff in VBScript. HOWEVER we have stuck with JScript for
>>client side as brand X browsers don't support VBs.
>>
>>Chears,
>>Richard
>>
>>

Richard

unread,
Jul 26, 1998, 3:00:00 AM7/26/98
to
Oh, I almost forgot. Per your request here is a link to a web site that
will give you full instructions about easily converting VBScript into a .dll
for rapid execution.

http://tor-pw1.netcom.ca/~kbwcs/dll.html

zane_...@my-dejanews.com

unread,
Jul 27, 1998, 3:00:00 AM7/27/98
to
I didn't write the note to which Richard replies, but I may be able to help.
(I did write a message that was perhaps a bit more vitriolic - I apologize,
and offer, perhaps, some help.)

In article <uEDULbG...@uppssnewspub04.moswest.msn.net>,
"Richard" <rich...@cavucorp.nospam.com> wrote:

<snip>

> How are you doing trim using the replace? maybe I am missing something, but
> my VID 1.0 documentation for JScript, I can not find a "replace" command.
> Is it listed under a different name? Also could you show me how to
> eleminate leading & trailing spaces from a request( field ) without
> effecting any spaces in the middle of the text string.

'replace' shows up in JScript 3, as a method of the String object. Version 3
also supports regular expressions (which in my opinion is a big advantage over
VBS), so you can do something like yourString.replace(/^ +| +$/,"") to trim a
string. My syntax may not be 100% correct, but you get the idea. You can get
the Version 3 scripting engines from www.microsoft.com/scripting (as well as
version 5, which adds try ... catch!)

> What function do you use to format currency? Our database has a lot of
> monitiary rows which are stored in SQL as real numbers. We need to out them
> with commas, a decimal point, and two decimals.

There is no equivalent in JS that will use the values specified in the Control
Panel. However, it wouldn't be too difficult to write a short function to
format the number to your local format, after converting it to a String.

> What are you using to manipulate SQL date fields for IIS 3.0. We could not
> get the following JScript to work with IIS 3.0, BUT IT WORKS WITH IIS 4.0
> (or could the fix have been one of the hot fixes applied to our server?).
> We need this for IIS 3.0 as that is what MS ships with Small Bus.
> var dateMod
> dateMod = RS("dateModified")
> Response.Write( '<td valign="top" >' + dateMod + "&nbsp;</td>" )

What is dateMod? Date object? If so, Response.Write('<td valign="top">' +
dateMod.toLocaleString() + '&nbsp;</td>'). If it's already a string, does it
make a difference if you change the "&nbsp;</td>" to '&nbsp;</td>'? Or is it
not retrieving any value at all?

> Turning VB Objects into .dlls ->. We wrote a large amount of functions, and
> which we shared across ASP pages with include statements. we took the
> include files and compiled them under VB5 into .dll and now link to the
> utility functions as an methods of an object. example:
> dim str
> was:
> str = str & SQLNumber( request("quantity") )
> is now in dll for performance reasons:
> str = utilFunctions.SQLNumber( request("quantity") )

Yes, you can in some cases cut'n'paste VBScript into VB5 (although VB is
missing some VBS functions, such as split and replace.) In your earlier
post, I thought you were suggesting that you could create robust business
objects in this manner. One interesting option that I mentioned earlier -
server-side scriptlets, which you can implement in any ActiveX scripting
language, including VBS, JS, Perl, etc.

> We could not get this to work in JScript, hopefully you can show me how to
> do it right.
> var varx;
> for( varx in Session.Contents )
> Response.write( varx + ":" + Session.Contents(varx) + "<BR>" ) ;
>
> This is how it works in VBS.
> dim item
> For Each item in Session.Contents
> Response.write( "<p>" & item & ":" & Session.Contents(item) & "</p>")
> Next
>

(The following is summarized from a MS faq)
In VB, For Each ... In ... enumerates the members of a collection, while the
JScript for (... in ...) loop enumerates the members of a JScript object:

To enumerate the items in a collection, use the Enumerator object:

for ( var myenum = new Enumerator(myCollection) ; !myenum.atEnd() ;
myenum.moveNext() )
document.write(myenum.item());

Enumerator objects are considerably more flexible than for-each-in loops.
Several enumerators can be declared at the same time for each collection,
enumerators can be passed around as data, they can be reset to the beginning
at any time, etc.

zane
&#137;

Richard

unread,
Jul 28, 1998, 3:00:00 AM7/28/98
to
thanks for your user friendly response (apology accepted).

You have provided me a number of good points.
1 - I was living in the initial VBS and JScript world of IIS 3.0 (script
engine version 1.0??), in which VBS has much more functionality that JS
(less bugs also). I AM NOW AWAKE. I did find that the JS problem with SQL
dates was fixed in the ASP shipped with IIS 4.0.
2 - your link to www.microsoft.com/scripting was very helpful.
3 - I need to spend less time writing web applications and more time
learning. BUT that leads to an interesting question, of when does one slow
down the learning so they can be doing? GRIN...

Could you decrypt the parameters of your statement: - yourString.replace(/^
+| +$/,"")

Thanks again.

zane_...@my-dejanews.com wrote in message
<6ph3oj$agv$1...@nnrp1.dejanews.com>...


>I didn't write the note to which Richard replies, but I may be able to
help.
>(I did write a message that was perhaps a bit more vitriolic - I apologize,
>and offer, perhaps, some help.)
>
>In article <uEDULbG...@uppssnewspub04.moswest.msn.net>,
> "Richard" <rich...@cavucorp.nospam.com> wrote:
>
><snip>
>

>> How are you doing trim using the replace? maybe I am missing something,
but
>> my VID 1.0 documentation for JScript, I can not find a "replace" command.
>> Is it listed under a different name? Also could you show me how to
>> eleminate leading & trailing spaces from a request( field ) without
>> effecting any spaces in the middle of the text string.
>

>'replace' shows up in JScript 3, as a method of the String object. Version
3
>also supports regular expressions (which in my opinion is a big advantage
over
>VBS), so you can do something like yourString.replace(/^ +| +$/,"") to trim
a
>string. My syntax may not be 100% correct, but you get the idea. You can
get
>the Version 3 scripting engines from www.microsoft.com/scripting (as well
as
>version 5, which adds try ... catch!)
>

>> What function do you use to format currency? Our database has a lot of
>> monitiary rows which are stored in SQL as real numbers. We need to out
them
>> with commas, a decimal point, and two decimals.
>

>There is no equivalent in JS that will use the values specified in the
Control
>Panel. However, it wouldn't be too difficult to write a short function to
>format the number to your local format, after converting it to a String.
>

>> What are you using to manipulate SQL date fields for IIS 3.0. We could
not
>> get the following JScript to work with IIS 3.0, BUT IT WORKS WITH IIS 4.0
>> (or could the fix have been one of the hot fixes applied to our server?).
>> We need this for IIS 3.0 as that is what MS ships with Small Bus.
>> var dateMod
>> dateMod = RS("dateModified")
>> Response.Write( '<td valign="top" >' + dateMod + "&nbsp;</td>" )
>

>What is dateMod? Date object? If so, Response.Write('<td valign="top">' +
>dateMod.toLocaleString() + '&nbsp;</td>'). If it's already a string, does
it
>make a difference if you change the "&nbsp;</td>" to '&nbsp;</td>'? Or is
it
>not retrieving any value at all?
>

>> Turning VB Objects into .dlls ->. We wrote a large amount of functions,
and
>> which we shared across ASP pages with include statements. we took the
>> include files and compiled them under VB5 into .dll and now link to the
>> utility functions as an methods of an object. example:
>> dim str
>> was:
>> str = str & SQLNumber( request("quantity") )
>> is now in dll for performance reasons:
>> str = utilFunctions.SQLNumber( request("quantity") )
>

>Yes, you can in some cases cut'n'paste VBScript into VB5 (although VB is
>missing some VBS functions, such as split and replace.) In your earlier
>post, I thought you were suggesting that you could create robust business
>objects in this manner. One interesting option that I mentioned earlier -
>server-side scriptlets, which you can implement in any ActiveX scripting
>language, including VBS, JS, Perl, etc.
>

>> We could not get this to work in JScript, hopefully you can show me how
to
>> do it right.
>> var varx;
>> for( varx in Session.Contents )
>> Response.write( varx + ":" + Session.Contents(varx) + "<BR>" ) ;
>>
>> This is how it works in VBS.
>> dim item
>> For Each item in Session.Contents
>> Response.write( "<p>" & item & ":" & Session.Contents(item) & "</p>")
>> Next
>>
>

zane_...@yahoo.com

unread,
Jul 29, 1998, 3:00:00 AM7/29/98
to
In article <#S3CTcgu...@uppssnewspub04.moswest.msn.net>,

"Richard" <rich...@cavucorp.nospam.com> wrote:
> thanks for your user friendly response (apology accepted).
>
> You have provided me a number of good points.
> 1 - I was living in the initial VBS and JScript world of IIS 3.0 (script
> engine version 1.0??), in which VBS has much more functionality that JS
> (less bugs also). I AM NOW AWAKE. I did find that the JS problem with SQL
> dates was fixed in the ASP shipped with IIS 4.0.

IIS4 shipped with the V3 scripting engines - maybe they fixed that particular
problem.

> 2 - your link to www.microsoft.com/scripting was very helpful.
> 3 - I need to spend less time writing web applications and more time
> learning. BUT that leads to an interesting question, of when does one slow
> down the learning so they can be doing? GRIN...

Doing's no fun, if it doesn't involve learning!

> Could you decrypt the parameters of your statement: - yourString.replace(/^
> +| +$/,"")

I said I might not have the syntax right - I left out a 'g' -
yourString.replace(/^ +| +$/g,"")

replace takes the following syntax -
stringObj.replace(rgExp, replaceText)

This particular regular expression =
/ = regexp delimiter (start)
^ = Matches the beginning of input or line
= (space)
+ = Matches the preceding character one or more times
| = or
= (space)
+ = Matches the preceding character one or more times
$ = Matches the end of input or line
/ = regexp delimiter (end)
g = global search for all occurrences of pattern

In other words, this looks for one or more spaces at the beginning or end of
the input, and replaces them with "".

See the JScript (or Perl, etc.) documentation for complete regular expression
syntax.

Jeff McCrory

unread,
Jul 29, 1998, 3:00:00 AM7/29/98
to
Since ASP is a microsoft thingy a would guess it would have to be MS
JScript. Have you seen MS J++ Version 6 ? Its really taking the
fucking mickey, They've given Java its own Windows MFC library, I
thought Java was supposed to be platform independant ????

Matty F

unread,
Jul 29, 1998, 3:00:00 AM7/29/98
to
Long time no see Jeff, how's tricks?


Jeff McCrory wrote in message <35bee176....@news.dial.pipex.com>...

Scott Willsey

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
Allen Strand <ast...@ix.netcom.com> wrote in message
35B66518...@ix.netcom.com...


>
>On error resume next is a bizzare concept also. You better check
>for errors or you will end up with bizzare things. Hopefully Microsoft
>will come up with something like the CATCH/TRY concept in C++
>for errors. I would recommend that you leave On Error OFF, UNTIL you
>have debugged your code. Then turn it ON with appropriate checks
>to make certain you are not working on invalid data.
>


The Aug 1998, Vol 8 No. 9 issue of Visual Basic Programmer's Journal has an
interesting article about improving Asp error handling using vb components.

Page 101, check it out.

Scott

......................................................................
Please edit the email address to reply

Scott Willsey

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
WebSlinger <incomm...@bigfoot.com> wrote in message
OtC9Uhl...@uppssnewspub05.moswest.msn.net...

>The big gain is that < 505 of the browser market share runs vbs so you
>really need to use JScript for the client. It's much nicer to just
>consistently use one script language for both the server and client side
>scripts, especially in environments like asp where you'll typically have
>server and client side script within the same text file...
>

Actually, one of the nice things about using javascript for the client and
vbscript (or perlscript, or whatever) for the server-side code is that other
programmers reading your code (or you re-reading your code months later) can
immediately see what is being executed where. It really helps seperate
itself out a litte more than just looking for the <% %> symbols.

0 new messages