Thanks for linking this! I got to absorb some of his enthusiasm for the language.
Janet’s macros are not hygienic, and Janet does not have a separate namespace for functions. But by allowing you to unquote literal functions, Janet makes it possible to write macros that are completely referentially transparent. It’s an incredibly simple and elegant solution to an otherwise very delicate problem.
I know very little about Lisp macros, other than the fact that Lisp is famous for them. But it sounds like Janet has a new/unusual take on macros?
This book was a big help to me in deciding to use a Lisp (yes, I know) for day-to-day stuff. While I mostly program in C and C++ on microcontrollers, for system scripting I just kind of slid into Python due to starting out there for microcontrollers due to library support. I am efficient in Python but I don’t feel like the programs are particularly readable or concise. And I would like to think in terms of recursion a bit more often and stretch my mind a little there. I had been dabbling in tiny Lisps but wanted more practicality. I’ve started learning Janet by way of doing Everybody Codes challenges, which seems like a good iterative way to get better and think differently. But I owe the motivation in the first place to this book and to Janet’s docs, in-REPL and online both.
This has been posted before, but I’m compelled to say that this is the book that nudged me into finally using a Lisp. Janet looked neat, but I didn’t understand why I’d use it instead of an established language like Common Lisp. So I learned Common Lisp using the book Practical Common Lisp, and it was great!
But then I learned why Janet is interesting: a < 1 MB, embeddable Lisp-like language with lots of handy features built-in is actually probably closer to what I want for my projects, because I’m allergic to overhead and bloat (and I don’t usually need peak performance). Unfortunately, I didn’t end up liking the concept of avoiding lists, in favor of arrays, buffers, dictionaries, and tables. I much prefer the uniform syntax of Scheme and Common Lisp. Basically, I want a Scheme/Common Lisp-inspired Janet, instead of Clojure-inspired like Janet. And such things probably exist, although I haven’t found one that is as easy to embed.
Regardless, Janet for Mortals is a great book, and I enjoyed the writing style. I highly recommend taking a look if you’ve ever wondered why Janet (or Lisps generally) are unique.
Have you tried S7 Scheme? It’s a Scheme that’s part of the SND sound editor project. It comes as single C file you can just drop into your codebase. It’s also extremely well-tested.
If you don’t mind a bit more heavyweight (but tunable at compile-time), and want a more standard Scheme, you could use chibi, which served as the reference implementation for r7rs. It was also explicitly designed to be a “better” embeddable Scheme (before, most people would typically use SIOD or TinyScheme).
edit: also of interest is picolisp which does a lot in a small space.
edit 2: I just remembered there’s also librep, the Lisp written for the Sawfish window manager. It’s inspired by Elisp, but more like a Scheme (it has one namespace and static binding) and also fairly small (if you don’t link it against libgmp).
In theory, I feel like I should prefer Scheme because it’s simpler and has many implementations to match to my use cases, but in practice the fragmentation and incompatibilities frustrate me.
Having said that, s7 is definitely on my list to explore. Chibi was oddly slow for me. I’m also eyeing npt (a C implementation of Common Lisp). CLISP also is neat, though not my preferred programming license. But Janet just has such an awesome standard library that it’s hard to beat in < 1 MB.
in practice the fragmentation and incompatibilities frustrate me
This is a common thing beginners feel. But once you select an implementation you will just stick with that and the fragmentation and incompatibilities are a total non-issue. Especially if you do it for embedding - you’ll just use the one implementation anyway. Also, with R7RS, portability should already be a lot better.
Note that if you had picked Janet, Picolisp or Librep, that would also effectively lock you into a single dialect of Lisp, with even less portability from other Lisps.
Janet indeed looks like a good scripting language. When a script becomes too long for Bash, Python is usually considered as an alternative, but Janet seems nicer in this case because it is much more easier to embed shell commands with an sh package. Now I’m definitely going to give Janet a try.
Also I like the style of writing, and I enjoyed reading it with all the small jokes all over the book.
The most interesting part for me was fibers and that you can achieve quite much with them (coroutines, concurrency, early returns, error handling, etc.). The first two are not surprising as fibers are widely used both for coroutines and concurrency, but I wonder if any other language uses fibers for error handling.
The “Why Janet” blog post mentioned in TFA is also worth reading.
Thanks for linking this! I got to absorb some of his enthusiasm for the language.
I know very little about Lisp macros, other than the fact that Lisp is famous for them. But it sounds like Janet has a new/unusual take on macros?
This book was a big help to me in deciding to use a Lisp (yes, I know) for day-to-day stuff. While I mostly program in C and C++ on microcontrollers, for system scripting I just kind of slid into Python due to starting out there for microcontrollers due to library support. I am efficient in Python but I don’t feel like the programs are particularly readable or concise. And I would like to think in terms of recursion a bit more often and stretch my mind a little there. I had been dabbling in tiny Lisps but wanted more practicality. I’ve started learning Janet by way of doing Everybody Codes challenges, which seems like a good iterative way to get better and think differently. But I owe the motivation in the first place to this book and to Janet’s docs, in-REPL and online both.
This has been posted before, but I’m compelled to say that this is the book that nudged me into finally using a Lisp. Janet looked neat, but I didn’t understand why I’d use it instead of an established language like Common Lisp. So I learned Common Lisp using the book Practical Common Lisp, and it was great!
But then I learned why Janet is interesting: a < 1 MB, embeddable Lisp-like language with lots of handy features built-in is actually probably closer to what I want for my projects, because I’m allergic to overhead and bloat (and I don’t usually need peak performance). Unfortunately, I didn’t end up liking the concept of avoiding lists, in favor of arrays, buffers, dictionaries, and tables. I much prefer the uniform syntax of Scheme and Common Lisp. Basically, I want a Scheme/Common Lisp-inspired Janet, instead of Clojure-inspired like Janet. And such things probably exist, although I haven’t found one that is as easy to embed.
Regardless, Janet for Mortals is a great book, and I enjoyed the writing style. I highly recommend taking a look if you’ve ever wondered why Janet (or Lisps generally) are unique.
Have you tried S7 Scheme? It’s a Scheme that’s part of the SND sound editor project. It comes as single C file you can just drop into your codebase. It’s also extremely well-tested.
If you don’t mind a bit more heavyweight (but tunable at compile-time), and want a more standard Scheme, you could use chibi, which served as the reference implementation for r7rs. It was also explicitly designed to be a “better” embeddable Scheme (before, most people would typically use SIOD or TinyScheme).
edit: also of interest is picolisp which does a lot in a small space.
edit 2: I just remembered there’s also librep, the Lisp written for the Sawfish window manager. It’s inspired by Elisp, but more like a Scheme (it has one namespace and static binding) and also fairly small (if you don’t link it against libgmp).
In theory, I feel like I should prefer Scheme because it’s simpler and has many implementations to match to my use cases, but in practice the fragmentation and incompatibilities frustrate me.
Having said that, s7 is definitely on my list to explore. Chibi was oddly slow for me. I’m also eyeing npt (a C implementation of Common Lisp). CLISP also is neat, though not my preferred programming license. But Janet just has such an awesome standard library that it’s hard to beat in < 1 MB.
This is a common thing beginners feel. But once you select an implementation you will just stick with that and the fragmentation and incompatibilities are a total non-issue. Especially if you do it for embedding - you’ll just use the one implementation anyway. Also, with R7RS, portability should already be a lot better.
Note that if you had picked Janet, Picolisp or Librep, that would also effectively lock you into a single dialect of Lisp, with even less portability from other Lisps.
I’m sure you’re aware, but in case anyone else stumbles upon this thread: compatibility across implementations is one spot where Common Lisp shines.
Clarification for posterity: I meant to say that GPL isn’t my preferred license for a programming language runtime.
I have just finished reading the book.
Janet indeed looks like a good scripting language. When a script becomes too long for Bash, Python is usually considered as an alternative, but Janet seems nicer in this case because it is much more easier to embed shell commands with an
sh
package. Now I’m definitely going to give Janet a try.Also I like the style of writing, and I enjoyed reading it with all the small jokes all over the book.
The most interesting part for me was fibers and that you can achieve quite much with them (coroutines, concurrency, early returns, error handling, etc.). The first two are not surprising as fibers are widely used both for coroutines and concurrency, but I wonder if any other language uses fibers for error handling.
The book and Janet were discussed last year.
add ‘lisp’ tag