Saturday, July 3, 2010

OO Hello World - JScript.NET



Hello world in JScript is here! An ECMAScript/JavaScript dialect implemented by Microsoft.

A new language added to the list. This is a well-supported language from Microsoft since Visual Studio 2002/.NET 1.0, commonly used as a scripting language in Web pages or Windows Scripts, but that also allows you to create dlls and exe applications using Object Oriented features.


By the way, you can see my previous post here: http://carlosqt.blogspot.com/2010/06/oo-hello-world.html
where I give some details on WHY these "OO Hello World series" samples.

Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.
class Greet {
 var name;
 function Greet(name : String) {
  this.name = name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1);
 };
 function Salute() {
  print("Hello " + name + "!");
 };
}

// Greet the world!
var g = new Greet("world");
g.Salute();

Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
import System;

package GreetProgram
{
 public class Greet {
  private var name : String;
  public function Greet(name : String) {
   this.name = name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1);
  };
  public function Salute() {
   print("Hello " + this.name + "!");
  };
 }
}

// Greet the world!
function Main() {
 var g : GreetProgram.Greet = new GreetProgram.Greet("world");
 g.Salute();
};

Main();

The Program Output:





  



JScript Info:
“JScript 8.0 is a modern scripting language with a wide variety of applications. It is a true object-oriented language, and yet it still keeps its "scripting" feel. JScript 8.0 maintains full backwards compatibility with previous versions of JScript, while incorporating great new features and providing access to the common language runtime and .NET Framework.” Taken from: (http://msdn.microsoft.com/en-us/library/72bd815a(VS.80).aspx)

“JScript 8.0, the next generation of the Microsoft JScript language, is designed to be a fast and easy way to access the Microsoft .NET platform using the language of the Web. The primary role of JScript 8.0 is construction of Web sites with ASP.NET and customization of applications with Script for the .NET Framework.” Taken from: (http://msdn.microsoft.com/en-us/library/e2h4yzx6(v=VS.80).aspx)

Appeared:
2002
Current Version:
Developed by:
Microsoft
Creator:
Microsoft
Influenced by:
JavaScript (Brendan Eich)
Predecessor Language
JScript 5.8
Predecessor Appeared
1996
Predecessor Creator
Microsoft
Runtime Target:
CLR
Latest Framework Target:
4.0
Mono Target:
Yes
Allows Unmanaged Code:
No
Source Code Extension:
“.js”
Keywords:
75
Case Sensitive:
Yes
Free Version Available:
Yes
Open Source:
No
Standard:
ECMA-262
Latest IDE Support:
VisualStudio 2010
Language Reference:
Extra Info:


1 comment:

  1. i am learning Java script for begineres. i saw this article. it seems very interesting.

    ReplyDelete