GithubHelp home page GithubHelp logo

zackradisic / tyvm Goto Github PK

View Code? Open in Web Editor NEW
422.0 8.0 16.0 21.42 MB

An experimental bytecode interpreter / type-checker for type-level Typescript

Home Page: https://tyvm.vercel.app

TypeScript 19.73% Rust 30.61% Nix 0.73% Zig 47.59% Makefile 0.42% C 0.09% JavaScript 0.27% CSS 0.55%

tyvm's Introduction

tyvm

An experimental bytecode interpreter for type-level Typescript.

About

tyvm is another Typescript type-checker project, but this time with a focus on nailing type-level Typescript first.

The idea is that type-level Typescript is a very simple, purely functional programming language.

Tackling type-level Typescript alone is a lot less complex of a task then trying to reach feature parity with tsc in implementing the entirety of Typescript.

This would, theoretically, allow tyvm to be useful much more quickly. It could start being used as a converter for Typescript types -> X, where X is GraphQL, Prisma, JSON Schema, etc.

I'm also just fascinated by this kind of stuff, so it's also a fun side project for me.

Architectural Overview

This project is comprised of 2 main parts:

  1. Compiler: Written in Rust, takes Typescript type-level source code -> tyvm bytecode
  2. VM: Written in Zig, takes tyvm bytecode and executes it.

Compiler

The compiler uses the oxc project's parser to parse Typescript source code into an AST, which is then converted to a specialized intermediate representation (IR).

The IR makes compilation into bytecode much easier. It also doesn't constrain us to any one particular AST, conceptually, any AST from any of the JS/TS compiler projects (e.g. SWC, Babel, etc.) could be converted to the IR, allowing us to support many different compiler frontends.

VM

The VM is a stack based machine that runs the generated bytecode from the compiler.

Because of the simplicity and immutable nature of type-level Typescript, there many cool performance optimizations we can borrow from FP:

tyvm's People

Contributors

zackradisic 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  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  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  avatar  avatar  avatar  avatar  avatar  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.