| ▲ | dmpk2k 6 days ago |
| 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. |
|
| ▲ | ethan_smith 6 days ago | parent | next [-] |
| Janet uses a bytecode VM that's faster than many dynamic languages but won't match SBCL's native compilation performance; it has optional type annotations for documentation but not for optimization. |
|
| ▲ | netbioserror 6 days ago | parent | prev | next [-] |
| It's a lightweight embeddable interpreter and runtime, similar to Lua. Dynamically and strongly typed, but no native compilation. Easy to call C libraries, or embed into C projects. In my testing, it's roughly twice as fast as Python for similar tasks. You can "compile" a project by embedding scripts and resources with the runtime into a bundled executable. |
|
| ▲ | terminalbraid 6 days ago | parent | prev | next [-] |
| Janet does compile to standalone executables with jpm |
| |
| ▲ | xigoi 6 days ago | parent [-] | | Just keep in mind that these executables are the Janet bytecode interpreter bundled with your bytecode, not “real” native executables. | | |
| ▲ | terminalbraid 6 days ago | parent [-] | | No, they are actually real executables without the need of an external runtime. You can get images also if you like. See quickbin in the jpm man page. > Create a standalone, statically linked executable from a Janet source file that contains a main function. and discussion here https://janet.guide/ > My favorite feature of Janet, though, is something that sounds really dumb when I say it out loud: you can actually distribute Janet programs to other people. You can compile Janet programs into statically-linked native binaries and give them to people who have never even heard of Janet before. And they can run them without having to install any gems or set up any virtual environments or download any runtimes or anything else like that. They're not super tiny, though. A hello world I just did is about 727K. | | |
| ▲ | packetlost 6 days ago | parent | next [-] | | No, gp is correct, the 'real executables' are a VM image with the interpreter baked in. The only native code in the binary is the interpreter. Janet code does not compile to machine code. | | |
| ▲ | terminalbraid 6 days ago | parent [-] | | I understand your point, but by similar logic I can argue any language is interpreted because nothing compiles down to microcode. The point is you don't need janet-specific external dependencies in the environment. I don't differentiate between this and an inefficient compiler. | | |
| ▲ | packetlost 6 days ago | parent | next [-] | | > I can argue any language is interpreted because nothing compiles down to microcode Not every processor architecture uses microcode, so this doesn't hold up. > The point is you don't need janet-specific external dependencies in the environment Sure. > I don't differentiate between this and an inefficient compiler A compiler is the general term here, but the target is not. Targeting the native architecture for a CPU vs targeting a bytecode VM are quite different and have pretty important implications for performance, portability, memory usage, etc. | |
| ▲ | xigoi 6 days ago | parent | prev [-] | | The distinction matters because the resulting executable is not (significantly) faster than running the program as a script. | | |
| ▲ | massung 5 days ago | parent [-] | | I think the distinction (from the OP’s perspective) is that it’s “just an app” to the end user. When I download the Slack desktop app, I might know it’s running on electron because I’m a programmer. But I didn’t have to download and install nodejs or anything else. As far as I’m concerned it’s a completely self contained application. The end user needn’t download and install Janet or even know that Janet exists. That can obviously be done with any interpreted language, but Janet makes it really simple out of the box. |
|
|
| |
| ▲ | xigoi 6 days ago | parent | prev [-] | | From the book you linked: > But in order to produce native code, jpm actually: > 1. Compiles your Janet source code into an “image.” > 2. Embeds the contents of that image into a .c file that also links in the Janet runtime and interpreter. > 3. Compiles that .c file using your system’s C compiler. https://janet.guide/compilation-and-imagination/ | | |
|
|
|
|
| ▲ | atemerev 6 days ago | parent | prev [-] |
| This is not a replacement for Common Lisp. It is in the same niche as Guile (but quite faster). |
| |
| ▲ | terminalbraid 6 days ago | parent | next [-] | | Yeah, I see Janet as "what Guile intended itself to be", though it is quite a bit smaller (in some ways that's a postive). I find the choices it made to be more pragmatic and it's far more accessible in non-linux environments since Guile tied itself closely to guix. | |
| ▲ | anthk 6 days ago | parent | prev [-] | | Current Guile it's much faster. |
|