CFiggers / janet-lsp

A Language Server (LSP) for the Janet programming language.
MIT License
30 stars 8 forks source link

why use declare-binscript instead of declare-executable? #27

Closed haruki7049 closed 1 month ago

haruki7049 commented 1 month ago

I like binary formats, so I am wondering why @CFiggers are using declare-binscript.

I am new to Janet-lang and do not know the manner in which it is done in Janet-lang. If your reasons for using declare-binscript include Janet-lang's mannerisms, I would be glad to know.

sogaiu commented 1 month ago

This may not be why CFiggers uses declare-binscript, but I do it because it's easier to debug things (I can edit the script in-place) and it doesn't rely on a user having to compile anything.

pepe commented 1 month ago

I could remember it all wrong, but there was a change because of the loading of local modules. For tools, I am also inclined to use the declare-binscript. But for the release build of my apps, I strictly use declare-executable with compile-time configuration.

It can be my Janet-lang's mannerisms :-D.

haruki7049 commented 1 month ago

I understood that it is one of the debugging methods, is that correct?

CFiggers commented 1 month ago

Hi @haruki7049 —great question. The answer is, Janet LSP strategically runs on the user's install of Janet. This does two things that are useful for the LSP and are preferable to having an executable:

For other examples of installing Janet CLI tooling as binscripts, see ianthehenry's Judge and the first-party jpm tool, both of which install binscripts rather than executables. It's a very well-supported paradigm! 🙂 Of course, the caveat with this approach is that we have to assume that the end user has a copy of Janet installed. But given that Janet LSP is editor tooling for Janet, and is literally useless to anyone who is not a Janet programmer, I find this a safe assumption to make! 😁

CFiggers commented 1 month ago

Two other notes:

haruki7049 commented 1 month ago

Thanks for the very thorough explanation. I am a little bit bad at English so I had to use Deepl to read it.

Two things I understand now.

Are these two points correct?

This is a bit off topic, but I am currently working on a library that uses Nix, a package manager and build system, to build a project for Janet-lang.

buildJanetPackage currently only supports installation in binary format using declare-executable, and does not support installation in script format using declare-binscript, or installation of the .jimage of the build result.

From what you have said, I have learned about the effective use of declare-binscript and .jimage. So we will actively support both of them in the Nix library.

sogaiu commented 1 month ago

I think specifically for janet-lsp, the following point mentioned by @CFiggers is additionally relevant:

It means that the LSP will always have the same access to Janet (same version, same env vars, same installed modules) as the user's own copy of Janet.

That's not the same point as either debuggability or for cross-platform matters.


Regarding Nix / Guix and Janet, there are some discussions about that on the Janet Zulip instance as well as at the main Janet repository:

haruki7049 commented 1 month ago

I close this issue once my questions have been answered. Thanks for all your answers.

sogaiu commented 1 month ago

My apologies to CFiggers for my poor manners.

Sorry!

CFiggers commented 1 month ago

My apologies to CFiggers for my poor manners.

Sorry!

No poor manners detected, friend! No apology needed. Actually, I'm not even sure what you're referring to.

haruki7049 commented 1 month ago

I am smiling at how well you guys seem to get along....

sogaiu commented 1 month ago

No poor manners detected, friend! No apology needed. Actually, I'm not even sure what you're referring to.

You are most gracious.

In retrospect, I think I should have waited for you to respond before my barging in. Too quick to trigger (^^;

sogaiu commented 1 month ago

One last breach, if I may (^^;

@haruki7049 Please feel free to join us at the Zulip instance if you wish.

haruki7049 commented 1 month ago

I created my account for janet.zulipchat.com :) https://janet.zulipchat.com/#user/758940