Introducing squint, a ClojureScript syntax to JavaScript compiler!
The primary use case for squint is to produce JavaScript using ClojureScript syntax while producing ultra-small bundle sizes, by leveraging the JS platform directly. Squint does not protect you from the pitfalls of JS (mutability, equality), but lets you use the concepts you already know from ClojureScript and maps them more or less directly to JS where this makes sense. It comes with a standard library which has many of the core functions you know: map-indexed , for example, works like you would expect, but returns a mutable JS array instead of an immutable vector.
I’m really excited by this project. I work primarily with JS and can’t see that changing. I’d like to use Clojure to build tooling around my current work - being closer to JS will be a big help. Looking forward to macros and the REPL!
Really cool stuff. the jsx integration is great though the language is a bit too close to clojure for my liking. As in… I’ll likely get the immutable ops mixed up with the mutable ones.
The language resembles ClojureScript so that you don’t have to learn new APIs and porting between cherry and squint is easy. E.g. I’ve taken a Hacker News reader that was built in cherry and could port it to squint with almost no changes:
The “immutable” core functions in squint, like assoc, do not mutate the original, but create shallow copies of the original, so they are never causing “spooky action at a distance” effects. There is also the mutating assoc!.
Something like immer could be used to get back cheap full-blown immutability. I’ve made a little
start with that here: squint-immer. Compiling an example using squint + immer comes down at around 11kb with esbuild.
You can see the compiler output of squint in the playground: Squint
Or you can run npx squint --no-run --show -e '(+ 1 2 3)' on the command line.
haha. that’s so cool. I did something really something really similar when I started going down this rabbit hole:
… and like about 20 more repos…
It’s a pretty steep climb down though cos JS is just too vast an ecosystem right now. Good on you. Really jealous. Wish I had the luxury to do open source.
it needs to be reactified… but it’s still being maintained and worked upon. I was a bit sort on time and gave up trying to and just built on top of react-blessed but it’s got really good primitives to build upon. ink is too opinionated for me and not as flexible as either blessed or terminal-kit. But it’s really well maintained.
I got really into terminal apps for a while. still love to do more of it if I get the opportunity.
Just wanted to say that I’ve been using Squint and it works great. I really like that fact that it can be used as a Clojure library.
We have a static site builder tool and I use Squint to replace small JavaScript scripts (eg jquery type popups, tracking, etc) where Clojurescript would be overkill, but I still want Clojure syntax.
I’m embedding the Squint code directly in the Clojure template functions, and it works pretty well.
@mjmeintjes This is very helpful to know. Can you let me know which API you are currently using from Clojure? I’ll take care to write some unit tests for it and try to not break the API.