7 ms·
Sharpscript: Lisp for Scripting
- threatofrain 3y agoOne might also check out Janet for quick scripting tasks. https://janet-lang.org https://janet-lang.org
- capableweb 3y agoBeing a Clojure addict, I guess I have to leave the obligatory link to Babashka too then: https://github.com/babashka/babashka https://github.com/babashka/babashka (Native, fast starting Clojure interpreter for scripting)
- snordgren 3y agoI love Clojure as a language but I can't bother to deal with the JVM ecosystem most of the time. Is this something I could use as an alternative?
- drekipus 3y agoMy understanding is that the linked lib/system is "clojure without the JVM"
- funcDropShadow 3y agoYes and no. Babashka itself is Clojure/JVM program compiled with graalvm to a native binary that starts very fast. Babashka contains an interpreter for a simplified variant of Clojure. It also contains a predefined set of classes of the JVM and a predefined set of Clojure libraries. Basically, it contains most of what you would need to use it for simple scripts, make network requests, parse command line arguments and many more things. But, it won't run every possible Clojure program and it won't be as performant as Clojure on the JVM if the program runs longer.
- vindarel 3y agoAs a CL addict, this isn't unlike Babashka: fast-starting CL scripting with batteries included. https://github.com/ciel-lang/CIEL https://github.com/ciel-lang/CIEL (alpha) (otherwise the solution is to build a binary)
- amno 3y agoAs an Emacs addict, Emacs can do it all that babashak & ciel do, plus much more than so, like having a great stepper (edebug) and possibility to view the output while stepping through the code in a separate file buffer, as well as a server for long term processes, that can watch files and directories etc.
- bitwize 3y agoOr Guile: https://gnu.org/software/guile https://gnu.org/software/guile Or scsh, for the old school: https://scsh.net https://scsh.net
- JoelMcCracken 3y agoOr https://docs.racket-lang.org/rash/index.html https://docs.racket-lang.org/rash/index.html , racket ecosystem is great
- nerdponx 3y agoGauche is my favorite Scheme for general scripting. Huge Python-esque standard library, but very nicely organized. Fast enough for anything I need it to do. Straightforward command line interface. Good, mostly clear docs. I find that Guile and Chicken are harder to work with and have less of what I want available for immediate use.
- kazinator 3y agoTXR/TXR Lisp https://stackoverflow.com/search?tab=newest&q="txr"%20is%3aanswer&searchOn=3 https://stackoverflow.com/search?tab=newest&q="txr"%20is%3aa... https://unix.stackexchange.com/search?tab=newest&q="txr"%20is%3aanswer&searchOn=3 https://unix.stackexchange.com/search?tab=newest&q="txr"%20i...
- sakesun 3y agoI think it's worth to mention Braid here. https://github.com/BrucePay/BraidLang https://github.com/BrucePay/BraidLang
- Zambyte 3y agoAre there any Lisps that are particularly bad for scripting? Elisp comes to mind since it's not great unless you're already inside Emacs, but if you are it's pretty good.
- HKH2 3y agoAre there any good Lisp shells?
- soraminazuki 3y agoElisp can be used from the CLI with batch mode. It's convenient even, for manipulating text. Especially source code.
- amno 3y agoElisp is actually exceptional for scripting :). You can also compile Emacs without graphics for even faster startup, check emacs-nox, and you can run it as a script: https://www.emacswiki.org/emacs/EmacsScripts https://www.emacswiki.org/emacs/EmacsScripts. What you get extra is a really good debugger (edebug), and text processing library extensions so you don't need to start extra processes (grep, awk, tr & co) just to extract some text from one output and send it to another. They also have really, really good integration with system, almost on par with Bash. So despite Lisp being more verbose than a DSL like Bash script, you win tons by just having a debugger. Completion and Emacs auto-typing features (snippets, abbrevs, autoinsert etc) compensate for the verbosty.
- whartung 3y agoWhenever I think of Lisp for scripts, or even a login shell, I drift towards an elegant handling of pipes. Mostly because for 99% of what I do, it involves pipes. Scsh did a lot of work with this but it’s still (as I recall) ungainly. Not to mention the idea of mixing process calls with native functions. Something like this would be nice: (| ‘ls’ (myfunc) ‘uniq’ (out-to “afile”))
- matheusmoreira 3y agoUntyped syntax is a defining chracteristic of shells. This answer by Jörg W Mittag is very convincing: https://stackoverflow.com/a/3640403/512904 https://stackoverflow.com/a/3640403/512904 This table in particular is very illuminating: | Ruby | Bash ----------------------------------------- number | 123 | 123 string | '123' | 123 regexp | /123/ | 123 file | File.open('123') | 123 file descriptor | IO.open('123') | 123 URI | URI.parse('123') | 123 command | `123` | 123 Here's a similar table with add your example's syntatic elements: | Lisp | Bash ----------------------------------------- command | `ls` | ls function | (myfunc) | myfunc string | "afile" | afile redirection | (out-to "afile") | >afile
- amno 3y agoIndeed. However you can achieve things like that in an ordinary Lisp via unevaled (special) forms, with other words, macros. In Emacs Lisp eshell does it too, though they have extra advantage since Emacs has built-in text editor and text processing extensions. Eshell implements both Bash and Lisp syntax. I am not sure if "sharp lisp" does anything special for scripting than any other Lisp, but it is possible to do.
- matheusmoreira 3y agoThat's true but when you do that it's not really lisp anymore it's another language you just created and implemented as a lisp macro.
- Aliza657 3y agoSharpscript holds immense promise as a Lisp-based scripting language. While it may not have the extensive libraries and community support of some established languages, its unique blend of Lisp's elegance and scripting's practicality makes it a compelling choice for developers looking to explore a new realm of scripting possibilities. I'm eager to see how the language evolves and gains popularity among developers and scripting enthusiasts.
- emmelaich 3y agoFor anyone writing a lispy shell, please make the beginning paren implied. And end paren too, at end of line. If you want multiline, you can always type the paren yourself. To remind the user, make the default prompt `( ` Also consider using brackets [] instead of parens to be really wrist friendly.
- amno 3y agoIt is not as trivial as you think, but it is possible. M-x in Emacs does it. But it is certainly not as simple as "just remove start and end parenthesis" :-). In a Lisp-2 if you type a symbol "foo" without parens, you are asking for symbol foos value as a variable, but it you type (foo) you are asking for symbol foos value as a function. Since every symbol in a Lisp-2 language (Common Lisp, Emacs Lisp some other possibly) can have both variable value and function object assign to it, how would system know which one you ask for? Anyway, it is possible to do, for example M-x in Emacs does it. They do it by means of restricting repl to execute only functions, and they limit that to special function with so-called "interactive" form, whose job is to provide function arguments.
- lispm 3y agoLispWorks does that too - if the function has an argument. CL-USER 18 > + 1 2 3 CL-USER 19 > first (list 1 2 3) 1
- amno 3y agoHah! Why am I not surprised to see that nick on HN too :-) I have no experience with LispWorks whatsoever, but I am curious, how did they implemented it if you know? I mean, how do they differ between calling first as a value or first as a function? In your example first could be a defvared to have some value, and then I might have called a function to produce some unrelated output. I mean it is a contrived example, and probably nobody types in a repl like that, but the language does not forbid it since white spaces are insignificant. If they just treat the first token as operator always, than they could call any function with any arguments: CL-USER> op arg1 arg2 ... argN but then they would have to eval all values at the start of repl by calling (symbol-function arg), instead of just type arg to examine a value. I don't think it would be a bad think in itself tbh; but I am not sure the win is big enough to introduce a new concept. By the way, I think I have stumbled on some mailing list comment somewhere once, where they said, that Hemlock can use commands named more "english like", i.e. they can have names with spaces in it, not just the hyphenated function name as in Emacs. Do you know more about it, or how they have implemented it? I am just curious; seen your comments on Reddit, and if you are the same person, I understand you are well experienced and familiar with various Lisps and implementations; hope you don't mind asking. :)