Rewrite Your Scripts In LISP - with Roswell

  Рет қаралды 20,905

Gavin Freeborn

Gavin Freeborn

Күн бұрын

This tutorial is focused on Emacs and how I use it from day to day. Specifically this is focused on those coming from a command line background
Link to roswell
github.com/roswell/roswell
More on running commands and such with CL
lispcookbook.github.io/cl-coo...
More on scripting with CL
lispcookbook.github.io/cl-coo...
Link to uiop's documentation
asdf.common-lisp.dev/uiop.html
Let me know what you think and if there is anything specific you would like to learn about.
---------------► Wanna Support Me? ◀︎---------------
Github:
www.github.com/sponsors/gavinok
Patreon:
/ gavinfreeborn
---------------► Wanna Checkout My Dots? ◀︎---------------
Vimrc:
github.com/Gavinok/dotvim
Emacs Config:
github.com/Gavinok/emacs.d
---------------► Come Join The Community◀︎---------------
LBRY:
open.lbry.com/@GavinFreeborn:...
Matrix Space:
matrix.to/#/%23gavinfreeborn:...
Discord:
/ discord
00:00 Intro
01:18 Why Not Python Or Go?
02:38 Quick Explanation Of What Roswell Is
03:03 Installing Roswell
03:29 Using Roswell From The CLI
04:05 Writing Your First Script With Roswell
04:43 Explaining The Strange Formatting Of The Header
05:39 Loading A Roswell Script Into A REPL
07:12 Porting A Bash Script To Roswell
12:57 Executing An External Program
18:14 Compiling An Executable
19:47 Conclusion

Пікірлер: 69
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
One thing I didn't get to mention in the video was that you can also add external libraries by adding them to the #+quicklisp section of your script. Really simplifies dependency management and makes it so you can compile them into your final executable.
@beauteetmusculation8191
@beauteetmusculation8191 2 жыл бұрын
Which clearly is a big win. That's the reason I like compiled languages: making statically-linked programs.
@pascal7947
@pascal7947 2 жыл бұрын
Nice video. I love the interactive programming in Lisps. In the Clojure world there is Babashka, which is a really cool way to write scripts.
@c1dk1n
@c1dk1n 2 жыл бұрын
@FichDich InDemArsch That's like, your opinion, man.
@jeffspaulding9834
@jeffspaulding9834 Жыл бұрын
As much as I love CL, I do complicated shell scripts in Perl. Everyone thinks Perl is all about string manipulation, but Perl was actually written to replace complicated shell and awk scripts. There's a reason almost every UNIX includes Perl as part of the base system install - it's the glue that holds everything together.
@laughingvampire7555
@laughingvampire7555 Жыл бұрын
yes, perl was the goto scripting language for admin and IP management, a friend who has been perl coder for the last 25 years had books on "how to admin windows with perl" I read the book and it was amazing. I did an internship in the bioinformatics department of the school of Biomedicine in my college, I got to work some dna sequencing stuff, it was amazing and fun, mostly was making web interfaces for clustal and other bioinformatics In web development perl had an awesome feature that is lacking in all other scripting languages, the concept of "tainted data" and this lead perl to secure web apps while the php people were shipping code with huge signs of "inject sql here please" all over the place.
@jasenq6986
@jasenq6986 10 ай бұрын
or python
@jeffspaulding9834
@jeffspaulding9834 10 ай бұрын
@@jasenq6986 Python's for if you want to script but hate shell scripting.
@LabiaLicker
@LabiaLicker 6 ай бұрын
@@jasenq6986 yeah nah
@logicaestrex2278
@logicaestrex2278 16 күн бұрын
@@LabiaLicker python is also included in almost every distro and is extremely flexible. i do like perl, but python works as well
@vindarel
@vindarel 2 жыл бұрын
+1 about Python, Go and CL's best-in-class interactivity. Roswell's added value here is that it is easy to share one's script, but it is worth noting that it is *not* /necessary/ in order to build a binary (and compress it). So I myself often just build a binary without Roswell. I refer to the Cookbook!
@freesoftwareextremist8119
@freesoftwareextremist8119 2 жыл бұрын
I like roswell for building for the fact that it is super easy to make it buildable for people who don't know about Lisp. Imagine explaining them that they need to install SBCL, quicklisp, run archane commands in the REPL...
@vindarel
@vindarel 2 жыл бұрын
@@freesoftwareextremist8119 Sure ! (although these can also be scripted) And the simplest option for end-users (or one's own server) remains to provide a binary (specific to the target platform).
@valentinussofa4135
@valentinussofa4135 2 жыл бұрын
Patrick Winston's book has made me interested in the topic of lessons about LISP. Nice video content. Liked & Subcribed. 🙏
@alexisgallagher5109
@alexisgallagher5109 2 ай бұрын
swift-sh gives you this in Swift, which also has a REPL. rust-script is comparable in rust. Glad to learn about roswell.
@yafz
@yafz 2 жыл бұрын
Nice demonstration!
@staypufd2001
@staypufd2001 Жыл бұрын
When you put asterisk's around a global, they have classically called "Ear Muffs".
@boots7859
@boots7859 Жыл бұрын
It would be interesting to see file size comparison. I know you mentioned it towards the end of the vid about having to compress the image, etc, but ultimately if it ends up with 10Mb for a simple script it makes the vaule proposition a bit different.
@Imaltont
@Imaltont 2 жыл бұрын
Common Lisp seems really nice for this kind of thing. I would say though that Ocaml is also great for this kind of thing. You can get a similar workflow to SLIME/Sly in emacs with Tuareg, compiles down to a binary executable, and comes with these kinds of tools (language server in merlin, opam package manager, easy to get dune (project manager/build tool) and utop (better REPL than the default) through opam, debugger etc) instead of having to hunt them down the same way as with Common Lisp's quicklisp/asdf/roswell. The MLs is also another beautiful family of languages, and they are especially elegant when it comes to pattern matching/lots of conditions on a list of data/parsers. They are much more rigid than the Lisps, but they work great for this kind of stuff.
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
Outside of a little SML (and if you count Haskell) I haven't done too much with the ml family but I'd definitely be interested in giving ocaml a look. As far as I know you can't manipulate a running program with ocaml the same way you can with lisp can you? For reference take a look at this demo kzfaq.info/get/bejne/bNZ9rMujqcmxqqs.html . If you can I'd be really interested in giving it a try! I haven't actually seen anything other than CL provide such functionality.
@Imaltont
@Imaltont 2 жыл бұрын
@@GavinFreeborn The compiled binary you can't edit while it's running afaik, no, but you can while developing, by sending new definitions to the REPL for evaluation. Tuareg gives you this in a SLIME-like way in Emacs, though afaik it doesn't have as many features as SLIME. To my knowledge there are a few other languages than the Lisps that have the image based workflow, most notably is probably Smalltalk. There are also probably other niche/academic languages that can that I just can't think of/don't know of yet.
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
@@Imaltont Thanks! I'll definitely still give Tuareg a look either way
@herrkrake8106
@herrkrake8106 2 жыл бұрын
@@Imaltont Oh, poor thing Smalltalk.
@ceticobr
@ceticobr 2 жыл бұрын
Nice vídeo. Liked and subscribed.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 2 жыл бұрын
Did you know you can run just about any language in a Jupyter cell, without needing a custom backend kernel for that language? You can just use the standard “%%script” cell magic. For example, a bash command: %%script bash echo 'hi there!' LISP with SBCL: %%script sbcl (+ 2 2) SBCL without the startup banner and prompts: %%script sbcl --script (+ 2 2) ; produces no output (princ (+ 2 2)) ; need to do explicit output SBCL without the output cruft as before, but restoring automatic printing of expressions: %%script sbcl --noinform --eval "(require 'sb-aclrepl)" --eval "(setq sb-aclrepl:*prompt* \"\")" (+ 2 2) In all cases, copy the “%%script” line as is, and put whetever you want in the rest of the cell.
@jeffspaulding9834
@jeffspaulding9834 Жыл бұрын
Emacs' org-mode has similar functionality (org-babel). It doesn't have the nice widgets, though.
@EdouardTavinor
@EdouardTavinor 10 ай бұрын
I think what you say about go can be applied to a lot of modern tooling. Other languages can be even more verbose here. For example, if you just want to write and test one function in java you need to write a file with a class definition and either a main method or another file which uses something like junit. With clisp or emacs lisp in emacs you just evaluate the defun and then write an expression that calls the function and evaluate that.
@doesnt_even_lift
@doesnt_even_lift 2 жыл бұрын
I was thinking about re-writing my scripts using babashka, partly because I really like that things can be piped into it on the commandline like a regular shell for testing. Other than speed from compilation, are there other benefits I would be missing out on by not using CL with roswell? I'm not very familiar with the differences between a clojure-based scripting language and a common lisp based scripting environment
@SaHaRaSquad
@SaHaRaSquad Жыл бұрын
The thing that always turns me away from Common Lisp is how cumbersome the REPL is. You can't use arrow keys to repeat a previous command like in Bash, instead you now have garbage in the commandline. You can't just continue after getting an error message, because every single error imprisons you in a weird debugger menu that needs a different key to exit every time. I'm sure it makes sense in a way but it seems the interface ignores all advancements in CLI tools of the past decades. Guile Scheme isn't much better but at least the input to exit the debugger is consistent. Emacs Lisp is the only language I know of that may throw syntax errors based on the contents of a comment (yes, really). Maybe I missed a great alternative but I'm used to Bash & Python, and SBCL felt like a step backwards to me even though I kinda like the language itself. I must say, however, that Roswell is a great recommendation. It made setting up SBCL so much easier.
@GavinFreeborn
@GavinFreeborn Жыл бұрын
Maybe take a look at github.com/fukamachi/mondo which is intended to make the lisp repl more interactive. Common lisp's is more customizable than most languages for this reason the default isn't intended to be fully featured
@GavinFreeborn
@GavinFreeborn Жыл бұрын
The repl in lisp is more extendible than most languages repls so it doesn't actually include a "interactive shell" the included shell is intended more for editors to easily integrate with (adding lots of features to the default makes this hard. There are plenty of programs that provide a more bash like repl
@SaHaRaSquad
@SaHaRaSquad Жыл бұрын
@@GavinFreeborn Nice, mondo is a lot better. Thanks for the link
@GlobalYoung7
@GlobalYoung7 Жыл бұрын
thank you 😊
@commarchinin
@commarchinin 2 жыл бұрын
My personal CL scripting experiences have been relatively negative. In particular, handling paths is pretty commonly a big deal in scripts, which really isn't a fun time in CL. That said, I think that's mostly a personal preference thing, and I agree on which way out I'd like my scripts' parens.
@DMWatchesYoutube
@DMWatchesYoutube Жыл бұрын
It's funny how something so common is often forgotten, rust seems to have a big challenge ahead in formalizing file paths
@GekoPoiss
@GekoPoiss 8 ай бұрын
Any programming language or library is easily portable and with sensible tooling if you use Nix.
@ruffianeo3418
@ruffianeo3418 Жыл бұрын
Not sure if roswell in the mix would make it easier or harder for new lispers. The workflow without it is not really more complicated.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 2 жыл бұрын
4:54 Note what “exec” does: it tells the shell to replace itself with the program it is executing, rather than spawning a separate subprocess. Not sure why that is necessary: why not put the “ros” command directly in that first shebang line, and avoid going through a shell at all?
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
Portability really. Not every user will have ros installed in the same place. `#!/bin/env -S ros run ...`would work however -S isn't POSIX compliment and any user using a non gnu `env` would fail to run the program. Without the -S the extra options/args given to Roswell would not work.
@rexcastrosurvey
@rexcastrosurvey Жыл бұрын
Hey mate im learning lisp atm. Im learning for looking on code on example . Theres a way to open protected lisp code? Thanks and more power . i subscribe on your channel
@GavinFreeborn
@GavinFreeborn Жыл бұрын
Protected? What do you mean?
@herrkrake8106
@herrkrake8106 2 жыл бұрын
Lisp syntax look like a total gibberish! What is the best and shortest way to wrap one's head around if programming experience is only occasional python and shell scripting? Setup stumpwm, next, guix and emacs?
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
Best way is to almost forget about the parentheses. The editor will indent your code for you so all you have to do is read the indentation. Kinda like you would with python just everything is a function call. E.g. (> (+ 1 2) (+ 3 4)) You don't really need to care about the closing parentheses. All you do is see ogh this is a comparison of argument 1 and argument 2. Then look at the aligned arguments. It takes a bit of getting used to but once it clicks it's just like reading every other language.
@herrkrake8106
@herrkrake8106 2 жыл бұрын
@@GavinFreeborn Got it! Which dialect suits better for big data driven projects from your point of view? Closure looks nice from these perspective, but it has reputation of good frontend tool, I suppose. Don't you think so?
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
@@herrkrake8106 I think you meant clojure which is a fine option. You are likely thinking of clojurescript which is basically just a very of clojure that compiles to JavaScript. Clojure it's self runs on the JVM (same thing scala, java, and kotlin use) so you shouldn't have any issues there. I haven't done much data science work so I can't really speak as to its offerings there unfortunately.
@herrkrake8106
@herrkrake8106 2 жыл бұрын
@@GavinFreeborn Oh, thanks for a fast answer! Gonna dig deeper with clojure script then. Appreciate you sharing your thoughts!
@erickwarteng2427
@erickwarteng2427 2 жыл бұрын
What font are you using
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
PregmattaPro
@herrkrake8106
@herrkrake8106 2 жыл бұрын
Try Consolas. The best one for my taste.
@gamerboy4566
@gamerboy4566 2 жыл бұрын
What’s the font you are using?
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
PregmattaPro
@gamerboy4566
@gamerboy4566 2 жыл бұрын
@@GavinFreeborn Thanks
@N0zer0
@N0zer0 2 жыл бұрын
5:15 Why not just simply #!/bin/ros? You don't even need -Q since it's the default mode of operation.
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
Portability really. Not every user will have ros installed in the same place. `#!/bin/env -S ros run ...`would work however -S isn't POSIX compliment and any user using a non gnu `env` would fail to run the program. Without the -S the extra options/args given to Roswell would not work. As for the -Q I am not 100% sure on their reasoning but I guess it's just to make it so those who don't want quicklisp just need to change one char since +Q will disable quicklisp support.
@jwiskikruger8921
@jwiskikruger8921 2 жыл бұрын
this theme is beatiful, can you tell me the name pls?
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
It's my own theme actually. Your can find it in the `lisp/spaceway.el` directory under my emacs configs
@jwiskikruger8921
@jwiskikruger8921 2 жыл бұрын
@@GavinFreeborn thank you
@lamprospitsillou6325
@lamprospitsillou6325 2 жыл бұрын
The one who betrayed us and joined the dark side... Just kidding ! I don't use Emacs Or lisp but i love picking in this huge world of lisps and Emacs 😁! Really interesting videos.
@GavinFreeborn
@GavinFreeborn 2 жыл бұрын
I assume this is in reference to the lack of viming I've been doing 😅. I have been considering making more vim content since even though I use it very little there are surprisingly few people covering the topics I considered actually interesting to work with.
@lepton099
@lepton099 Жыл бұрын
IDE for write in lisp, i´´m beginner , THANKS A LOT
@angelluna2884
@angelluna2884 Жыл бұрын
portacle
@programmingguy6081
@programmingguy6081 Жыл бұрын
The point of shell scripts is you don't need to install anything and you can do everything in a simple text editor. Also most people using scripting languages are not programmers. Instead of lisp just use awk or perl. Most OS`es come with one or both of these. If on windows just use powershell.
@AK-vx4dy
@AK-vx4dy Жыл бұрын
Install dark mode please :( Ok jokes aside, decrease brightness in camera or change white balace, your selfie is overexposed badly.
@GavinFreeborn
@GavinFreeborn Жыл бұрын
I've since changed this. See my later videos
@mlongval
@mlongval Жыл бұрын
"High key video" anyone?
@collinsa8909
@collinsa8909 Жыл бұрын
Your fumblings with the language is enough warning signs that it would more likely be a pain to work with than advertised
@GavinFreeborn
@GavinFreeborn Жыл бұрын
Common Lisp letting me fumble and recover during development is one of the biggest things that makes me enjoy working with it.
@terryphelps4204
@terryphelps4204 Жыл бұрын
I like the content of this video, but: You have go-ahead-and disease like so many KZfaq video makers have. You say "go ahead and" all the time. It doesn't mean anything.
@GavinFreeborn
@GavinFreeborn Жыл бұрын
Thanks for the feedback. I'll avoid the go ahead and statments
Writing A Game In Lisp???
21:35
Gavin Freeborn
Рет қаралды 9 М.
Why Are Lisp Macros So Great!?
16:28
Gavin Freeborn
Рет қаралды 15 М.
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 9 МЛН
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 9 МЛН
Useful gadget for styling hair 🤩💖 #gadgets #hairstyle
00:20
FLIP FLOP Hacks
Рет қаралды 6 МЛН
Дарю Самокат Скейтеру !
00:42
Vlad Samokatchik
Рет қаралды 8 МЛН
Creating Your First Lisp Project - Quicklisp, asdf, and Packages
24:47
What is the Curse of Lisp?
25:09
Eric Normand
Рет қаралды 26 М.
Unleash The REPL With Sly
14:45
Gavin Freeborn
Рет қаралды 12 М.
Doom Emacs On Day One (Learn These Things FIRST!)
35:10
DistroTube
Рет қаралды 165 М.
The Rise & Fall of LISP - Too Good For The Rest Of the World
17:44
Gavin Freeborn
Рет қаралды 38 М.
Why Lisp Is One Of The Most Productive Programming Languages
12:14
Gavin Freeborn
Рет қаралды 41 М.
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 45 М.
Manage Your Dotfiles with Home Manager!
32:06
LibrePhoenix
Рет қаралды 50 М.
Лазер против камеры смартфона
1:01
NEWTONLABS
Рет қаралды 712 М.
Telefonu Parçaladım!😱
0:16
Safak Novruz
Рет қаралды 26 МЛН
Battery  low 🔋 🪫
0:10
dednahype
Рет қаралды 13 МЛН
Красиво, но телефон жаль
0:32
Бесполезные Новости
Рет қаралды 1,5 МЛН