Giter Club home page Giter Club logo

clay's Introduction

CLAY

CLAY (Common Lisp According to Yogurt) is a version of common lisp with an interpreter written in rust. Development is tested against SBCL.

building clay:

First clone this repo. Then cd into the repo directory. Then build with the release flag (cargo build --release). Then copy the binary to a somewhere in your path variable.

on linux:

$ > git clone https://github.com/calacuda/clay.git
$ > git clone https://github.com/calacuda/clay_lib.git
$ > cd clay
$ > cargo build --release
$ > cp /target/release/clay ~/.local/bin

usage:

Consider this lisp function that calculates factorials recursively.

(defun fact (k)
  ;(write-line "k is " k)
  (if (< k 2)
      1
    (* k (fact (- k 1)))
    )
  )

(write (fact 5))
(terpri)

the line that is commented out is commented out because, it will not work in SBCL.

This code is stored in the "test.lisp" file. To run it with sbcl one would type:

$ sbcl --script test.lisp

to run with clay:

$ clay test.lisp

if you need/want to look at the lexer, parser, and bytecode compiler output, run using "--test".

benchmarks:

SBCL:

$ > hyperfine -r 1000 "sbcl --script test.lisp"
Benchmark #1: sbcl --script test.lisp
  Time (mean ± σ):       8.8 ms ±   2.3 ms    [User: 4.2 ms, System: 4.9 ms]
  Range (min … max):     6.9 ms …  17.9 ms    1000 runs

clay:

$ > hyperfine -r 1000 "target/release/clay test.lisp"
Benchmark #1: target/release/clay test.lisp
  Time (mean ± σ):       1.6 ms ±   1.3 ms    [User: 1.3 ms, System: 1.3 ms]
  Range (min … max):     0.5 ms …   9.2 ms    1000 runs

In other words my implementation is faster then SBCL. However SBCL is much, and I mean much, better at dealing with large numbers.

TODO:

  • implement an import statement to add libraries to the current name space.
  • test if C libraries can be imported.
  • enable saving of byte code to a file.
  • compiled rust lib loading.

perpetual TODOs:

  • clean up the code (delete unneeded commented lines, fix cargo warnings, etc).

Acknowledgement:

I got a good start on this project, and not to mention a better grasp of rust from looking at another similar GitHub project (this github). this is the same place I got the Lexer from.

clay's People

Contributors

calacuda avatar

Stargazers

 avatar

Watchers

 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.