ASP Server Side scripting languages?

Status
Not open for further replies.

indigo

Well-known member
5,606
I use vb-script. I know... everyone hates it.

With the pending release of the .NET servers, and needing to learn XML, and still working with basically ASP2.0 features for the most part, I figure now is as good a time as any to make the move to a new server side scripting language if there's a compelling reason to.

Is JScript a good substitute for vbscript?

Keep in mind, my focus is Microsoft. I know that's not everyone's cup o' tea, but I like Visual Studio, I like Active Directory, and I like the web side of IIS. I'm not going to consider Perl or anything that isn't natively supported in IIS.

So... AFAIK, it's vbscript or jscript. Any other options? Which do you prefer and why? I want to set myself up now for the next few years, as I've been able to with ASP2. I'm not really dissatisfied with what I can do right now, but I figure I can get started now on the new stuff, so I don't get leapfrogged too much by web applications that take more advantage of the newer technologies...
 
VBScript is hardly a substitue for javascript.

Admittedly it may have caught up feature-wise somewhat in recent versions, but it is still slower.

In fact though, until around the scripting version 5 or so, you had to use both to get everything you needed - vbscript didn't have objects, or regexps, and jscript _still_ doesn't have a way of creating a safearray, or dynamically typing a com object. In very early versions it didn't even have exception handling.

I ususally do everything in jscript, but have a couple of vbscript wrappers for creating arrays and doing typeof.
 

martin007

Ars Tribunus Militum
2,783
Originally posted by hanser:
Why?

Good question.

As pdampier said, with .NET you have a whole range of languages to choose from.

IMO, choosing VB is kinda flaky because you have such better alternatives. Using C#, for instance, will mean that you can *easily* switch to other OO languages in the future (ie Java)

I'd love to know if anyone has any reasons to use VB.NET; I sure don't see any.
 

russ-iha

Ars Praefectus
4,407
Subscriptor
VB.NET can do anything C# can do (except drop into unmanaged code. You can lock down objects in VB.NET and pass them to the win32 api, etc, but you can't write actual unsafe segments)

It is also just as object-oriented. Inheritance, polymorphism, overloading.

It supports free threading. It can provide classes for other .NET languages to consume, and can use any class exposed by any other language in the. NET framework.

Please explain what is so great about C# that I should choose it over VB.NET?
 

bash666

Ars Legatus Legionis
24,417
Originally posted by russ-iha:
VB.NET can do anything C# can do (except drop into unmanaged code. You can lock down objects in VB.NET and pass them to the win32 api, etc, but you can't write actual unsafe segments)

It is also just as object-oriented. Inheritance, polymorphism, overloading.

It supports free threading. It can provide classes for other .NET languages to consume, and can use any class exposed by any other language in the. NET framework.

Please explain what is so great about C# that I should choose it over VB.NET?

No DIM :D

Seriously if you knwo VB and are willing to learn teh diffs with VB.NET, good. But if you know anyother common language9C,C++,Java), C# is almost certain to be closer and easier to learn.
 

indigo

Well-known member
5,606
Harder to maintain no?

I kinda like the fact that I can open up even notepad, and fix some little oversight (read:bug :) ), in my code...

For instance:

"(record1.value = this or record1.value = that) and "
"(record2.value = this or record2.value = that)"

Was something I ran into recently... this means record1.this & record2.this is legit, when really it's not what I wanted. So I open it up, and:

"(record1.value = this and record2.value = that) or"
"(record1.value = that and record2.value = this)"

More like it...

I really have very little experience with "real" compiled languages though... I mean, I used Borland C 2.0 many moons ago, but otherwise. ;)

Besides, page-compile-time and page performance, is never a worry, it's bandwidth and db performance, so?

I'm curious anyways... I think for now, I'll just try to dig into jscript though... Thanks for the help.

but think how bad it would be if it had to recompile each time the page was accessed

Aren't they cached?
 

pdampier

Ars Legatus Legionis
16,955
I'd love to know if anyone has any reasons to use VB.NET; I sure don't see any.

If you know VB using VB.NET is relatively easy. Moving to C# is significantly more work for very little (if any for most apps) gain.

Stick with what you like - Thats the benefit with .NET.

Why would I want to use a compiled language on my webpage?

1. Speed.
2. Code behind - remove code/script logic from the HTML completely.
3. Compiled code allows you to verify syntax is at least correct on compile - rather than having to execute the script only to find a syntax error.


Cafedirect moved from a J2EE web site to compiled ASP.NET and found,

'We had 5 dual processor machines that have now been converted to one machine. There's no way we could have done that with Java.' says Durham. 'The performance increase after moving to the .NET Framework was unbelievable. The machines used to run at about 50-70% utilization and now run at about 2-3%. I have never heard of such an increase in performance.'

http://www.microsoft.com/presspass/events/pdc01/doc/cafepress.doc

Side issue: VBScript (different in .NET pages with VB.NET since you have the stringbuilder class) is slow with string manipulation... There are ways to code round that though its not so much the string manipulation but the allocation of strings that is slow. Minimize the number of allocations/re-allocations and its fast.
 

pdampier

Ars Legatus Legionis
16,955
Isn't that the whole point of scripting vs. compiled? Am I so far gone that now compiled languages are no longer pre-compiled? It sounds more like a cached interpreted language?

It is a JIT compiler. If it notices the file has been changed (eg you drop a new version of the source there) it will recomipile the code before execution.

You can also set directories to pre-compile code in the "normal" manner of which you are thinking. They will still 'recompile' it if they notice you've dropped a new version in though. (if I recall right)

So initially when a page "compiles" there is a pause in execution. With the "pre-compile" option there is not. However the pause only happens once on the web site so subsequent users do not repeatedly hit that pause.
 

indigo

Well-known member
5,606
Well that certainly sounds cool...

Isn't "real" coding alot harder than scripting though? I'm not really sure I understand the communication between the two (the page and the compiled code). In fact, I know I don't...

In an ASP page, I can say:

code:<HR>
Code:
<td>Hello <%=rsUsers("FirstName")%>!</td>

How does my JIT compiled code (and thanks for clearing up JIT for me), interject itself into the HTML like that?

I guess my biggest failing is I just know how to make stuff work with vbscript. ;) I couldn't tell you if the above is an ADO thing, (other than it being a recordset), a vbscript thing, or whatever...

Actually... it's an ADO thing right? Since "=value" is the same as Response.Write(value) and Response.Write is ADO right?

I'm embarrased to be showing off how little I know... :oops:
 

martin007

Ars Tribunus Militum
2,783
Originally posted by pdampier:
Quote: "Why would I want to use a compiled language on my webpage? "

1. Speed.
2. Code behind - remove code/script logic from the HTML completely.
3. Compiled code allows you to verify syntax is at least correct on compile - rather than having to execute the script only to find a syntax error.

Probably a good thing to add here is

4. Source code security (!!)

If you know VB using VB.NET is relatively easy. Moving to C# is significantly more work for very little (if any for most apps) gain.

Good point.

On a side note, is there any performance difference putting code in a pre-compiled component or just in the <script runat="server"> tag of the web form? I'd imagine there isn't, but I could be wrong.
 

MrMills

Ars Praefectus
3,727
Moderator
indigo,

Each page is probably converted entirely into the compiled version. In effect, your source code

<td>Hello <%=rsUsers("FirstName")%>!</td>

would be converted into

Response.Write "<td>Hello "
Response.Write rsUsers("FirstName")
Response.Write "!</td>"

and then compiled.

Whenever a page is requested and IIS notes that the source is newer than the compiled version, it compiles the page again. Like make, if you're familiar with that.
 
Originally posted by MrMills:
<td>Hello <%=rsUsers("FirstName")%>!</td>

Just to add to MrMills point, the above syntax is still correct and useable with ASP.NET.

I use C# for my ASP.NET pages, although I have used Perl in small parts when I felt like it. IMHO, VB.NET makes a great language for ASP.NET pages, because, for once, END IF and LOOP, etc, are much more readable than seemingly random }'s in complex pages.

For example, I had an "expected }" error the other day in a very complex C# bases ASP page. It took a while to figure out where exactly the missing } was supposed to go, due to the large amount of HTML code mixed in with C# code.

Since all .NET programs have access to the same framework, the language itself is more a matter of taste or preference. I happen to prefer C#.
 

indigo

Well-known member
5,606
Thanks for the help. However, wouldn't what you described basically suck<sup>TM</sup>? ;)

I mean, I would assume a compiled language is a bit slower than a scripting language to compile, and atleast 75% of my work is dynamic in nature... rsUsers("FirstName") could be "Fred", or "Jim", or "Gargamel"...

I mean, when you visit contracts.asp, chances are, you aren't viewing the same document that was served from the same page before... so... recompile?
 

bash666

Ars Legatus Legionis
24,417
I mean, when you visit contracts.asp, chances are, you aren't viewing the same document that was served from the same page before... so... recompile?

No. Different variables don't require a recomile, only changed code. Once you UL you new page, ASP.NET sees it's different(don't know how, maybe SHA1 or something, hopefully not date, time and size) and it recompiles it. You page is then turned into MSIL(bytecode), and the MSIL is turned into native code. You're you're going to tell me native code is slower than a parsed script?

-Kevin
 

pdampier

Ars Legatus Legionis
16,955
indigo: It doesn't work how you're thinking...

Have a read of:

http://www.4guysfromrolla.com/webtech/051801-1.shtml

http://www.4guysfromrolla.com/webtech/100500-1.shtml

http://www.wintellect.com/resources/faqs/default.asp?faq_id=1

I think that will help clarify things for you?

Bascially your source code has not changed for printing that users name to the screen. Merely your input variable to the code (ie the user name) so no recompile is needed.
 
Status
Not open for further replies.