Not to mention https://bauble.studio/ from the same author!
It doesn't work in my browser - which is understandable because my computer is ancient - but sometimes when I want a break from study in the library I'll spend thirty minutes on a library computer playing in bauble there. I might get around to trying to figure out how the thing works, but the graphics you can make just fiddling with numbers is wild.
Long life to Janet.
For me, on a 2021 MacBook Pro M1 Max, on MacOs 15.1.1, it appears to work in Chrome but in Firefox shows this error.
error: script:16:1: compile error: unknown symbol twist
in evaluate [lib/evaluator.janet] on line 81, column 7
in bauble-evaluator/evaluate [lib/init.janet] on line 8, column 12
delete the contents of the script and then refresh — you’ve loaded an old version of bauble before and have the old tutorial cached in localStorage :/
It's neat to compare Janet to GNU Guile. Guile's original pitch is that it's intended to be easily used side-by-side with C. However, because it's an older language, it hasn't (to my knowledge) picked up newer sensibilities like having a package manager shipped with the language toolchain.
One thing I like about Guile is how much effort they've put into describing compatibility with the RNRS standards. Not sure how Schemey Janet actually is, but I'm curious to find out.
Janet it not Scheme-like at all. It's more like if someone made Clojure on top of Lua.
Which is really funny because that's basically exactly what fennel is, which was made by the same guy. I don't think he's written about it but fennel compiles to lua while janet is its own thing.
This is funny, cos I saw this stated somewhere on HN the other day, was totally amazed he'd done both, went and checked, and found out it was untrue - I think! Someone correct me please if I'm confused.
Calvin Rose made Janet https://github.com/bakpakin and https://bakpakin.com/
Phil Hagelberg made Fennel https://git.sr.ht/~technomancy/fennel and https://technomancy.us/colophon
It's complicated; Calvin Rose was the original creator of Fennel ("fnl"), but I understand it was just a little side project that he made over the course of a week or so in college. Phil Hagelberg found the project years later and thought it was cool, took over as its maintainer, and basically turned it into the Fennel you know today. So it's like, kind of, I dunno, both things are kinda true.
That's even more funny in the end, I thought GP was referring to Phil Hagelberg as creator of both, but they were referring to Calvin Rose as creator of both. Oops. Mystery solved.
Anyway - Fennel and Janet look very interesting, and a large thank you to everyone involved!
Correct. Syntactically it's more similar to Clojure while the runtime is, to my understanding, heavily inspired by the non-JIT versions of Lua.
As a language, it's fine. I found the documentation pretty good and the language makes some very sensible decisions but I can't bring myself to use it for anything serious. The lack tooling makes it challenging.
I personally like Fennel a lot, but it’s not at the point where I would build something large on top of it. The language itself is solid, but like you said, there’s not a lot of tooling.
I have used janet for embedding into another program as an alternative to lua and it was great for that case. Lua doesn't have good tooling either, and I didn't have anything to gain from a tiny runtime and I wanted more powerful tools for making a DSL in there. It worked out perfectly, I'd do it again.
Yeah, I'm not saying there aren't usecases that it would excel at (sounds like you found one!), I just haven't really had a problem that I thought it would yet. I've come really close though
> "the turtles are metaphors"
:( The turtles were real, not metaphorical: http://classicacorn.computinghistory.org.uk/8bit_focus/logo/...
(it fits the definition of metaphor 'One thing conceived as representing another; a symbol' but it has the feel of people saying "my niece thought the floppy disk save icon is a refrigerator because that's where you save leftover food" not realising that it was a real piece of fun/cute hardware many moons ago).
I don't think that what's displayed on that page is a "real" turtle...
It is a real “turtle”, however.
Ha! You never know when you are going to run into a point-of-view that would be on the fast track to 'closed as off-topic' if anyone asked a question about it on the philosophy stack exchange.
I enjoyed this book’s practical take. It’s a big part of why I am currently learning Janet by doing Everybody Codes in it right now.
The title made me believe it was just another AI assistant (thinking Janet from "The Good Place" - but for us non-dead people instead. Was pleasantly surprised to see it is a programming language and that the title was just a clever joke on that:
The Janet language is named after an immortal being in The Good Place who helps mortals navigate the afterlife, hence the title.
It kinda surprised me that they ship the language with a PEG (parsing expression grammer) instead of a basic Regex engine.
This has been my wish for any programming language that ships a Regex library by default to also include a capable PEG. GNU Guile also has a PEG library in its standard library (see <https://www.gnu.org/software/guile/manual/html_node/PEG-Pars...>).
Janet's 'spork' module is kinda like their libc, and has a regex submodule; it's very likely to be installed.
Janet is my first exposure to PEGs, so nothing to compare against but I love how powerful and easy they are. I have a better grasp of them in only a few months than dabbling over 20yrs with regex.
Also there is quite a bit of The Good Place callbacks within the Janet community; numerous 3rd party modules are named after characters, for example.
I had also not seen PEGs before, but the way you can use parsing node identifiers recursively (and mutually recursively) seems very intuitive.
Elm does something similr. Neither elm/regex nor elm/parser are built-in, but elm/regex encourages you to use elm/parser instead.
btw, I like the namesake, but a language named Janet is pretty much obligated to also prioritize control.
Off topic - a separate blog post by TFA got me into split mechanical keyboards. It helped me after years of shoulder and wrist pain. Highly recommend exploring other posts by Ian.
This book got me started with Janet a few months ago, and I really think it helped me get past the difficulty I've had in the past starting with Lisp-y languages (Janet is Lisp like only in appearance afaik) but this just clicked. I'm having a lot of fun writing Janet and refer back to the book often.
I do think the macro example that is early in the book is a little overwhelming; if you can get past that everything is far easier. Whats great is that you can leave the author a comment right from the repl, so I did :)
I really like the slightly silly writing style! Reminds me of a toned-down Douglas Adams. Honestly, I'm not particularly interested in Janet but the style sucked me in.
Absolutely love the writing style, which was the reason I got sucked into functional programming and the Janet language deeper than I'd had previously wanted to.
Thank you!
> Okay great. I think that’s a totally reasonable second code sample ever for you to look at.
I like it.
I've read the book and I found it very fascinating and kind of playful, which actually makes learning the Janet program language much more fun. However, I found the documentation of the language lacking in many ways. Oftentimes there are functions or commands that are just there, but there's no example or explanation. or explanation as to what they do. In fact, there are a lot of those that I found in the book, but I couldn't find in the documentation. So this is one of the reasons I stopped learning Janet, even though I really like the idea of this language, and the fact that it has many sane defaults and similarities to mainstream languages instead of like adhering to archaic Lisp conventions. At the end of the day, it's not actually a LISP because it's not cons lists. And it is fine by me, but again, I found the language not fully documented.
Do you remember any of the functions/commands that were not documented? I'm semi active in the Janet community and would be able to work on improving the docs where its lacking!
I had exactly the same experience (minus reading the book). Often, I'd just see the function signature and no further explanation. I do realise that it takes a lot of time and effort to build up extensive docs, but it happened enough that I put it down and started looking for another Lisp that compiles down to a binary.
I'm curious, which Lisp did you end up choosing?
I'm still looking around, but Owl is a frontrunner.
If the bigger runtime isn't a deal breaker, maybe look at Racket.
Janet looks really interesting. Especially with how easy to embed it is.
If I understand it correctly creating DSLs in it should also be very easy with its macro and PEG feature?
Writing DSLs is very easy, and fun! The PEG grammars are very elegant to build up. I wrote a language for programmatic recipes (think scaling, unit conversion, etc) with it and it was a delight. I'd provide an example but I haven't taken the time to write a README so I haven't published it publicly yet.
Hey that's cool. Are you willing to instead share an example snippet of what the DSL itself looks like?
Here's an excerpt (which is in a map passed to peg/compile) for numeric parsing:
:nonzero-int (* (range "19") (any (range "09")))
:int (+ "0" :nonzero-int)
:decimal (cmt (* (? (<- :int)) "." (<- (some (range "09")))) ,parse-decimal)
:fraction (cmt (\* (? (\* (number :nonzero-int) :s+)) (number :nonzero-int)
"/" (number :nonzero-int)) ,parse-fraction)
:integer (cmt (number :nonzero-int) ,parse-integer)
:num (+ :decimal :fraction :integer)
I'm pretty new to it, but from what I've seen the answer is yes. And while I haven't wrote any macros yet I think PEGs are fantastic, and sooo readable. Their website has an example PEG to read Janet source - https://janet-lang.org/docs/syntax.html#Grammar
Embedding is really easy, as is writing c modules. You can link shared, or use an amalgamated c file. Check out https://janet-lang.org/capi/embedding.html
Honestly I'm having just as much fun learning Janet as I am writing C modules and embeddings; Janet all the things!
It's an incredible lua replacement for embedding. A lot of the time for an embedded scripting language you're defining a DSL which bare lua is fairly poorly suited to. And you lose the tininess and simplicity of the embedding if you're having to cram PCRE and shit in there too.
Janet basically just copies lua's C interop because it's the best part of lua. And then with PEGs and a solid macro system you're in a much better position for scripting, or defining a scripting environment, or a configuration DSL, or whatever you wanted a non-C language for.
“We’ll start with some numbers” I was expecting he’ll start by proclaiming it’s that language that uses floats for integers.
The style and tone of this book (website) is quite funny, I really enjoy it.
> ... has a built-in repl. At any point you can press escape and pull it up, and it’s docked to the bottom of the page...
probably not a good decision to use `Esc` since browsers have default bindings for it. firefox exits fullscreen on `Esc`
I couldn’t get into Janet, I’m not sure if this is a personal failing on my part. The only other Lisp I’ve spent any significant time in is Emacs Lisp, and everything in Janet seemed similar enough to that but just subtly different that I was always making silly mistakes. The PEG features were really compelling on paper but I found the syntax unwieldy and confusing. The documentation was complete in that it had descriptions of all the functions, but spartan in that it lacked examples or other helpful usage information. There didn’t seem to be any basic batteries included such as JSON parsing; if I want to write a quick script in a language and I have to first write a JSON or XML parser, task is already failed.
This was like four years ago, so maybe the ecosystem is better now. Or maybe scripting was the wrong ruler to measure Janet by. I don’t know but this post is making me want to reinstall it.
They put things like JSON and regex in the 'spork' module, which is kinda like libc; theres a strong internal drive to keep the core light. Many projects depend on spork, so it its likely to be installed on early.
The docs are decent, though I agree there are still gaps in practical examples, this has been supplemented by https://janetdocs.com, which are linked as "community examples" per function
This is a very "Internet" comment, but what struck me about the title and very many other titles in the software engineering world is that I'm not sure it's the best idea to belittle readers in the title. The implication of "<x> for normal people, mortals, dummies, etc." titles is that the reader is not on the level of the author of the book and the authors of the tool or topic that one is learning about. Specifically, "for mortals" implies the author and programming language author are immortals, or at least not mortal. I realize this is taking the title more seriously than probably intended, but this type of framing pops up a lot in the software and programming world.
hi, i am the author of this book and i agree with you. it's not a good connotation. i chose it because: 1. it is kinda memorable (look there are so many programming books with exactly the same name) 2. the language is named after an immortal being who guides mortals through the afterlife in the fictional property the good place, so there's some kinda connection. but i agree the implication that janet is somehow "hard" to learn or that the author is somehow "on a higher plane" is bad. i waffled on this a lot but never came up with another title i could stand and ultimately just pulled the trigger. (but note that i left myself some wiggle room with a neutral domain name.) i hope the tone of the book itself helps to counteract the title, but ya know who knows
This isn't really a specific complaint about this book. Just triggered my thoughts on a general theme. Thanks for writing the book. I might look into it, as I'm generally interested in Lisp/Scheme-likes.
I could see this is if the title was "for morons" (or something like it), something implying a class division. But 100% of humans are mortal. Everyone is mortal, including the author. So there's no real division here, no two tiered system: we are all on the mortal tier.
For that matter, the For Dummies books have subtitles that refer to "the rest of us". So the actual reader as well as the author are not necessarily one of the dummies.
I think a more charitable interpretation of the title is an implication that the other material written for Janet was written for supergeniuses (or whatever), so here's a book finally written for normal people.
This is very cool:
> this book contains a repl, and you can summon it whenever you’d like by pressing the escape key on your keyboard. The book will then start downloading like a megabyte of JavaScript and WebAssembly, and once it’s done you will be able to try out Janet right here in the comfort of your browser. No need to install anything; no need to leave the comfort of this book website if you’d like to test something out.
> The repl is not just a repl, though. It is also a portal into conversation with me, the author. You can use the repl to report typos or factual errors, ask questions, or express confusion. I won’t be able to respond in the repl, but if you include some kind of contact information in your reports I will make an effort to follow up with you.
I’m holding out for the one written for immortals.
I am not waiting for Janet for Ethereals. Once it ships, it will always have been available.
Meanwhile I'm waiting on "Janet for Normies" for myself
Ooooh, is this the start of a series - who's going to do those two, and then "Janet for Aliens", "Janet for the Rest of Us", "Janet for Dummies", and so on. The titles write themselves!