Giter Site home page Giter Site logo

slowsharp's Introduction

SlowSharp Build Status

Slow version of C# interpreter because modern JITs are too fast.
Web Playground

Pros

  • More Compatability: Brings C# scripting into WSA, iOS and WebAssembly.
  • And nothing

Zero-binding

  • No manual assembly references
  • No type or method binding

Even this can be possible:

CScript.Run(@"
   CScript.Run("" Console.WriteLine(""hello from inception""); "");
");

Hot Reloading

Can replace methods after parsing. This also affects already instantiated objects.

var r = CScript.CreateRunner(@"
class Foo { public int GiveMeNumber() => 10; }
");

var foo = r.Instantiate("Foo");
// should be 10
foo.Invoke("GiveMeNumber");
ss.UpdateMethodsOnly(@"
class Foo { public int GiveMeNumber() => 20; }
");
// should be 20
foo.Invoke("GiveMeNumber");

Overriding (Virtual inheritance)

Supports virtual inheritance, this is useful with Unity.

class MyBehaviour : MonoBehaviour { 
   public void SayHello() { /* ... */ }
}
// Error, MonoBehaviour cannot be instantiated by Unity's law
ss.Instantiate("MyBehaviour");

// Use this when you're not able to create an object yourself.
ss.Override("MyBehaviour", gameObject);

Finally, there will be two instances, but act as one derivered object.

// You can invoke methods from `MyBehaviour` which are defined in script-side.
ss.Invoke("SayHello");

// You can also invoke methods from `MonoBehaviour`
ss.Invoke("StopAllCoroutines");

Sandboxing

Access control

Prevents malicious function call such as Threading and File.

var ac = new AccessControl();
ac.AddBlockedType("System.Threading.Thread");
ac.AddBlockedNamespace("System.IO");

new RunConfig() {
  accessControl = ac
};

Timeout

Prevents long-running tasks with a timeout option.

new RunConfig() {
  timeout = 1000 /* ms */
};

Limitations

Since SlowSharp is an interpreter, there're some differences and limitations.

Lazy semantic validation
SlowSharp does not validate whole syntaxs during the parse time. It only checks the overall form is valid or not.
As a result, some mistakes won't be detected until it's fully reached and executed.

Console.WriteLine("Hello");

// There's not method `WriteLn` in `Conosle` class.
// However, this will not throw an exception util SlowSharp actually 
// evaluates the below line.
Console.WriteLn("World");
var a = 1234;
Console.WriteLine(a);
var a = 4556; // redefination

slowsharp's People

Contributors

pjc0247 avatar ssut avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.