Git Product home page Git Product logo

cherry's Introduction

Cherry ๐Ÿ’

Experimental ClojureScript to ES6 module compiler.

Reducing friction between ClojureScript and JS tooling.

โš ๏ธ This project is an experiment and not recommended to be used in production. It currently has many bugs and will undergo many breaking changes.

Also check out ClavaScript which is a CLJS syntax to JS compiler.

Quickstart

Although it's early days and far from complete, you're welcome to try out cherry and submit issues.

$ mkdir cherry-test && cd cherry-test
$ npm init -y
$ npm install cherry-cljs@latest

Create a .cljs file, e.g. example.cljs:

(ns example
  (:require ["fs" :as fs]
            ["url" :refer [fileURLToPath]]))

(prn (fs/existsSync (fileURLToPath js/import.meta.url)))

(defn foo [{:keys [a b c]}]
  (+ a b c))

(js/console.log (foo {:a 1 :b 2 :c 3}))

Then compile and run (run does both):

$ npx cherry run example.cljs
true
6

Run npx cherry --help to see all command line options.

Examples

A few examples of currenly working projects compiled by cherry:

See the examples directory for more.

Project goals

Goals of cherry:

  • Compile .cljs files on the fly into ES6-compatible .mjs files.
  • Compiler will be available on NPM and can be used from JS tooling, but isn't part of the compiled output unless explicitly used.
  • Compiled JS files are fairly readable and have source map support for debugging
  • Compiled JS files are linked to one shared NPM module "cherry-cljs" which contains cljs.core.js, cljs.string, etc. such that libraries written in cherry can be compiled and hosted on NPM, while all sharing the same standard library and data structures. See this tweet on how that looks.
  • Output linked to older versions of cherry will work with newer versions of cherry: i.e. 'binary' compatibility.
  • Light-weight and fast: heavy lifting such as optimizations are expected to be done by JS tooling
  • No dependency on Google Closure: this project will use it for bootstrapping itself (by using the CLJS compiler), but users of this project won't see any goog.* stuff.
  • Macro support
  • REPL support
  • Async/await support. See this tweet for a demo.
  • Native support for JS object destructuring: [^:js {:keys [a b]} #js {:a 1 :b 2}]
  • Native support for JSX via #jsx reader tag

Cherry may introduce new constructs such as js/await which won't be compatible with current CLJS. Also it might not support all features that CLJS offers. As such, using existing libraries from the CLJS ecosystem or compiling Cherry CLJS code with the CLJS compiler may become challenging. However, some results of this experiment may end up as improvements in the CLJS compiler if they turn out to be of value.

Depending on interest both from people working on this and the broader community, the above goals may or may not be pursued. If you are interested in maturing cherry, please submit issues for bug reports or share your thoughts on Github Discussions.

Cherry started out as a fork of Scriptjure. Currently it's being reworked to meet the above goals.

License

Cherry is licensed under the EPL, the same as Clojure core and Scriptjure. See epl-v10.html in the root directory for more information.

cherry's People

Contributors

arohner avatar borkdude avatar christophermaier avatar djblue avatar heliosmaster avatar hugoduncan avatar ibdknox avatar mk avatar purcell avatar pyr avatar scottjad 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.