News for hackers. Stuff that matters.
Re:I Accidentally a Scheme by TylerE on Wednesday November 15, 2023 @01:10AM (#38273809)
Ooh that's actually really interesting. I've always been a bit into lisp... even did a bit of amatuer CL back in the day..but always thought the distribution model of basically a memory dump was just the worst of all possible worlds.
Re:I Accidentally a Scheme by bigfishrunning on Wednesday November 15, 2023 @03:29PM (#38281997)
I agree with this sentiment -- from a reproducability standpoint, CL images aren't great. My workflow has always been to maintain a source file and then use emacs to shove s-expressions into the repl -- that way, rather then save the image, i can just re-evaluate my source file and get a reasonable facsimile
Re:I Accidentally a Scheme by cfiggers on Wednesday November 15, 2023 @06:50PM (#38284063)
Janet has an excellent distribution story (IMHO, anyway). You can do everything from Python-style distribution of .janet scripts all the way up to compiling stand-alone native executables.

You can also do the memory dump thing, if that's your preference--and, under the hood, that's actually how the native executables work too. The Janet compiler/interpreter and core library all together is approximately 1MB in size (that's not a typo! One Megabyte!). So when you compile an executable, what you're really doing is packaging together a serialized image of the compile time state bundled together with a full copy of the Janet abstract machine. On startup, the Janet runtime boots (extremely quickly, FWIW), it rehydrates the compile time state (which includes all your function definitions, variable declarations, etc.), and then it executes your `(main)` function.

This means there's all kinds of compile-time metaprogramming magic you can do _without_ needing a whole separate build language to do it, and also without impacting run time performance (like, for e.g., macro expansion all happens during that step). Because all that will have calculated during compilation, the results are saved to your embedded image and so they'll be accessible at run time, wherever and whenever that may happen.

I'm honestly not that well-educated on programming languages in general so I don't know if this is all super boring run-of-the-mill type stuff that other languages do too (probably so), but learning how Janet does it was super fun when it all clicked in my brain and it's the one language I know a little bit about, so hey, now you get to know about it too. :)