Skip to content(if available)orjump to list(if available)

From C++ to Clojure: Jank language promises best of both

troad

I'm very excited for Jank, I wish the creator well.

If I could make one tiny plea, it would be to focus on tooling too, and ensuring the experience for someone trying Jank out is as smooth as possible. Don't assume everyone is already set up with paredit and can fire off emacs chords without a thought. I suspect that Jank will be of particular interest to C++ programmers, many of whom are used to a very different dev paradigm.

The Clojure community has done a great job at trying to smooth out the rough edges of Lisp tooling, and ensure there are on-ramps for newcomers (e.g. things like Calva for VS Code). I hope Jank keeps this up, because those first impressions really do matter. I'd hate to watch people bounce off Jank because they get stuck on trying to figure emacs out, or because they get frustrated trying to keep parentheses matched in Notepad.

Jeaye

You're absolutely right. To start with, I'm focusing on capturing and converting existing Clojure devs. However, there's a very large pool of C++ devs who could benefit from jank. As you said, jank not only needs to be ready for them, they need to be educated on lisps, functional programming, data-oriented programming, REPL-based interactive development, etc. It's not an easy learning curve right now, into Clojure.

I aim to focus a good deal of time, post jank's launch, to create materials which enable this. Materials specifically targeted at OOP devs coming from the native space.

vlovich123

As someone who might be in your target demographic in theory but not familiar with Clojure, what capabilities does Clojure itself offer as a language that a different mainstream scripting language doesn’t?

For example, I’ve always thought that the interesting part of Erlang is Beam & the uninteresting part was a niche language. Beam with JS as the language is much more approachable & leverages a rich existing ecosystem of tooling & libraries. Indeed, if you look at it the right way Cloudflare Workers is exactly that; isolated virtual processes within a single OS process that communicate with each other using a message based IPC & if they crash just the microservice is taken down & transparently relaunched.

So from that perspective, why Clojure instead of the same features on a different more popular language?

ndr

It's hard to describe what immutable/persistent data structures do to your thinking.

A lot of responsibilities move to the edges and you're left being able to think and tests pieces of code in isolation. The repl becomes usable, and you code from inside your running program. It's a steep step to get started but it's going to transform how you think about some problems.

butterisgood

I can imagine Jank being incredible “glue” to start until it takes over by osmosis. (For c++ of course)

Maybe I should play some advent of code games with it to get comfy!

lincpa

[dead]

roenxi

This seems like an opportunity to plug the good work https://www.clojuriststogether.org/ do. They do good work. Plug concludes.

Clojure - like many languages - seems to be benefiting a lot from the work the IDE people have been putting in to good infrastructure. A lot of the magic is being moved out of Emacs towards tools like Treesitter and the LSP server which are more platform independent. Not a huge amount to do with Clojure per say, but the Clojure ecosystem is benefiting a lot from it. The Emacs specific stuff is becoming very Emacs-specific (like paraedit, bless its socks).

waffletower

I am wary of LSP. I should try LSP again using eastwood, which probably has its trade-offs. While I absolutely admire Borkdude's many gifts to the Clojure community, the lack of static analysis in clj-kondo is a non-starter for me -- macro support is painfully manual. Because of its speed, clj-kondo likely is more performant in an editor LSP context, but too opinionated for me.

diggan

I think Clojure has benefit way more from nRepl and everything in that ecosystem, than LSP and that newfangled stuff, at least my personal setup relies on nRepl and doesn't even use LSP afaik.

ab5tract

The “use emacs” prerequisite that shows up frequently when exploring Lisps has been such a dealbreaker for me in the past. I have no patience for learning “chords” or even using a non-modal-but-still-not-just-normal-input editor simply to explore a language. My impression being that these chords morph depending on “modes” doesn’t help at all. At least with vim you can learn a piece at a time (sorry, not trying to revive last century’s favorite flame war, but it’s true).

Also: no one has managed to explain to me what makes emacs so uniquely capable of interacting with a running interpreter, despite this usually being the USP I hear for “needing” emacs when attempting to Lisp.

pritambaral

> Also: no one has managed to explain to me what makes emacs so uniquely capable of interacting with a running interpreter, despite this usually being the USP I hear for “needing” emacs when attempting to Lisp.

As an Emacs user that has to work in teams of non-Emacs users, the answer to this boils down to culture and ecosystem maturity.

Purely technically, there's nothing that Emacs allows me to do with REPL Driven Development that _couldn't _ be done in another editor. Practically? I still haven't been able to even get (sufficiently) started with any editor.

I often have to work on a Rails codebase that takes tens of seconds just to start. Dev cycles in the traditional Edit-Restart flow were so painful that I wished badly to burn this codebase down and rewrite it all in a language and style that supports a Lisp-style REPL. Then I discovered inf-ruby.el in Emacs. It allows me to just edit the code and reload only what's changed. It automatically inserts the correct `module Xyz; ...; end` etc. No more restarts.

I showed it to my coworkers. They shared the pain with restarts. And yet, to this day, none of them have an equivalent to inf-ruby in their editors.

inf-ruby.el is less than 1400 lines of code. It's easy enough to implement in Vim, IntelliJ, VS Code, anything really. But it exists only in Emacs, so far. Why? I'm sure because some Emacs user, once upon a time, wished similarly to have a more Lispy REPL for their Ruby dev work, and just built it. Because they were used to it, from having used Emacs or other Lisps with Emacs.

Compare that to when I first tried to support Common Lisp development on VS Code. A language that already has full support for REPL Driven Development with an interactive debugger built-in. Nope, we aren't gonna use any of that, because in VS Code land, we use LSP. A model that really only works for languages that can be statically analyzed. You want Go To Definition on a method that's included from a module and called on a receiver that's a dynamic variable? Well, sucks to be you, I guess.

So, while people make do with the severe limitations of Solargraph or Ruby-LSP, I use robe.el — which adds lisp style code intelligence by running inside your Ruby process — and get code intelligence that actually works with a language as dynamic as Ruby. Again, robe.el was just there for me to use. Again, there's nothing about Emacs that makes robe.el possible in Emacs but not in other editors. Again, there's no equivalent to it (that I've found) in the ecosystems of other editors.

ab5tract

This is honestly fascinating stuff, so thank you for sharing!

I wonder if it is an exposure issue: only those who use emacs know it is possible and those who know emacs have little incentive to leave their editor-OS.

I guess I’ll have to dig into some of these examples you have shared and see if I can comprehend and/or relocate their magic.

Jeaye

As the guy building jank, I agree with you about emacs, chords, etc. I'm a vimmer and I can tell you that Clojure is superb in Vim land (Conjure), VS Code land (Calva), Emacs land (??? some major mode), and IntelliJ land (Cursive).

chii

realistically, it's the REPL, not the editor, that makes lisp what it is - not just having a repl running, but to have your app be part of the repl, and you develop it bit by bit.

The javascript/UI people have found live reloading/editing to be a game changer, but this has been the case for lisp development since...well, the beginning!

ab5tract

Awesome to read this!

Since I’ve got you here, can I ask you for your thoughts on LispE and how it contrasts with jank’s approach? It seems clear that they both arrive from different lineages of the Lisp kingdom. LispE is also found dangling a few toes at depth within the icy waters of array programming.

Perhaps the only connection between the two is that the one makes me think of the other. But if there’s more, though, I’d love to read about it.

lincpa

[dead]

pjmlp

The proper answer for Lisps should be use Allegro or LispWorks, which actually provide a full blown environment as Lisp environments of by gone eras.

Does vim display inline graphics in a repl, with editing capabilities?

This is one of the basic features of classical graphical Lisp environments from the 1980's, IPython and Jupyter notebooks, or better, Mathematica are only building upon this.

Emacs and vim are not quite at the same experience level.

disgruntledphd2

Org mode in emacs does this. It's a little clunky but it definitely works (better than notebooks IMO).

veqq

> what makes emacs so uniquely capable

Emacs is easily programmable (and in lisp), more unixy than modern Linux, like a whole operating system. Lispers make tools for it because it's very easy for them. Lisp tools have been far advanced of others; LSP wasn't initially adopted in Lisp communities because better tools (swank) were already around.

dang

Related. Others?

I quit my job to work on my programming language - https://news.ycombinator.com/item?id=42658898 - Jan 2025 (32 comments)

Jank: Programming Language - https://news.ycombinator.com/item?id=42477992 - Dec 2024 (3 comments)

Jank is now running on LLVM IR - https://news.ycombinator.com/item?id=42276672 - Nov 2024 (16 comments)

Jank development update – Moving to LLVM IR - https://news.ycombinator.com/item?id=41845669 - Oct 2024 (49 comments)

The Jank Language: LLVM Hosted Clojure - https://news.ycombinator.com/item?id=32493217 - Aug 2022 (79 comments)

null

[deleted]

tombert

I'm not super familiar with this project, so forgive a bit of ignorance on this; what does this buy you over vanilla Clojure and native-image compiling with GraalVM.

This is a genuine question, not meant to dismiss the project!

ETA:

Sorry, further down the article answered my question:

> “jank is also a good fit for any Clojure devs who want a lighter runtime without sacrificing JIT compilation, as they would if they used a Graal native image, or if they want easy access to native libraries for whatever reason.”

Jeaye

The two biggest things are:

1. You get a native binary without sacrificing interactive programming. With a Graal native image, all of that goes away. With jank, you can still REPL in, change things, JIT compile code, etc.

2. You get Clojure -> JVM level of seamless interop from jank -> C++. I am pretty darn sure that this will be unprecedented, given the challenges of the native space (no standard reflection, differing ABIs, C++ templates, etc).

Aside from that, jank is making some huge quality of life improvements over Clojure JVM. I've shared some of this already, but I'll have a post coming out EOQ which will demonstrate the difference in compiler errors between the two. It's night and day.

tombert

I'm looking forward to it; being able to utilize C and C++ libraries directly from Clojure is something that I could see being pretty valuable.

I've been debating trying my hand at making a simple game engine...it would be great if I could use a Lisp to do it.

2mlWQbCK

Did you look at Janet? Of course there are many other embeddable LISPs, but I think in particular Janet is a good, light, (subset of) Clojure-like language.

It is built into TIC-80 by default, making it already useful for (small) games.

https://janet-lang.org/ https://tic80.com/

lelanthran

You can use lisp with almost native C support, if you use ecl or gcl.

joeevans1000

You can compile a native program. Not one that requires the JVM. And it also interops with a number of more native graphical tools (as opposed to having other use things that require/work-from java). To those coming to this thread who might not be familiar with Clojure: Clojure already can sit on top of javascript (as Clojurescript) and there was work making it work on top of, if I recall right, some of the C languages. But those latter ones don't seem to be anywhere near the capabilities of this project.

vmsp

Looks similar to Clasp but implements Clojure instead of Common Lisp.

https://clasp-developers.github.io/

mark_l_watson

Cool. I tried to build Clasp from source a long while ago, and failed. Now a brew install….

binary132

Clasp is really cool but it’s a shame that it does not support Windows properly. A lot of C++ is used on Windows. I’ve seen this pattern repeated elsewhere — I think it has to do with Windows exception handling being different and complicated. Hopefully jank does not suffer the same fate, since author is a gamedev!

elcritch

The Jank creator talking with folks at CERN about integrating with their C++ codebase makes sense too. Clasp was originally used to do some molecular simulation if memory recalls.

hatmatrix

Good point. When Clojure first came out it was questioned whether it's a lisp at all, but now I commonly hear many say it is the best Lisp.

aaronbrethorst

How is it pronounced? Dzank or Yonk?

barrell

Always happy to see clojure on the front page, doubly happy to see jank! I just scoured the internet last week trying to find all the information I could on it.

As a clojure(script) developer of 10 years, I still try and avoid anything JVM related. Not that I have anything against the JVM — but I never did any Java programming, and to really learn about the JVM you have to learn quite a bit about Java… which is just very low on my priority list.

I have been dreaming about jank a little bit, so maybe this is a good place to ask the question, since I see the jank developer is reading the comments: would it be possible to write a module in jank that can be used in a Swift/iOS application (currently or in the future)? I assume so, but I’m not sure how accessible the outputs of jank are to other c libraries.

The reason I ask is I have an offline clojurescript front end. If I want native mobile apps, that means I either have to duplicate the logic, figure out some JavaScript bridge, use react native, or use dart — none of which seem ideal. Ideally I could just extract the critical business logic into a few modules and generate the header files for swift, import directly into cljs for web, and use as regular clojure for android.

Totally understandable if this isn’t a valid use case for jank, but it’s what’s captured my imagination :)

danbolt

I really appreciate the seamless rawdogging into C++ that this language provides. It’s the sort of ambition I’m here for.

Or, I find a lot of script runtimes in games have a strict boundary separating them from the native code (often for good reasons), but I wonder if we could integrate more tightly given static analysis has come a long way.

rcarmo

Somehow I completely missed this. I mostly stopped using Clojure solely because of the JVM madness (yes, I know about babaskha, won’t use it due to the GraalVM dependency and possible Oracle tentacles lurking there) and have fallen back to things like Hy (which can be clunky but at least runs everywhere I have a Python interpreter). Something that has better Clojure-like syntax and uses LLVM aid very appealing, provided it can do (and serve) HTTP requests sanely and has enough batteries included.

Any good pointers to existing libraries to get a feel for the ecosystem?

bobnamob

As far as I'm aware, jank isn't at the point where libraries exist. It's still under initial development and doesn't implement all of Clojure just yet.

sorry_i_lisp

No value judgment, what do you mean by "JVM madness"?

rcarmo

Slowness and bloat, plus the sheer dependency footprint.

Tcepsa

As a long-time fan of Clojure (I've been using it to varying degrees since 2008 and it is my favorite programming language) I'm really excited about the interpretability it sounds like this will open up!!

fuhsnn

>Seamless C++ interop

More detail would be appreciated, I'm not aware of any non-transpiling language that actually support full C++ RTTI/exceptions interop.

pritambaral

Clasp, and implementation of Common Lisp in C++ on LLVM, has exceptions interop. The creator of Clasp even hooked up the Lisp GC to be able to automatically manage C++ objects. A compacting GC, mind, that automatically updates pointers to the managed C++ objects that it moves.

senkora

That’s pretty cool. I would love to hear more about how this works.

In particular, whether it is restricted in practice to types that are std::is_trivially_relocatable.

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p11...

Jeaye

More detail to come. You're right, it's unprecedented.