@calcit/procs
@calcit/procs
npm i @calcit/procs
@calcit/procs

@calcit/procs

Lisp compiling to JavaScript ES Modules

by calcit-lang

0.6.5 (see all)TypeScript:Not Found
npm i @calcit/procs
Readme

Calcit Scripting Language

Semantically a dialect of ClojureScript. Built with Rust. Compiles to JavaScript ES Modules.

Browse examples or also try WASM version online.

Core design:

  • Interpreter runs on Rust, extensible with Rust FFI
  • Persistent Data Structure
  • Structural Editor(with indentation-based syntax as a fallback)
  • Lisp macros, functional style
  • Compiles to JavaScript in ES Modules, JavaScript Interop
  • Hot code swapping friendly

Install

Build and install with Rust:

# get Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# get Calcit
cargo install calcit

For Ubuntu latest, try binaries from http://bin.calcit-lang.org/linux/ , which are provided for CI usages.

Usage

Snippets evaling:

cr -e 'range 100'

multi-lines snippet:

cr -e '

println "|a demo"

->
  range 100
  map $ fn (x)
    * x x

'

Run with a compact.cirru:

cr compact.cirru -1 # run only once

cr compact.cirru # watch mode enabled by default

cr compact.cirru --init-fn='app.main/main!' # specifying init-fn

JavaScript codegen

It compiles to JavaScript and runs in consistet semantics. However it might require a lot of JavaScript interop.

cr compact.cirru --emit-js # compile to js
cr compact.cirru --emit-js --emit-path=out/ # compile to js and save in `out/`

By default, js code is generated to js-out/. You will need Vite or Node to run it, from an entry file:

import { main_$x_, reload_$x_ } from "./js-out/app.main.mjs";
main_$x_();

Calcit Editor & Bundler

Install Calcit Editor and run ct to launch editor server, which writes compact.cirru and .compact-inc.cirru on saving. Try launching example by cloning Calcit Workflow.

Read more in Minimal Calcit to learn how to code Calcit with a plain text editor.

Read more in Respo Calcit Workflow to learn to create an MVC webpage with Respo.

Modules

No package manager yet, need to manage modules with git tags.

Configurations inside calcit.cirru and compact.cirru:

:configs $ {}
  :modules $ [] |memof/compact.cirru |lilac/

Paths defined in :modules field are just loaded as files from ~/.config/calcit/modules/, i.e. ~/.config/calcit/modules/memof/compact.cirru.

Modules that ends with /s are automatically suffixed compact.cirru since it's the default filename.

To load modules in CI environments, make use of git clone.

Development

I use these commands to run local examples:

# run tests in Rust
cargo run --bin cr -- calcit/test.cirru -1

# run tests in Node.js
cargo run --bin cr -- calcit/test.cirru --emit-js -1 && yarn try-js

# run snippet
cargo run --bin cr -- -e 'range 100'

cr compact.cirru --emit-ir # compiles intermediate representation into program-ir.cirru

Other tools:

Some resources:

License

MIT

Downloads/wk

589

GitHub Stars

55

LAST COMMIT

7mos ago

MAINTAINERS

1

CONTRIBUTORS

4

OPEN ISSUES

0

OPEN PRs

1
VersionTagPublished
0.6.5
latest
7d ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate