Giter Site home page Giter Site logo

luukdegram / luf Goto Github PK

View Code? Open in Web Editor NEW
34.0 2.0 4.0 976 KB

Statically typed, embeddable, scripting language written in Zig.

Home Page: https://github.com/Luukdegram/luf

License: MIT License

Zig 100.00%
zig language scripting-language embeddable-scripting-language statically-typed ziglang luf embeddable

luf's Introduction

Luf

Luf is a statically typed embeddable scripting language written in Zig.

The goal of this project is to create a simple, expressive scripting language that can be used to implement new ideas. As most of it is experimental, I would currently not recommend this for any serious use.

Resources

Building from source

Linux statusโ€ƒ Windowsโ€ƒMacOS

I try to keep up with the latest version of Zig to be able to use all of its features (and bug fixes). Currently, you'll need atleast version 0.8.0-dev.2641+55811d8da to build Luf.

Building

To build Luf as a static library, execute the following Zig command:

zig build

Tests

Currently all tests are written in Zig, but there's plans to also write behavioural tests in Luf.

To run all tests, execute the following command:

zig build test

Editor support

Currently there's support for syntax highlighting for vscode, which can be found here.

luf's People

Contributors

luukdegram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

luf's Issues

Add support for calling Zig functions

  • Add compiler support for 'packages' for type support. (compiler doesn't know anything about this package, therefore we should ignore type checking for those cases but return a general .module type or something like that).
  • Add function to value.zig to wrap a Zig function into a Luf Value.
  • Add VM support to add Zig functions as a 'package'.

Experiment: Allow compilation to typed ZIR

It would be a cool experiment to compile to typed ZIR that can be used by Zig's compiler to compile it to machine code and see its effect on performance compared to regular Zig code.

Obviously we will have to comply with Zig's semantics and type system, allowing us to only implement features that are supported by Zig. We will also have to handle memory usage someway.

Allocate error messages so we can format them with arguments

Currently error messages require to be comptime known, cuasing us to lose runtime known information, such as an en expected type. By allocating them we can use std.fmt.allocPrint() to make fancy error messages.

Ensure we do not forget to free all memory created by those messages. Either by deinit() or when write() is called.

Add a basic CLI for compiling/running Luf

Currently, the user would have to create their own Zig project first, and embed the VM to be able to write Luf code. Luf should also come as a standalone CLI tool that can run both Luf files as well as compiled bytecode for faster execution using flags.

Improve the test bed for Luf

Currently all tests are handwritten within Zig with a lot of expects().
This is not really manageable, and takes quite some work to update on changes.
We should look into behavioral tests.

Implement optionals

Luf already supports nil literals, but assigning nil to a variable will make its type nil as well.
Optional should be seperate type that must be handled before usage, similair to how Zig handles them.

Add a WASM backend

Would be cool to be able to write Luf code, and compile to WASM, rather than having to write WASM code directly. Especially because Luf has type-safety and is a lot more readable than WASM text.

Optimize simple instructions

Some instructions can easily be optimized such as:

const x = 5 + 5 can be optimized to const x = 10.
const myFunc = fn() { return 5 } can be optomized to return 5.

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.