I'm interested to know who uses JScript.Net and for what sort of applications. Whenever I'm reading MSDN .Net documentation, I always notice the JScript samples but in all the years I've been a C# dev I've never actually known anyone to use it.
What sort of applications are people using this for, and how does it measure, in terms of flexibility, power and general usage, to C#?
[Edit: Just to clarify - I'm not asking what JScript.Net is, I'm asking what people are actually using it for - i.e. interested to know actual usage scenarios and how people have found it to work with]
JScript was first supported in the Internet Explorer 3.0 browser released in August 1996. Its most recent version is JScript 9.0, included in Internet Explorer 9.
It is a trademark scripting language specification. JScript released in 1996 by Microsoft, as Microsoft's dialect of ECMAScript. JScript and JavaScript are different names for the same language. They have different names to avoid trademark issues.
To be clear, C# was a proposed JavaScript alternative that could be used exclusively for Microsoft software. Since C# is the programming language of the most popular software on the planet, it has gone through many versions and updates.
NET is a . NET programming language developed by Microsoft.
Rob - I have used JScript.NET in anger in one place in my code, which is essentially to expose the functionality of its eval method. Here is a cut-down version:
static public class Evaluator { private const string _jscriptSource = @"package Evaluator { class Evaluator { public function Eval(expr : String) : String { return eval(expr); } } }"; static private object _evaluator; static private Type _evaluatorType; static Evaluator() { InstantiateInternalEvaluator(); } static private void InstantiateInternalEvaluator() { JScriptCodeProvider compiler = new JScriptCodeProvider(); CompilerParameters parameters; parameters = new CompilerParameters(); parameters.GenerateInMemory = true; CompilerResults results; results = compiler.CompileAssemblyFromSource(parameters, _jscriptSource); Assembly assembly = results.CompiledAssembly; _evaluatorType = assembly.GetType("Evaluator.Evaluator"); _evaluator = Activator.CreateInstance(_evaluatorType); } static public object EvaluateToObject(string statement) { try { return _evaluatorType.InvokeMember( "Eval", BindingFlags.InvokeMethod, null, _evaluator, new object[] {statement} ); } catch (Exception) { InstantiateInternalEvaluator(); return null; } }
You can obviously create overloads for other return types. I can't claim the original idea for this was mine! Uses for this would be, for example, to evaluate a string expression like 3 + 4
to 7
without expression parsing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With