Julia .NET Interop Library

I had created a long time ago a Julia .NET Interop Library. The goal of this library is to intuitively integrate .NET into Julia and be able to launch and utilize both languages from the other.

Recently, I have begun a side project of trying to create a julia runtime written in .NET and I was reminded of this project. I realized that I would be able to harness some of the capabilities of my primitive runtime project to build a much more mature and powerful interop library. This is beneficial to both projects as I able to see ways to mimic julia capabilities from .NET.

I am currently redesigning this interop library from the ground up and I wanted to bring this to the community to get advice about ways to enhance this library.

Components of the new Library:
Sharp Core: Launch and provide the framework to connect to Julia. (All code that interacts with julia passes through this library)

Sharp Dynamics: Provides Julian Dynamic Capabilities to .NET through dynamic objects. For dynamic code, this library will act as the intuitive way to call into julia.

Sharp Statics: Creates .NET static libraries of Julia modules that enable you to call into Julia "statically" and optimized to be as efficient as possible (there should be little to no boxing, mostly working with native methods).

Sharp Stdlib: Provides the primitive framework of the Julia Stdlib that cannot be generated by Sharp Statics.

This is quite an in depth project and I wanted to share it with the community to see if anyone would be interested in contributing to this project!

7 Likes

An update on the runtime. It is now called the Spinor Programming Language.

I have been working on the Julia Parser (Wow is this a tough Language Lol!)

It works for a good amount of Julia code already but there is a long ways to go (I think it supports ~450 binary operators atm)! You can dynamically add or alter operators such as adding left/right associativity, precedence etc. I may add this ability into the language in the future.

I read a lot of the internals of Julia source and copied over what I could but there is simply a lot I cannot copy since the environment is of .NET.

Here is my first milestone:

static void Main(string[] args) {
            Spinor.Init();
            try {
                var p = new ExprParser();
                var expr = (Expr) p.Parse(@"
                            module MyModule
                                x = 5
                                x *= 2
                                x = (x + 2) * (x - 2) * (x ^ 2) ∈ w

                                struct MyStruct 
                                        field1
                                end
                            end");
                
                expr.WriteCode(Console.Out);
                expr.PrintLn();
            }
            catch (SpinorException e) {
                e.Print();
            }
            Spinor.Exit();
        }

Output:

module MyModule
        #= :3 =#
    x = 5       #= :4 =#
    x * 2       #= :5 =#
    x = ((x + 2) * (x - 2) * (x ^ 2)) ? w       #= :7 =#
    struct MyStruct
                #= :8 =#
        field1  #= :9 =#
    end #= :10 =#
end

Expr(:module, Any[False, MyModule, Expr(:block, Any[#= :3 =#, Expr(:=, Any[x, 5]), #= :4 =#, Expr(:*=, Any[x, 2]), #= :5 =#, Expr(:=, Any[x, Expr(:call, Any[?, Expr(:call, Any[*, Expr(:call, Any[+, x, 2]), Ex
pr(:call, Any[-, x, 2]), Expr(:call, Any[^, x, 2])]), w])]), #= :7 =#, Expr(:struct, Any[False, MyStruct, Expr(:block, Any[#= :8 =#, field1, #= :9 =#])]), #= :10 =#])])

The next milestone will be creating an evaluator that converts Expr objects into CLR code. This will be significantly harder.

2 Likes