JScript .NET

Source: Wikipedia, the free encyclopedia.
JScript .NET
dynamic
Platform.NET Framework
Influenced by
JScript, ECMAScript
JScript .NET
Filename extension
.js

JScript .NET is a .NET programming language developed by Microsoft.

The primary differences between JScript and JScript .NET can be summarized as follows:

Firstly, JScript is a

scripts) can be executed without the need to compile the code first. This is not the case with the JScript .NET command-line compiler, since this next-generation version relies on the .NET Common Language Runtime (CLR) for execution, which requires that the code be compiled to Common Intermediate Language (CIL), formerly called Microsoft Intermediate Language (MSIL), code before it can be run. Nevertheless, JScript .NET still provides full support for interpreting code at runtime (e.g., via the Function constructor or the eval function) and indeed the interpreter can be exposed by custom applications hosting the JScript .NET engine via the VSA[jargon
] interfaces.

Secondly, JScript has a strong foundation in Microsoft's ActiveX/COM technologies, and relies primarily on ActiveX components to provide much of its functionality (including database access via ADO, file handling, etc.), whereas JScript .NET uses the .NET Framework to provide equivalent functionality. For backwards-compatibility (or for where no .NET equivalent library exists), JScript .NET still provides full access to ActiveX objects via .NET / COM Interop using both the ActiveXObject constructor and the standard methods of the .NET Type class.

Although the .NET Framework and .NET languages such as

Visual Studio .NET. However, ASP.NET
supports JScript .NET.

Language differences

The following are prime examples of language differences between JScript .NET and other .NET languages, including comparisons.

Differences with C#

Differences with C++

e.g.:

import System;

Console.WriteLine("Hello, what's your name?");
Console.WriteLine("Type your name: ");

var _name = Console.ReadLine();

Console.WriteLine("Hello, " + _name);

Differences with Java

  • JScript .NET syntax and lexical conventions are similar to Java in that both are derived from C. JScript was originally Microsoft's implementation of ECMAScript, which is more commonly known as JavaScript, though it is unrelated to Java. Thus, users of Java and other C-derived languages will find JScript easier to learn.
  • JScript .NET allows developers to use untyped variables, and can sometimes infer their type from their usage to optimize the compiled code. On the other hand, Java requires all variables to be typed.
  • JScript .NET can add properties and methods to objects in
    run-time
    , while Java objects always conform to their declared interface.
  • JScript .NET supports
    global variables
    , something Java does not.

Differences with older versions of JScript

  • JScript .NET allows developers to declare variables and functions with type information (e.g., var x : String;), while type information for JScript's variables and functions can not be declared (e.g., var x;).
  • JScript .NET scripts are not interpreted, but executed independently. When executed, a JScript .NET application will invoke the CLR. The CLR will execute the CIL instructions without using an interpreter.
  • JScript .NET can be run without the presence of a browser or another scripting engine as the compiler can generate standalone executables and assemblies. However these still require .NET Framework to be installed in order to run.
  • JScript .NET provides access to the .NET Framework BCL (
    Base Class Library
    ), providing much more functionality.
  • JScript .NET is only available as a scripting language for ASP.NET, the technology used to generate web pages; thus, JScript .NET takes a similar role to PHP and other server-side scripting languages. Internet Explorer, however, is still using only the older JScript engine, so JScript.NET cannot be used to script web pages (or HTAs or HTCs). In this regard, JScript is much more versatile than JScript .NET.

See also

Notes

References