summaryrefslogtreecommitdiffstats
path: root/2022/talks/async.md
blob: 8e0f144a3533c2103d5c694d8e37f204f6ac615a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[[!sidebar content=""]]
[[!meta title="Emacs was async before async was cool"]]
[[!meta copyright="Copyright © 2022 Michael Herstine"]]
[[!inline pages="internal(2022/info/async-nav)" raw="yes"]]

<!-- Initially generated with emacsconf-generate-talk-page and then left alone for manual editing -->
<!-- You can manually edit this file to update the abstract, add links, etc. --->


# Emacs was async before async was cool
Michael Herstine (IRC: sp1ff)

[[!inline pages="internal(2022/info/async-before)" raw="yes"]]

While async is all the rage in the JavaScript, Go and Rust
communities, Emacs has had the ability to (certain) asynchronous
processing all along. I learned this while writing an Emacs package to
program to my music server's API.

Music Player Daemon is a project that does what it says: hangs out in
the background & plays your music. It has an API that I wanted to call
from Emacs. I had just learned async Rust, so I decided to see if I
could do something similar here. It turns out I could: I wound-up
writing a little async runtime that allows callers to "send" commands
to the daemon by queueing them up and returning immediately. In the
background, as output from previous commands comes in, new commands
are dequeued and sent.

This required callers to provide callbacks in order to receive the
results of their commands, which led to a situation all too familiar
to Javascript programmers: callback hell. The coda to my story was
(finally) coming to understand Lisp macros in order to extend Emacs
Lisp with a more convenient construct for sending multiple commands.

This talk will dive into the details of the Emacs Lisp process API,
specifically the Low-Level Network Access API, with illustrations as
to how it can be used to build an asynchronous queue. It will also
introduce Lisp macros and how powerful they can be.

Michael is a developer and long-time Emacs user from the San Francisco
Bay area. He hacks in C++, Lisp & Rust and thinks a lot about writing
provably correct code. You can find him at:

  - his [home page](https://www.unwoundstack.com)
  - on IRC: sp1ff on Libera.Chat
  - through [e-mail](mailto:sp1ff@pobox.com)
  - or on [Github](https://github.com/sp1ff)

[[!inline pages="internal(2022/info/async-after)" raw="yes"]]

[[!inline pages="internal(2022/info/async-nav)" raw="yes"]]