 Hi, I'm Martin. I'd like to talk to you about notebooks and the rebel So as Clegerians, we all love the rebel, right? And of course, I mean a real editor connected rebel into our running system So we love the rebel and we don't really like notebooks. I mean, we we love our editors We don't want to edit code in the browser and these notebook formats that put our code into Jason blobs Together with base 64 encoded results that we can't reasonably put into version control or reuse They're not so great But there is a lot of stuff to like about notebooks Notebooks as a medium take us beyond text. They allow us to make sense of our data generate insights draw pictures The greater telling story and we can look at them on the web If we consider those things the rebel really starts to look a lot less ideal It's only text no visual results. They're not so good at telling a story The reading experience is just not great with these monospace funds We always need to start a running system and evaluate the form to see a result These are some of the thoughts that went into building clerk our attempt to bring those two things We love notebooks and the rebel closer together I'd like to show you now what clerk is and what it can do for you starting with a small life coding session Let's dive right in One of the main perks of clerk is you get to use your editor that some of you have spent decades Tweaking to the liking and you get to keep your rebel first This is emacs here that I'm using and I'm starting a rebel now starting my closure process and I get a connection I can evaluate this form and this will start clerk Tell it to open a browser when it started and watch these paths for file system changes So I'm creating a new closure namespace. Let's make the fund a bit bigger and This is basically hello world in clerk as I saved this you see this shows up It has prose this line comment and I can Do computations? cool Let's explore our dictionary a bit and you can see my editor being helpful here, so it's completing These paths and I can slurp those Cool, you can see in clerk This is a fairly large string the megabyte two and a half million characters And I'm getting a tiny preview of this in clerk and I can load more data on demand Let's also add a small namespace declaration here and Let's massage this a bit So I'm splitting this into individual lines. This is now 230,000 words again clerk renders this nicely for me Let's group this by the first character Cool. Now again, I have a map now here. I can load data at the root level as I can further down the tree And so I think this might be a bit nicer still So you see we curve Upper and lower case characters. Let's fix that and Turning this into a keyword Might make things a bit nicer still and how about we Sort this as well Cool, so this is our data set. We're gonna look at we'll give this a name. So these are Kind of letters to words, right? Looking good and you can see as I would evaluate this in emacs. I'm sure if you can see this here I Just get the bar name back whereas clerk shows us the data behind the bar We can now bring in clerk and with just some tiny tiny code. We can make this a lot more useful So let's put this into a table nice, we have a table of all the characters and again, we can Load more and clerk is trying hard to understand most of the different table formats that folks would use in closure and convert them To understand them automatically Next I'd like to explore. What's the distribution of words by starting character? We're mapping over the count of the values in This map I'm using the rappel now to evaluate this. This looks good Now let's put this into a plotly plot That doesn't look quite right. I think I need actually a map of data and Get this in here nice But the axes are wrong. Let's change them around and Some labels would still be nice cool, I Think it's pretty clear if you compare these two things here that I Can make sense of this graph and get the answer that I need much quicker and get a much clearer picture now I see that P and S are the most common letters and Overall, it's very very little custom code that I need to get these things So that's the first example with plain closure and clerk. We're gonna look at two more now so First tap So you might be familiar with closure core tap if you're not it's a closure core function allows us to send values to a tap and we can add these listeners via add tap which means whenever we tap a value closure core is gonna call all of these function handlers that we've registered and What we do here. We just conch this onto this atom. We've defined We're using a deaf once to make sure it is only defined once starting out with the empty list And now I can actually run some forms to see this in action So you see these numbers are showing up as I tap them some random integers Let's also add a vector of random numbers a map some random words and a few more integers Cool, and you can see I can still lazily load more data again clerk's default viewers are being helpful here by Not overflowing the repel or not overflowing clerk with two large values If we're printing a big data set to the repel we run into problems. This is what we're trying to solve here So that's tap and Onto the next one what you've seen up to here are just clerks built-in viewers I think you've seen that they can be pretty useful in a lot of situations, but sometimes you just need something special We're gonna look at that now Rule 30, so I'm sure everyone has seen the game of life There are many systems like it each name for the order in which the rules were discovered. This is a clerk notebook exploring rule 30 I'm just gonna walk you through how this works in the repel first. We define rule 30 as this map This defines for each entry state kind of the successor state so if I get three cells with ones in it and we use numbers here as a binary representation and Yeah, this is how How my repel would show it then we get the first generation as a vector With zeros and a one in the middle and then we can Finally evolve the board right and let's look at that So, yeah, we can kind of squint and see that there is a pattern here, but it's kind of hard to see what's going on, right? and So we can bring in some clerk custom viewers specific for our problem at hand To I think yeah get a clearer inside of what's happening here So let's do that first so clerk viewers in general There are maps of predicates and a render function. They can have more things on them but that's kind of the essence and As I enable this you can see each cell is being displayed as this tiny square. We're using our html viewer here with these diffs with a fixed width and height and as well setting some classes and They're gonna be either with a black or white background I can lazily load more data again here and Things should look a lot better if I bring in more of these viewers so we also define a viewer for vectors as well as for lists and So compare these two things here, right? I can get a much nicer picture on the right really without a lot of custom code This is all the code. I had to write for this situation and it's really not that much code and not that hard a Final example of plain closure and clerk before we get to the more exciting stuff. My kids have this game But they lost the dice that came with it, so it's not really hard to make a dice in closure, right? This is pretty standard stuff. We have Six sides to our dice. We have an atom. It's gonna store the state and we can control it from the repel right now We're also saying what the side is Good and we're printing it to the repel My kids can't really use anything that they can't touch on their iPad I want to get them to use the repel, but I think we're still a few years off here We can bring in clerk to make this actually happen again with very little code And so what we're doing here We're defining a viewer. That's just a render function in this case And we're putting this just on this form using clerk with viewer It will be called with the value inside the dice atom, which it is a side and then we're rendering This with a pretty large font as well as a button with an on-click handler that when in boat uses The clerk eval function of the viewer API to send this quoted form over to clerk where clerk will evaluate in the JVM Let's try this blau blau Grün That's it Now up to here. This was all just plain closure and clerk But we can combine clerk with any libraries in the closure ecosystem to do many more interesting things And I'm excited to show you two great examples of this First Sikkim utils. Let's make this a bit bigger Sikkim utils is a closure port of a scheme library for classical mechanics from Sassmann This closure port is built by Colin Smith and Sam Ritchie Sam was kind enough to collaborate with us on this notebook here In Sikkim utils you can write closure code to represent equations that we can use to drive physical simulations Now this is pretty meaty stuff. We'll just fly over it and I'll share this so you can read along later We're not gonna interact with this interactively now This is its own story that you can read along and you can play with in your editor We'll provide a sample repo for you to play with the first thing to note Is that you have closure forms representing a physical system using functional geometry? What's cool is that Sikkim utils can perform algebraic simplifications on them and render different representations of a given expression Here you can see a prefix notation Here you see a simplified version of this and Here we see a lot tech rendering of the simplified version So we're going to mostly here scroll pretty quickly past most of this stuff Here is initial conditions being set up for our double pendulum then there's gonna be some helper code for visualizations and Until we finally get to this great picture so what you see here is again using just a clerk Vega light viewer very little custom code and And yeah, we can move the slider here to to run through time right as well as have a visualization of the pathways just took through time and So this is kind of the chaotic case for these chaotic initial conditions and here we have the same thing for regular data and Yeah, there's a lot more to Sikkim utils Sam is working Working on a lot of stuff. That's yeah even more mind-blowing. He's just added general relativity to it And I'm really excited to To really gain a deeper understanding as somebody who studied physics to deepen my understanding of physics through computation So that's it for physics with clerk and Sikkim utils and you almost made it just one final example Getting the world's knowledge into clerk This notebook is using another cool library Jack Russia's Monday name It's named after Paul old lids attempt to index the world's knowledge Some consider it a precursor to the internet. I think it's fair to call this a precursor to Wikipedia for sure Again, you can read along. This is a pretty good Narrated story can read along later. I just want to highlight Kind of that not a lot of custom code is going to be needed here to do this stuff So first we can ask it questions like what has James clerk Maxwell Who's also the naming patron of this library famous for having invented or discovered and We get back this internal ID, but can easily resolve this Find out that that's a unified field theory And we can get this information also in many different languages Again, this is all just a built-in viewers No custom visualization code at all and it's already pretty useful But yeah, putting this into a table can make things nicer, right? Or kind of grouping it by the inventor To find out that Albert Einstein has in wait invented quite a few things Some of which you'll soon be able to explore with Sikkim utils and clerk Let's look at another example visualizing geospatial data So in this query We're looking up all places in Germany ending in our or its Indicating that they're of Slavic origin. We're getting the latitude longitude and name Then we're using a Vega viewer to visualize those on the map This is what it looks like again very little custom code But we can also Go a bit further here we're querying for all Swift's or hummingbirds and Generating a custom table using the hiccup viewer showing the names their pictures and Their home range for each one Beautiful a last example and then we're done a network diagram. So This is again using clerk's html viewer that also understands SVG combining this with Jack's Aroic library to draw as a network graph of the origins or of all programming languages influenced by Lisp and Yeah, we get back this really huge graph You can best explore this on your own I think and Yeah, so we get Lisp at the root And we can find closure I think somewhere here on the right Here it is. I hope this gives you a sense of what's possible with clerk when we combine it with some of the amazing libraries We have an enclosure ecosystem Both these notebooks were created without any changes to clerk. I Think this is a testament to the great power of the composability. We have an enclosure library ecosystem To wrap things up, I'd like to show you how the static publishing works And I should actually say that these notebooks you've seen They are statically published. So Yeah, I can't load these elitions here anymore But these are actually static websites that you can easily put some place on the web for others to read And Let's go back to my script here. So we have this clerk's build static app command, right? that Opens up this index html page, but I actually want to show you that we can easily Open my finder get this index page and drop this directory in here Something went wrong, but I'm happy. It's not in my software. Let's try this again cool, and now we have this website live and Yeah, you can see I can still Load this notebook you've seen here. It has all the stuff in it right including this big SVG and It's time to for me to thank you. Thanks for listening Thanks to everybody who contributed to clerk special. Thanks to Jack who's been mentoring me on this project and yeah His help has really been invaluable If you like clerk, please play with it and reach out to me on Twitter or next journal on the clue During slack with feedback. Thank you