百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

lizzie

> 编程语言
开源

用于 .Net 和 CLR 的脚本语言

194 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于 .Net 和 CLR 的脚本语言

Lizzie a scripting language for .Net

Lizzie is a dynamic scripting language for .Net based upon a design pattern called "Symbolic Delegates". This allows you to execute dynamically created scripts, that does neither compile nor are interpreted, but instead "compiles" directly down to managed CLR delegates. Below is an example of using Lizzie from C#.

csharp
using System;
using lizzie;

class MainClass
{
    public static void Main(string[] args)
    {
        // Some inline Lizzie code
        var code = @"

// Multiples 10 by 2 and adds to 57
+(57, *(10, 2))

";

        // Creating a Lizzie lambda object from the above code, and evaluating it
        var lambda = LambdaCompiler.Compile(code);
        var result = lambda();

        // Writing the result of the above evaluation to the console
        Console.WriteLine("Result was: " + result);

        // Waiting for user input
        Console.Read();
    }
}

Lizzie is highly influenced and inspired from Lisp, but without the unintuitive "Polish notation". In such a way, it arguably is dynamic Lisp for the CLR. Its dynamic nature allows you to execute snippets of Lizzie code, inline in your C# code, by loading your code from files, or by for instance fetching the code from some database of some sort, or even transmit code over the network to have a server endpoint (securely) evaluate your code.

You can easily create your own "keywords" in Lizzie, which allows you to create your own DSL or "Domain Specific programming Languages". Lizzie hence easily lends itself to richer rule based engines, and similar domain specific problems, where your code needs to be more dynamic in nature than that which the CLR allows you to through C#, VB.NET or F#.

What is a Symbolic Delegate?

A Symbolic Delegate is a CLR delegate that is dynamically looked up during runtime from a dictionary of delegates with the same signature. This allows you to dynamically wire together delegates to an "execution tree" during runtime, based upon whatever delegate happens to be the value for your "symbol". Lizzie is literally a dictionary of delegates, where the key to lookup your delegates are of type string. This allows you to easily extend Lizzie by simply creating a new delegate, and associating it with a "symbol", to such have access to execute CLR methods from your Lizzie script code.

MSDN Article about symbolic delegates written by yours truly

Binding Lizzie to your own types

If you want to, you can "bind" your Lizzie code to a CLR type. This allows you to extend your Lizzie code with your own C# "keywords", to create your own "DSL". Below is an example.

csharp
using System;
using lizzie;

class MainClass
{
    [Bind(Name = "write")]
    object Write(Binder ctx, Arguments arguments)
    {
        Console.WriteLine(arguments.Get(0));
        return null;
    }

    public static void Main(string[] args)
    {
        // Some inline Lizzie code
        var code = @"

write('Hello World!!')

";

        // Creating a lambda function from our code, and evaluating it
        var function = LambdaCompiler.Compile(new MainClass(), code);
        function();
    }
}

How small is Lizzie?

The entire reference documentation for Lizze is roughly 12 pages if you choose to print it. This is the entire reference documentation for the language. This allows you to learn the entire programming language literally in 20 minutes. The "compiler" for the language is less than 500 lines of code, and all "keywords" are less than 1,000 lines of code in total. The project as a whole has roughly 2,200 lines of code, but 50% of these are comments. When built, the DLL is roughly 45KB on disc. There are 7 public classes in the project, one attribute, and one interface. There are less than 30 methods in total, and you don't have to use more than a handful of these to start adding dynamic scripting abilities to your CLR code. This arguably makes Lizzie the smallest (useful) programming language on the planet, if you ignore languages such as "brainfuck", arguably created more or less as a joke.

The Lizzie tokenizer also contains only 7 different tokens. There are no operators in the language, no keywords, and only one type of statement. In fact all "statements" are "functions", that all have the same signature. Compare this to the 500+ keywords, and 50+ operators of C#, and the 1,000+ pages of reference documentation for C#, and hopefully you understand the advantage.

  • The entire language and its syntax explained in 12 pages

How fast is Lizzie

When profiling a language such as Lizzie, there are two important things to measure.

  • Compilation speed
  • Execution speed

Compilation is blistering fast, at least if you consider the fact that the compiler is written in C#. Below is an example that compiles 10,000 snippets of Lizzie code. On my machine this code is finished after ~2 seconds.

csharp
using System;
using System.Diagnostics;
using lizzie;

class MainClass
{
    public static void Main(string[] args)
    {
        // Some inline Lizzie code
        var code = @"
+(5, 2, 50)
-(100, 30, 3)
*(5, 3, 2)
/(100, 4)
%(18, 4)
";

        // Compiling the above code 10,000 times
        Console.WriteLine("Compiling some Lizzie code 10,000 times, please wait ...");
        Stopwatch sw = Stopwatch.StartNew();
        for (var idx = 0; idx  Install-Package lizzie

Or visit the download page to get its source code

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#csharpdotnetdotnetstandarddsl

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言