Editor Integrated REPL Driven Development for all languages
Musa Al-hassy (he/him) - Pronunciation: moo seh, http://alhassy.com/ https://github.com/alhassy, Alhassy@gmail.com
Format: 10-min talk ; Q&A: ask questions via Etherpad/IRC; we'll e-mail the speaker and post answers on this wiki page after the conference
Status: All done
Duration: 09:37 minutes00:04.880 Introduction 00:35.989 The wonders of C-x C-e 03:35.809 An overview of REPL Driven Development 04:51.143 REPL Driven Development with Java 07:28.029 Bring your own Read Protocol 07:59.669 Use Case: RDD & Job Interviews
Description
Emacs’ C-x C-e is arguably one of its killer features: The ability to run arbitrary Lisp code, anywhere. We demonstrate that the idea is portable to other languages [0, 1]. The result is an Emacs interface for any language, where code of your choosing is evaluated, and results are echoed at your cursor in overlays. We will demonstrate how to solve simple problems such as FizzBuzz in a RDD style using, say, Java or any language that the audience chooses. We will also look quickly at "growing programs" such as a photo gallery application, starting from scratch. Along the way, we discuss what features make a RDD system pleasant and how they can be implemented with our system. Finally, we conclude with how this RDD setup allows for inserting results of a computation as a use case for writing tests —i.e., we we show how user-definitions of a read protocol (the 'R' of 'REPL') can result in an analog of C-u C-x C-e.
[0] 💐 Repl Driven Development: Editor Integrated REPLs for all languages 🔁
http://alhassy.com/repl-driven-development
[1] REPL Driven Development :: Teaching a JavaScript runtime, incrementally, to be a web server 🍽️ 🔁 �
https://youtu.be/b6Z3NQVn4lY?si=MTMJDSdzszhbA267
About the speaker:
Musa is an Emacs afficando. His day job is with Java, but his heart is with Lisp. His experience with interactive programming is only with Agda [2] and Emacs Lisp [3], and both [4].
[2] Graphs are to categories as lists are to monoids
http://alhassy.com/PathCat.html
[3] A Life Configuring Emacs
http://alhassy.com/emacs.d/
[4] Making Modules with Meta-Programmed Meta-Primitives http://alhassy.com/next-700-module-systems/prototype/package-former.html
Discussion
Questions and answers
- Q: I know that there are many packages for creating graphics with
Javascript, but I don't know how to use any of them... is it
possible to use your package to create graphics in Javascript step
by step from Emacs?
- A:
- Q: Can you summarize what languages your packages support and do you
have a common framework for interfacing to their interpreters?
- A:
- Q: Did you get the job? =) Did the interviewer have any feedback
about your screen-sharing-driven development?
- A:
- Q: Could you compare your package to Language Servers (LSP)? They
seem to have similar functionality to your package.
- A:
Transcript
C-x C-e
)
and get a little pop-up.
Alright, so here I pressed C-x C-e
and this is what it ran.
And what this package gives you
is the same ability
for any language of your choosing.
So for example, here is some Java,
and I bound it to Ctrl-x, Ctrl-j (C-x C-j
).
So I say C-x C-j
, and this runs some code,
and over here I get a little pop-up.
The wonderful thing about
being able to run code from anywhere
is that you can keep it in normal text files
or any kind of file you like.
For example, you can have hyperlinks,
as it were…, like this one.
C-x C-e
, and now we can see this down here.
Learn about it.
But being able to run other languages besides Emacs
lets us do some interesting things.
For example, in the middle of a JavaScript program,
you might write a line like this. C-x C-n
.
And that says down here
javascript-eval
in the mode line,
and so this just checks that some endpoint
is working as intended.
So you don't need to use an external tool
to check endpoints.
You can just use Emacs in your favorite language.
You know, you can keep your spirit up.
So, C-x C-a
runs applescript-eval
.
The cool thing is, your code immediately takes form.
Right away, you see it doing things, you know,
altering your environment.
For example, this is JavaScript,
and JavaScript here is gonna change Emacs for us.
So C-x C-n
. And you can see down here
javascript-eval
was invoked.
It returned true, and this line of JavaScript
altered our Emacs. So that's really nice.
So you don't need to use just Emacs Lisp if you like.
You can use other systems.
As you saw, the output is shown in overlays.
So here's, for example, C-x C-p
to run
some Python code.
Notice it blinked in red
because I thought red was nice.
You can configure as you like.
And if you hover over it,
you can see the solution there,
and you can see it in a variety of familiar ways
if you use C-x C-e
regularly.
You can insert the results.
You can find documentation about them.
The idea here is that
you have this familiar Lisp workflow
with C-x C-e
, and this package ports it over
to your favorite language out.
So you can eval things,
you can insert them, and do as you like.
I think that's really neat.
C-x C-j
.
And this one increased in size,
and you can see down here I pressed C-x C-j
.
Let's change the color to blue,
C-x C-j
, the color is blue.
So all these changes are happening live.
Three balls isn't really a ball pit.
Let's go to 50 balls. There you go.
So it's nice that you can do this
without leaving your environment,
without building, you can rapidly modify and see.
I think that's nice.
Unfortunately, I'm at the halfway point,
so I won't be able to work through
some of these nice problems,
but you can see the videos
or GIFs on the associated repo.
Likewise for this one.
This one would have been a lot of fun,
but unfortunately, we're running short on time.
Apologies.
C-x C-j
,
and you see it's a list of person.
I didn't give this a name, so its name is $59.
If I hover over it, we can see the definition again.
So it's a person called Hamid, age 5,
another person called Jaafar, age 6.
This pretty printing is nice for me as a human,
but I can't execute this. This isn't valid Java.
So I could do C-u C-x C-j
.
If I have the help of a read protocol inserted.
Sorry, C-x C-j
. There it is.
So look, it gives me a new Person
with the construction everything.
Now I can work with.
Java can work with this.
So this can be quite useful for regression testing
or just to find out what your method spits out.
We can do the same thing. Here's a bigger example.
Trying to see it in the overlay is a bit cramped.
We can say C-u C-x C-j
.
All right, and now we have executable code.
Okay, this is neat.
If you want to do something with it.
I'm not really interested. I have four new persons.
If I really want to look at this,
I can say M-x java-eval-navigate-output
,
and now I see my output as this hierarchical tree.
I go down, I can see what's inside these,
what's the type of this thing, what's in there.
All right, so that's nice.
The idea is that we're not limited to
just textual output.
We can render output,
thanks to the power of Emacs, in any way we want.
In a browser, in a LaTeX file, in an Org mode (file),
however we really desire.
new Person
.
It's nice that you can do these kind of things
and that this software encourages you to do them.
Captioner: bhavin192
Questions or comments? Please e-mail Alhassy@gmail.com