Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JScript.NET vs ECMA

I am programming a small console app that is an intelligent front-end to a set of batch files with ungodly parameters.

I have decided to use JScript.Net for this though it may be ill advised compared to C# because I am finding the flexibility of it useful, and it feels a bit more RAD than C# for this kind of thing.

The problem I have is not being able to find adequate resources on the net showing how JScript.Net != ECMA when it gets down to the nuts and bolts level. I have to be constantly vigilant of the gotchas, and how things are actually implemented are a bit puzzling.

Does anyone have good links to information on this subject?

Edit--

To be specific, I want a resource that will stop me from writing tests like this -- which compiles and runs, despite the weirdness going on in the synax:

var int16:Int16=0;
w_(typeof int16);                // =number
//w_(int16.getType());    //runtime error function expected
//
var ds:String="dot,net,class";
w_(typeof ds);                   // =string
var da1:Array=ds.Split(',');  // proper case
var da2:Array=ds.split(',');  // camel case !works too!
w_(typeof da1);                 // =object
var ds1_:String=da1.join(',');// NOT proper. "Join" is **runtime error**
var ds2_:String=da2.join(',');// NOT proper. "Join" is **runtime error**
w_('ds1_:'+ds1_); // prints dot,net,class
w_('ds2_:'+ds2_); // prints dot,net,class
//
var js="jscript.object";
w_(typeof js);                   // =string
var ja1=js.split(','); // camel case
var ja2=js.Split(','); // proper case
w_(typeof ja1);                   // =object
var js1_=ja1.join(',');// camel
var js2_=ja2.join(',');// camel
w_('js1_:'+js1_);  // prints jscript.object
w_('js2_:'+js2_);  // prints jscript.object
//
// and then
//
var dss:System.String="dot,net,sys,class";
w_('dss:'+(typeof ds));                   // =undefined !!!
//w_('dss:'+dss.getType());    //runtime error function expected
var daa:Array=dss.Split(',');// proper case  ???? what is this object type!
var daa2:Array=dss.split(',');// camel case  ???? what is this object type!
w_(daa.join(','));       // prints dot,net,sys,class
w_(daa2.join(','));       // prints dot,net,sys,class
//

You see?

Also

// in library 'package' JLib_Test.jsc
import System;
import System.IO;
import System.Diagnostics;
import System.Text;
import System.Drawing;
package JLib_Test{
  class Test{
    public function Test(){
      //var re=new RegExp('^s$','gi'); // **runtime error** !
    }
  }
//
// in main 'exe' module
var re=new RegExp('^s$','gi'); // no errors
like image 717
Mark Robbins Avatar asked Jan 18 '26 23:01

Mark Robbins


1 Answers

As you are on Windows, just run your .js file with cscript.exe: this is the Windows Scripting Host (WSH) environment from Microsft that uses the other Microsoft implementation (a standard Windows 7 system has currently 3: JScript, JScript.NET and JavaScript in IE9). The JScript from WSH is the one that was used in IE up to IE8, and so has probably less .NET-isms.

Note that you'll probably have issues with your I/O and argument parsing as the API in .NET and WSH are different, so I suggest to make a common API wrapper.

like image 76
dolmen Avatar answered Jan 21 '26 12:01

dolmen