Janet: Lightweight, Expressive, Modern Lisp

by veqqon 7/27/2025, 1:28 AMwith 109 comments

by uvas_pasas_peron 7/27/2025, 2:30 PM

Lisp is very cool. But one thing I do not like is that the syntax style `(fun a b c)` loses out to the less-symmetric "OO" style `a.fun(b, c)` when it comes to IDE auto-completion. And for me the IDE help is important to provide a smooth developer experience and minimize wasted brain energy. I'd like to find a way to make the editing and auto-completion work better. I think the way IDEs (and maybe our brains) work is: "here is a thing X, now what can I do to/with it?". That translates to typing in your editor: "X.[cursor here]", and then the IDE lets you see and search the things you can "do" with X. But if, in Lisp, you write "([cursor here]", you are immediately confronted with: "what is the signature of that function again?", but the IDE has nothing to go on. Maybe there is different style of editing, where we could type the arguments, and then trigger the auto-complete.

by zelphirkalton 7/27/2025, 11:56 AM

When I see languages like this, I always wonder, how far the ecosystem is. I have used GNU Guile a lot and there are quite a few libraries for it, so that one can do almost anything. Web things are coming, but maybe not as fully there yet, as one might like. Racket also has lots of libraries. And even a standard library web framework.

So lets say I want to start my next web project in Janet. I already know Scheme and can probably quite easily just start writing another lisp, assuming it has TCO and I can do things mostly like I would in Scheme, except maybe for having to use funcall (which is annoying, but OK). Does Janet have libraries, that enable web projects? Like a web server and SXML or something like that? Or does it have things like a JSON parser? All these little things one would like to have, to not have to develop the basics first, before getting to the actual project.

And what about data structures? Are there functional data structures available? In GNU Guile I have at least the unmaintained guile-pfds. Hopefully, I will one day understand enough about functional data structures to build more or to maybe even maintain that library. But learning resources are scarce. It is already difficult to find a functional version of an AVL tree! Lots and lots of places merely teach non-persistent, non-functional versions of these data structures, and it is not trivial to translate them, might impact performance in ways that are not necessary, if one had great knowledge about how to make these data structures.

And also reproducibility! With GNU Guile I have what I need on Guix, which is great! With other languages, I might need to rely on older package managing approaches, that do not have reproducibility/determinism as the a high goal on their agenda, or might even lack the ability to create lock files/files with checksums. I don't want to go back to non-reproducible.

I am also eyeing statically typed variants like Carp. Same questions arise. Some seem really great and I would probably enjoy using them a lot. Would be a pity to then discover, that the ecosystem is just not there, and one has to create all the basic tools one needs oneself. Sometimes that can be fun, but it can also be exhausting and one never gets around to ones actual project.

by mesaoptimizeron 7/27/2025, 10:11 AM

Also see https://janet.guide/ for a good introductory book to Janet.

by dmpk2kon 7/27/2025, 9:27 AM

Does it have a native compiler and/or types? Basically, can it get in the ballpark of SBCL's performance?

It'd be nice to have something cleaner than Common Lisp, and a much smaller image size. If it has decent performance too, I'm sold.

by rich_sashaon 7/27/2025, 6:30 PM

Is there some kind of decision tree for "which lisp should i use?". CL, Scheme, Racket, Clojure, Janet... Elisp at least is clear :)

by bjolion 7/27/2025, 6:13 AM

Is there anything that is janet-unique? I just did a cursory glance, and most of it seems like a scheme with slightly different syntax and a more "modern" standard library.

Why should I switch from my scheme of choice (guile) to Janet?

by NeutralForeston 7/27/2025, 9:57 AM

Janet is awesome but pretty please, work on the tooling. There's very little in the way of working and debugging interactively with the REPL from any IDE that I know of and last time I tried (on Emacs) there was barely a dedicated mode to work with it.

by nemoniacon 7/27/2025, 10:28 AM

The first code example on that page claims to solve "the 3SUM problem".

According to [1], "the 3SUM problem asks if a given set of n real numbers contains three elements that sum to zero."

It's not clear to me what problem the Janet code solves but it's clearly not that 3SUM problem.

On the example input of

    @[2 4 1 3 8 7 -3 -1 12 -5 -8]
it outputs

    @[@[6 1 7] @[2 5 10] @[1 2 9] @[4 6 9] @[3 0 9] @[6 2 0]]
For what it's worth, here's some Common Lisp code that does solve the 3SUM problem in O(n^2).

    (defun 3sum (a)
      (let ((h (make-hash-table))
            (len (length a)))
        (dotimes (i len)
          (setf (gethash (aref a i) h) t))
        (dotimes (i len)
          (dotimes (j i)
            (when (gethash (- (+ (aref a i) (aref a j))) h)
              (return-from 3sum t))))))
    
    (3sum #(2 4 1 3 8 7 -3 -1 12 -5 -8))
    ;; => t

[1] https://en.wikipedia.org/wiki/3SUM

by dustedon 7/28/2025, 10:13 AM

Looks great, I like the clean syntax and in particular the defn is pretty.

I lost interest before I got to implementing proper functions, so mine only has variables that can be executed, if you're interested, it's here http://dusted.dk/pages/slispRepl/ but it's a mess, and only interpreted.

by raydenvmon 7/27/2025, 10:12 AM

Are there any known commercial use cases?

by firemelton 7/28/2025, 5:29 AM

I can't handle the line noise :(

by revskillon 7/27/2025, 10:20 AM

I do not see how it handles async await

by WillAdamson 7/27/2025, 11:40 AM

It is unfortunate that there doesn't seem to be a GUI library --- if there was one _and_ if one could easily compile to a stand-alone program for distribution, this would be very interesting to me.

For bonus points, compiling to a stand-alone JavaScript wrapped in HTML would be awesome if it could be hosted on a Github page.