Jint - Javascript Interpreter for .NET

Project Description

Jint is a script engine based on the Javascript language. Using Jint, developers can provide fully scriptable applications, execute .NET code without compiling, or create external configuration logic, using the most used script language.
Jint aims at providing  every JavaScript functionalities to .NET applications, and bindings to .NET languages can be done in both sides. Jint scripts can use any .NET object from your application, and use every part of the .NET base class library.

Differences with other script engines

Jint is different as it doesn't use  CodeDomProvider technique which is using compilation under the hood and thus leads to memory leaks as the compiled assemblies can't be unloaded. Moreover, using this technique prevents using dynamically types variables the way JavaScript does, allowing more flexibility in your scripts. On the opposite, Jint embeds it's own parsing logic, and  really interprets the scripts. Jint uses the famous ANTLR ( http://www.antlr.org) library for this purpose.
As it uses Javascript as its language you don't have to learn a new language, it has proven to be very powerful for scripting purposes, and you can use several text editors for syntax checking.

Usage scenarios

  • Create applications users can automate by providing a programmable interface. A good example is what VBA is for Microsoft Office applications
  • Enhance configurability to change your application's behavior and logic without compiling or deploying binaries
  • Evaluate dynamic code or expressions

Sample usage

Here is a sample in C#, but any .NET language can use Jint. Jint is able to handle all advanced JavaScript techniques decribed on this MSDN article:  http://msdn.microsoft.com/en-us/magazine/cc163419.aspx. It currently implements all concepts defined in ECMAScript version 3.0.

script= @"
  function square(x) { 
    return x * x; 
  };
  
  return square(number);
  ";
  
var result = new JintEngine()
  .SetParameter("number", 3)
  .Run(script));

Assert.AreEqual(9, result);

You can also check the actual implemented  test suite for more samples.

Implemented artifacts

  • Standard Javascript elements:
    • Objects and methods
    • Loops (do, while, for)
    • Code blocks and scopes
    • Conditional statements (if, switch/case)
    • Json
    • Property indexers
    • Dynamic properties
    • Javascript native classes (Math, String, Object, Number)
    • Regular expressions
    • Functions (declarations plus anonymous functions)
    • Prototypes and constructors
  • .NET bindings
    • External objects and values
    • External functions to enhance the script resources
    • Return value to .NET code
  • Out of the box Jint Shell application
    • Use Jint on the command line

Deployment

Jint is deployed as a part of your application and fits inside a single assembly. Nothing as to be installed on the client machine.

Roadmap

  • 0.8 - All javascript languages artifacts as of ECMAScript 3.0
  • 0.9 - Beta phase - All javascript core methods are implemented (Math, slice, ...)
  • 1.0 - Positive feedback from Beta
  • 1.1 - ECMAScript 5.0 elements

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值