cherry 2022-08-13

I would actually suggest a compiler option that could try to keep most things in JavaScript-land. But I'm not that sure if it's that useful, either - it can be confusing and have some weird side-effects (like, for example, vector or map comparison)

assoc with objects and arrays could amount to spread operators in js-land

so it doesn't mutate by default. you could use something akin to transient to allow direct mutation within that form

I mean that's mostly how I write js in the first place

never mutate args, chain functions so there are always new objects/arrays/maps on each transformation , etc

is there a good dissoc equivalent of this?

I have a poc branch up now in which:

$ ./node_cli.js -e '(prn (-> (assoc {} :foo :bar :baz 2) (dissoc :baz)))'
{ foo: 'bar' }
are all acting as update in place functions

and prn is just mapped to console.log directly

and keywords are just strings

maybe it's ok to treat assoc as in place mutation but map :keys destructuring to the spread operator

or should we reserve assoc for the immutable TC39 ones and use assoc! for in place

$ ./node_cli.js -e '(prn (-> (assoc! {} :foo :bar :baz 2) (dissoc! :baz)))'
{ foo: 'bar' }

A script example that I've got working here:

(ns argparse
  (:require
   ["argparse" :as argparse :refer [ArgumentParser]]))

(def parser (ArgumentParser. {:prog "example.cljs"
                              :description "Example!"}))

(parser.add_argument "-f" "--foo" {:help "foo bar"})

(def args (js/process.argv.slice 4))

(prn (parser.parse_args args))

OK, instead of just contemplating alternatives, I decided to make a spin-off from cherry here: #squint https://github.com/clavascript/clavascript I'm going to develop them in parallel and we'll see what becomes the most useful tool. A/B testing FTW :)

4

This is really exciting!

why did you choose the name clava? I saw this first in github and thought it was a calva dialect for vscode 🙈😅

clojure + javascript?

oh I see, didn’t pick up on it because of the cla (versus clo)

The interop story is getting more complicated on all platforms. Clojure isn't keeping up with all the options in Java (old features like private classes are awkward and new features like pattern matching are ignored). JS is more complicated cos much interop has to rely on idioms. Including libraries is already its own form of torture.