reddit / emacs

A demo of Common Lisp in Emacs and SLIME: how to call an API, parse JSON and build a binary: another Lisp for other purposes

dzecniv · 2022-05-18 07:47
Hi community, I started my Lisp journey with Emacs, as everybody else, and I now like Common Lisp very much. In the following video I show how to create a project, how to call the GitHub API, parse JSON, and create a binary to use our app from the terminal. I do this from Emacs and SLIME, the IDE for CL. https://www.youtube.com/watch?v=TAtwcBh1QLg If you wrote some Elisp, you will notice differences. For example, the REPL is different, more featureful than IELM, that I don't use that much for Elisp. We have an interactive debugger with restarts (actions we can choose, in the video I go to the source file, I re-compile the function, I come back to the debugger and I choose "retry", and the call passes). As a developer we can set our own restarts, of course. Some other things I do are: compile one function (C-c C-c, that one we don't have in Elisp) or the whole buffer (C-c C-k), go to the REPL (C-c C-z), pre-fill a call to the function the pointer was in (C-c C-y and it is especially useful because it can add a package prefix (yes, we have packages that serve as namespaces)). I `inspect` a data structure (there is an interactive version too. In other editors like LispWorks, we can have a graphical pane to click and explore (and change) a variable). I click on a previous result printed on the REPL to use it as an argument of a new entry. In this case it is a readable data, but I could click on the hash-table object/presentation, that we see only as ± `#<hash-table :count 3>` and it would work too. Emacs and SLIME is the best combo for CL development, and a great IDE in itself. In the end I build a binary and just this I find it attractive for a Lisp developer (how do you do that with your Elisp application ? ;) ) I had trouble discovering all this, so hopefully it makes it look easy and makes you want to try. I encourage you to, I can't imagine what would happen if all the Emacs-Lisp developers out there built CL tools and libraries :) It is just another opportunity to write some Lisp in places where you wouldn't pick Elisp. Hope you find it useful (and fun), thank you. https://www.youtube.com/watch?v=TAtwcBh1QLg --- My other favourite resources: - https://lispcookbook.github.io/cl-cookbook/ - https://github.com/CodyReichert/awesome-cl
jvillasante · 2022-05-18 10:21
Very cool! 98M binary is no joke!
dzecniv · 2022-05-18 11:36
damn you saw it! I didn't use [core compression](https://lispcookbook.github.io/cl-cookbook/scripting.html#building-a-smaller-binary-with-sbcls-core-compression), we can lower it to ±30-40 MB easily.
digikar · 2022-05-18 12:22
And it's not just a binary, it's an image that you can use to debug and modify your application live :).
dzecniv · 2022-05-18 14:05
hell yes, thanks for the addition. And I use it: I have deployed a web app, and for simple updates, I log into the REPL of the running app and I reload the sources. I can even install libraries that way. For more secure deployment I'd use a proper method, but so far it works, easily, with no interruption of service.