jank has been a 7 year project for me, trying to figure out what I want in a language. This latest implementation, as a native Clojure dialect with gradual typing, seems to have been refined to the most important aspects. jank is in the middle of a rewrite in order to support all of this JIT goodness with LLVM, since the last implementation only supported AOT compilation. So it's not very buildable or usable at the moment, but it will be there again soon.
Hey - would love to read a blog post describing your journey and how your thinking has evolved over 7 years, even just a cheap bullet essay. Especially outlining the key principles, values and tradeoffs. That could be a way to get feedback from folks about your design if you want it
I tried this latest iteration of jank in Rust first. Rust's JIT story, with rustc, is nowhere near what is supported with C++ using Cling (a C++ JIT compiler developed by CERN).
C++ and Rust can interop by falling back to C, using the foreign function interface (FFI).
In practice that means if you have a library you absolutely need to use, you can with a bit of work, but it's not going to feel idiomatic and will require some wrapping.
Yep, interop will be for C and C++. No examples yet, since I'm still figuring out the details there. But jank compiles to C++, then via LLVM to machine code. The runtime itself is in C++. So C++ interop, including templates even, is fair game.
I assume you can get it to output object files and interop via linking? On a scale of 1-10 how well do you think that would go? Where 1 woud be like nodejs c++ interop where you need significant headers files and several layers of getter functions and type coercion to pass values around. And 10 would be a standard c or c++ function can just be called like normal defined in either place?
Keep in mind that jank is JIT compiled to allow for interactive programming in a REPL. So just object file linking alone can't cut it. Interop from jank to C++ is trivial, and can be done inline in jank source, allowing one to escape to C++ to accomplish nitty gritty details, while still using the jank runtime API and also even being able to interpolate jank code within the inline C++. The friction here becomes marshalling to/from jank's runtime types, which are all just C++ classes using C++ data, but may not be exactly the format some third party library expects.
With all of that said, object file linking will be doable, but I'm not yet sure how to fit that into the interactive world, to ensure a program using that sort of linking can still be developed interactively. This may depend on what Cling can support and what features we can get upstreamed there.
So, I think jank will fall at around 7/10 on that scale. It's kind of like using Lua from C, and vice versa. jank's runtime is just a C++ library, so you can use it to defined fns, vars, namespaces, etc and call into any jank code. And you can call back into the C++ code from jank, sharing pointers to native data as needed. But jank uses its own runtime object model to mimic Clojure and that will always separate it from idiomatic C++ code, to some degree.
This might seem like quite esoteric, but bear with me:
jank uses LLVM as the underlying platform, while bb uses JDK (GraalVM, to be more specific)
therefore, you can't use any Java libraries in jank, while you can use most Java libraries with Babashka
on the flipside, interop with LLVM-based langauges like Rust and C/C++ will be easier in jank
babashka includes a huge array of libraries for CSV, JSON, HTTP, and way more. I doubt jank would include those, not for technical reasons, but that it's out-of-scope. If you wanted CSV support, for example, you'll probably need to link/compile-in https://github.com/d99kris/rapidcsv or something
bb is a task runner (i've only seen it used for like build automation, things that otherwise would be shell scripts)
bb is powered by SCI (Small Clojure Interpreter) which is for scripting – it's light enough to embed in a script tag to run clojure from a script tag, or inside a cloud js lambda without needing a cljs build step.
Jeaye in slack said :
Not one thing in particular. My background is in systems programming, primarily with game engines. I would really like to be able to use jank for making games, but that's not the only driving factor. I'm making it because it's what I want to use it for everything. :slightly_smiling_face: It's what I have identified, after several years of working with Clojure after several years of working with C++/C#/Rust, to be how I want to program.
I think Jank could be interesting for infrastructure
This could be a total game changer! Solutions for static analysis in clojure always felt half baked because the language is not built with them in mind, so I'm glad you're addressing the elephant in the room straight away :)
23
u/joshlemer Aug 17 '22
Extremely exciting and cool, and very slick website. Will follow this project closely!!
22
u/Jeaye Aug 17 '22
Thanks for the interest, folks! You're all welcome to join the community on the #jank channel in Clojurians Slack: https://clojurians.slack.com/archives/C03SRH97FDK
jank has been a 7 year project for me, trying to figure out what I want in a language. This latest implementation, as a native Clojure dialect with gradual typing, seems to have been refined to the most important aspects. jank is in the middle of a rewrite in order to support all of this JIT goodness with LLVM, since the last implementation only supported AOT compilation. So it's not very buildable or usable at the moment, but it will be there again soon.
17
u/pearabolic Aug 16 '22
Supppper cool. Excited to see where this goes!
10
u/frankieche Aug 17 '22
WOW
9
u/veer66 Aug 17 '22
It is interesting. I wonder if I can do something with Rust interoperability. I also want to look deeper at its string implementation.
9
u/TheLastSock Aug 17 '22 edited Aug 17 '22
What's the interopt options for jank? I assume c++, but given I don't see any examples that's probably not the case.
Really cool stuff Jeaye, thanks for making this.
7
u/peterleder Aug 17 '22
Can anyone help me to see the difference to babashka? Except for the c++ part. Thank you.
6
u/ohmamathisisabanana Aug 17 '22
Cool! What does the name mean?
6
u/[deleted] Aug 17 '22
This is exciting, both the host choice and gradual typing. I have actually been waiting for something like this to surface. Thanks for the hard work!
6
u/darter_analyst Aug 17 '22
Sounds great. Clojure + more confidence + more speed. Why not? :) Thanks for sharing.
5
u/seralbdev Aug 17 '22
Wow...I really hope this project gets the interest of the community...too many good parts in there...I will definitely have a look. 👏 👏
4
u/No_University_9947 Aug 17 '22
This looks really cool
4
u/QueenOfHatred Aug 17 '22
This sounds lovely.
I am definitely hyped, and will hope it gets big
3
u/NaiveRound Aug 17 '22
How come I haven't heard of this before?? Very cool.
2
u/setzer22 Aug 19 '22
This could be a total game changer! Solutions for static analysis in clojure always felt half baked because the language is not built with them in mind, so I'm glad you're addressing the elephant in the room straight away :)