JScript .NET: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>ScrabbleTiles
Restored revision 1230271721 by Boleyn (talk): LLM Misuse
 
imported>Jerryobject
WP:LINK add.
 
Line 1: Line 1:
{{short description|Programming language developed by Microsoft}}
{{Short description|Programming language developed by Microsoft}}
{{multiple issues|
{{Multiple issues|
{{original research|date=November 2013}}
{{No footnotes|date=November 2013}}
{{inline|date=November 2013}}
{{Update|date=June 2015}}
{{update|date=June 2015}}
}}
}}
{{Infobox programming language
{{Infobox programming language
| name                   = JScript .NET
| name = JScript .NET
| paradigm              = [[multi-paradigm]]
| paradigms = [[Comparison of multi-paradigm programming languages|Multi-paradigm]]: [[Object-oriented programming|object-oriented]] ([[Prototype-based programming|prototype-based]]), [[Functional programming|functional]], [[Imperative programming|imperative]], [[Scripting language|scripting]]
| generation            =
| family = [[ECMAScript]]
| year                  =  
| designer =  
| designer               =  
| developer = [[Microsoft|Microsoft Corporation]]
| developer             = [[Microsoft|Microsoft Corporation]]
| released = <!-- {{Start date and age|20yy}} -->
| latest release version =  
| latest release version =  
| latest release date   =  
| latest release date =  
| typing                 = [[duck typing|duck]], [[weak typing|weak]], [[dynamic typing|dynamic]]
| typing = [[Duck typing|duck]], [[Strong and weak typing|weak]], [[Dynamic typing|dynamic]]
| implementations        =  
| scope = [[Scope (computer science)|lexical]]
| dialects              =  
| platform = [[.NET]] framework
| influenced_by          = [[JScript]], [[ECMAScript]]
| operating system = [[Microsoft Windows]]
| influenced            =  
| license = [[Proprietary software|proprietary]]
| platform              = [[.NET Framework]]
| file ext = .js
| file format = JScript .NET
| website = <!-- {{URL|www.example.com}} -->
| implementations =
| dialects =  
| influenced by = [[JavaScript]], [[JScript]], [[ECMAScript]]
| influenced =
}}
}}
{{Infobox file format
'''JScript .NET''' is a [[.NET]] framework [[programming language]] developed by [[Microsoft]] as [[proprietary software]].
| name      = JScript .NET
| extension = .js
| mime      =
}}
'''JScript .NET''' is a [[.NET Framework|.NET]] [[programming language]] developed by [[Microsoft]].


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


Firstly, JScript is a [[Script (computer programming)|script]]ing language, and as such [[computer program|programs]] (or more suggestively, [[Script (computer programming)|script]]s) 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 <code>Function</code> constructor or the <code>[[eval#JavaScript|eval]]</code> function) and indeed the interpreter can be exposed by custom applications hosting the JScript .NET engine via the VSA{{Technical statement|reason=more on VSA interfaces|date=February 2012}} interfaces.
Firstly, JScript is a [[scripting language]], and as such, [[computer program|programs]] (or more suggestively, scripts) can be executed with no need to [[Compiler|compile]] the code before. This is not the case with the JScript .NET [[command-line interface]] 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 named Microsoft Intermediate Language (MSIL), code before it can be run. Nevertheless, JScript .NET still fully supports [[Interpreter (computing)|interpreting]] [[source code]] at [[Execution (computing)#Runtime|runtime]] (e.g., via the <code>Function</code> constructor or the <code>[[eval#JavaScript|eval]]</code> function) and indeed the interpreter can be exposed by custom applications hosting the JScript .NET engine via the VSA{{Technical inline|reason=more on VSA interfaces|date=February 2012}} interfaces.


Secondly, JScript has a strong foundation in Microsoft's [[ActiveX]]/[[Component Object Model|COM]] technologies, and relies primarily on ActiveX components to provide much of its functionality (including database access via [[ActiveX Data Objects|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.
Secondly, JScript has a strong foundation in Microsoft's [[ActiveX]] and [[Component Object Model]] (COM) technologies, and relies mainly on ActiveX components to provide much of its function (including database access via [[ActiveX Data Objects]] (ADO), file handling, etc.), whereas JScript .NET uses the [[.NET]] framework to provide equivalent function. For backward-compatibility (or for where no .NET equivalent library exists), JScript .NET still provides full access to ActiveX objects via .NET and [[COM Interop]] using both the ActiveXObject constructor and the standard methods of the .NET <code>Type</code> class.


Although the .NET Framework and .NET languages such as [[C Sharp (programming language)|C#]] and [[Visual Basic .NET]] have seen widespread adoption, JScript .NET has never received much attention, by the media or by developers. It is not supported in Microsoft's premier development tool, [[Visual Studio .NET]]. However, [[ASP.NET]] supports JScript .NET.
Although the .NET framework and languages such as [[C Sharp (programming language)|C#]] and [[Visual Basic (.NET)]] have been adopted widely, JScript .NET has received little attention, from the media and developers. It is not supported in Microsoft's premier development tool, [[Visual Studio .NET]]. However, [[ASP.NET]] supports JScript .NET.


== Language differences ==
== Language differences ==
Line 40: Line 40:


=== Differences with C# ===
=== Differences with C# ===
* JScript .NET does not require a [[Main function (programming)|main()]] [[function (programming)|function]] that the operating system must call directly when executing a JScript .NET application, as such, JScript .NET program flow can be based on global code.
* JScript .NET does not require an [[entry point]] ({{Mono|main()}} [[Function (computer programming)|function]]) that an [[operating system]] must call directly when executing a JScript .NET application, as such, JScript .NET program [[control flow]] can be based on global code.
* JScript .NET, because of its very loose type checking system can be very easy to learn, since the convention of explicit type declaration is not required at all.
* JScript .NET, because of its very loose [[data type]] checking system, can be easier to learn, since the common convention of [[Declaration (computer programming)|declaring]] types explicitly is unneeded.
* JScript .NET does not require explicit references to the .NET Framework Base Class Library, as certain functions found in earlier versions of JScript are present in JScript .NET (e.g. functions for finding the [[Trigonometric function|tangent]] of an angle for a [[right triangle]]).
* JScript .NET does not require explicit references to the .NET framework Base Class Library, as certain functions found in earlier versions of JScript are present in JScript .NET (e.g., functions for finding the [[Trigonometric function|tangent]] of an angle for a [[right triangle]]).
* JScript .NET is closely linked to [[C syntax]], and is thus very easy to learn for [[C Sharp (programming language)|C#]], [[Java (programming language)|Java]] or [[C++]] developers.
* JScript .NET is closely linked to [[C syntax]], and is thus easy to learn for [[C Sharp (programming language)|C#]], [[Java (programming language)|Java]], or [[C++]] developers.
* While JScript .NET can be used to create Windows Forms applications, JScript .NET will have some trouble, as delegates can only be consumed in JScript .NET and not created. Thus, custom events are hard to emulate in JScript .NET.
* While JScript .NET can be used to create Windows Forms applications, it can have some trouble, as delegates can only be consumed in JScript .NET and not created. Thus, custom events are hard to emulate in JScript .NET.


=== Differences with C++ ===
=== Differences with C++ ===
* JScript .NET does not require a [[Main function (programming)|main()]] [[function (programming)|function]].
* JScript .NET does not need a {{Mono|[[entry point|main()]]}} [[Function (computer programming)|function]].
* JScript .NET does not require explicit [[type declaration]] on variables. (In [[C++]], the use of templates and generics can be compared to this, loosely emulated with template specialization, etc.)
* JScript .NET does not need explicit [[type declaration]] on variables. (In [[C++]], the use of templates and generics can be compared to this, loosely emulated with template specialization, etc.)
* JScript .NET also does not require explicit [[Type conversion|type casts]] on variable use in the program. Code used to retrieve a string of characters, but only used for integer numbers can be cast implicitly; the vice versa can be done without error at compile time, but there is a chance of loss of precision or data.
* JScript .NET does not need explicit [[Type conversion|type casts]] on variable use in the program. Code used to retrieve a string of characters, but only used for integer numbers can be cast implicitly; the vice versa can be done without error at [[compile time]], but there is a chance of loss of precision or data.
e.g.:
e.g.:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
Line 69: Line 69:


=== Differences with older versions of JScript ===
=== 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 allows declarimg variables and functions with type information (e.g., <code>var x : String;</code>), while type information for JScript's variables and functions cannot be declared (e.g., <code>var x;</code>).
* JScript .NET scripts are not interpreted, but executed independently. When executed, a JScript .NET application will invoke the [[Common Language Runtime|CLR]]. The CLR will execute the [[Common Intermediate Language|CIL]] instructions without using an interpreter.
* JScript .NET scripts are not interpreted, but executed independently. When executed, a JScript .NET application will invoke the [[Common Language Runtime|CLR]]. The CLR will execute the [[Common Intermediate Language|CIL]] instructions without using an interpreter.
* JScript .NET can be run without the presence of a browser or another [[Scripting language|scripting engine]] as the compiler can generate standalone [[executable]]s and assemblies. However these still require [[.NET Framework]] to be installed in order to run.
* JScript .NET can be run without the presence of a browser or another [[Scripting language|scripting engine]] as the compiler can generate standalone [[executable]]s and assemblies. However these still require [[.NET]] framework to be installed to run.
* JScript .NET provides access to the .NET Framework BCL ([[Base Class Library]]), providing much more functionality.
* JScript .NET provides access to the .NET framework [[Base Class Library]] (BCL), providing much more function.
* 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 [[HTML Application|HTA]]s or HTCs). In this regard, JScript is much more versatile than JScript .NET.
* JScript .NET is available as a scripting language for only [[ASP.NET]], the technology used to generate web pages. Thus, JScript .NET has a role similar to [[PHP]] and other [[Client–server model|server-side]] scripting languages. Internet Explorer, however, still uses only the older JScript engine, so JScript.NET cannot be used to script web pages (or [[HTML Application]]s (HTAs), or HTCs). In this regard, JScript is much more versatile than JScript .NET.


== See also ==
== See also ==
* [[JavaScript OSA]]&nbsp;A system-level scripting language for the [[Apple Macintosh]]
* [[JavaScript OSA]] – system-level scripting language for [[Apple Inc.|Apple]] [[Mac (computer)|Macintosh]]
* [[JScript]]
* [[JScript]]
* [[ActionScript]]
* [[ActionScript]]
Line 86: Line 86:
* [http://msdn.microsoft.com/en-us/library/3bf5fs13.aspx Getting Started With JScript .NET]
* [http://msdn.microsoft.com/en-us/library/3bf5fs13.aspx Getting Started With JScript .NET]
* [http://msdn.microsoft.com/en-us/library/ms974588.aspx Introducing JScript .NET]
* [http://msdn.microsoft.com/en-us/library/ms974588.aspx Introducing JScript .NET]
* [https://web.archive.org/web/20091027083329/http://geocities.com/Jeff_Louie/jscript_net_windows_form.htm JScript.NET tutorial and form tutorial]
* [https://web.archive.org/web/20091027083329/http://geocities.com/Jeff_Louie/jscript_net_windows_form.htm JScript.NET tutorial and form tutorial]


{{Common Language Infrastructure}}
{{Common Language Infrastructure}}
Line 95: Line 95:
[[Category:JavaScript programming language family]]
[[Category:JavaScript programming language family]]
[[Category:Object-based programming languages]]
[[Category:Object-based programming languages]]
<!-- Hidden categories below -->
[[Category:Articles with example JavaScript code]]

Latest revision as of 11:23, 25 June 2025

Template:Short description Template:Multiple issues Script error: No such module "Infobox".Template:Template otherScript error: No such module "Check for unknown parameters". JScript .NET is a .NET framework programming language developed by Microsoft as proprietary software.

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

Firstly, JScript is a scripting language, and as such, programs (or more suggestively, scripts) can be executed with no need to compile the code before. This is not the case with the JScript .NET command-line interface 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 named Microsoft Intermediate Language (MSIL), code before it can be run. Nevertheless, JScript .NET still fully supports interpreting source 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 VSATemplate:Technical inline interfaces.

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

Although the .NET framework and languages such as C# and Visual Basic (.NET) have been adopted widely, JScript .NET has received little attention, from the media and developers. It is not supported in Microsoft's premier development tool, 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#

  • JScript .NET does not require an entry point (Template:Mono function) that an operating system must call directly when executing a JScript .NET application, as such, JScript .NET program control flow can be based on global code.
  • JScript .NET, because of its very loose data type checking system, can be easier to learn, since the common convention of declaring types explicitly is unneeded.
  • JScript .NET does not require explicit references to the .NET framework Base Class Library, as certain functions found in earlier versions of JScript are present in JScript .NET (e.g., functions for finding the tangent of an angle for a right triangle).
  • JScript .NET is closely linked to C syntax, and is thus easy to learn for C#, Java, or C++ developers.
  • While JScript .NET can be used to create Windows Forms applications, it can have some trouble, as delegates can only be consumed in JScript .NET and not created. Thus, custom events are hard to emulate in JScript .NET.

Differences with C++

  • JScript .NET does not need a Template:Mono function.
  • JScript .NET does not need explicit type declaration on variables. (In C++, the use of templates and generics can be compared to this, loosely emulated with template specialization, etc.)
  • JScript .NET does not need explicit type casts on variable use in the program. Code used to retrieve a string of characters, but only used for integer numbers can be cast implicitly; the vice versa can be done without error at compile time, but there is a chance of loss of precision or data.

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 declarimg variables and functions with type information (e.g., var x : String;), while type information for JScript's variables and functions cannot 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 to run.
  • JScript .NET provides access to the .NET framework Base Class Library (BCL), providing much more function.
  • JScript .NET is available as a scripting language for only ASP.NET, the technology used to generate web pages. Thus, JScript .NET has a role similar to PHP and other server-side scripting languages. Internet Explorer, however, still uses only the older JScript engine, so JScript.NET cannot be used to script web pages (or HTML Applications (HTAs), or HTCs). In this regard, JScript is much more versatile than JScript .NET.

See also

Notes

Template:Reflist

References

Template:Common Language Infrastructure Template:ECMAScript