Closed anonhostpi closed 3 months ago
Hi @anonhostpi,
We've looked at the Deno documentation, and we aren't clear on what a ClearScript-Deno combination would look like or even what the point of it would be.
ClearScript aims to make .NET applications scriptable, whereas Deno is a JavaScript application platform. How would one help the other achieve its goals?
Treating Deno as a script engine doesn't make sense. The script engine within Deno is V8, which ClearScript already supports, and going through Deno to achieve parity with that would be both difficult and pointless.
Deno's other main benefit is its implementation of a comprehensive JavaScript API, but if that's what you need, you can either embed Deno directly or use ClearScript and .NET to implement a similar API on top of bare V8.
The ability to use .NET to extend Deno might be interesting, but ClearScript doesn't really offer anything to facilitate that, and it's unclear whether such a capability would have broad appeal.
Please feel free to reopen this issue if you have additional thoughts about this topic. Thanks!
Language interop mostly. It would help .NET achieve the same thing that Python.NET has done but for JS instead of Python.
I know that this idea has been brought up for node multiple times, but Node isn't very embeddable.
Deno on the other hand is. Of course, as stated, an additional layer of work would have to be done to embed Deno compared to what Python.NET had to do for Python as Deno would need Rust FFIs in addition to the C# bindings.
The primary problem with porting the Node and/or Deno APIs to ClearScript's V8 as you suggested is that hundreds of those APIs aren't Javascript, but rather Native/C++. These APIs would have to be entirely rewritten from scratch.
In contrast, writing FFIs and bindings is just a matter of identifying existing code that you want to expose to another program (no rewrites required) which is effectively what this repo already does for V8 and the other JS engines
Currently, I'm exploring and researching both approaches (rewriting Node's Native APIs and writing my own FFIs for Deno) independently of this repo, but I am just a single hobby developer, and I expect that work to likely take me years, since I don't develop professionally (I have to do this in my off time between classes and work)
Can you give us an idea of what ClearScript-Deno integration might look like? That is, how would you use it from a .NET application? Do you envision something like DenoScriptEngine
that works just like V8ScriptEngine
but has all of Deno's JavaScript APIs built in?
I would expect it to be similar to what is exposed with V8ScriptEngine for consistency (with Deno's specific APIs being callable from JS land as you suggested)
Given that Deno is V8 based, I don't imagine you would need to expose any additional Deno-specific APIs to C# land.
It would be handy to have a variant of eval that just loads a Deno module by its identifier and returns its exports, but I think that would just be handy and not necessary.
Hi @anonhostpi,
Although that sounds like an interesting idea and a potentially useful project, it really isn't ClearScript's goal to provide general-purpose application frameworks or script APIs that go far beyond what's built into the language.
Also, please understand that ClearScript is a side project maintained by a very small group in their spare time, and we've got our hands full with the current batch of eight V8 platforms and over twenty individual NuGet packages.
ClearScript interfaces with V8 via the latter's expansive C++ API. Because Deno doesn't – as far as we can tell – provide that kind of access to its underlying script runtime, your proposal would require extensive modifications to both Deno and ClearScript. While that might still be far less work than building a Node.js-like platform atop V8ScriptEngine
, it just isn't something we're likely to tackle in the foreseeable future.
Sorry!
Originally discussed here: https://github.com/microsoft/ClearScript/issues/487#issuecomment-2222058653