Become a Creator today!Start creating today - Share your story with the world!
Start for free
00:00:00
00:00:01
#69 - Mike Fikes image

#69 - Mike Fikes

defn
Avatar
29 Plays3 years ago
Episode 69 - we go back to our first ever guest, Mike Fikes, creator of ambly, replete and bringing Clojurescript to microcontrollers!
Transcript

Episode 69 Kickoff & First Guest Throwback

00:00:15
Speaker
Welcome to Deaf and episode number 69. I think it is wherever. Ray, yeah, I expect some comment from you. Episode number 69. I think the kids are going to love it. That's all I mean. Yes. Yes. And this time we're going all the way back to the beginning. So we got our first guest in 2016. Who is it again? June 2016. And now after
00:00:43
Speaker
Seems like four years and a millennium because of 2020. Now we

Self-hosted ClojureScript & Developments

00:00:50
Speaker
invited back our first ever guest on the show. Welcome back to Deaf and my fives. And how do you feel about being part of this, you know,
00:01:01
Speaker
Amazing episode number. Oh, hey, Vijay. Hey, Ray. Yeah, my son is going to love it. Yeah, I can predict that. I was hoping that this would occur. I'm like, yeah, pick me for that episode. Yeah.
00:01:16
Speaker
It succeeded. Full circle. It's a full circle episode. Nice. So I think plenty of things changed since 2016 already. Yeah. Yeah. So I was trying to remember what I was talking about on that last episode. And the only thing I can think about is I remember in 2015 was when self-hosted ClosureScript kind of became a thing.
00:01:44
Speaker
And I think after that, several things were created surrounding that. And that's probably what we were talking about. Self hosted rebels and things like that around that timeframe. Yeah, it might have been the replete thing for iOS or things like plank and Luma and stuff like that. Maybe Luma wasn't even around yet.
00:02:05
Speaker
Maybe. I think what fundamentally allowed that all to happen, I think part of it at least was the fact that reader conditionals were added to closure. So that's about how long ago it was. That was right around half a decade ago.
00:02:21
Speaker
So what has been happening since then? So most recently,

Clojure in Microcontrollers: New Horizons

00:02:24
Speaker
I think maybe we should go. It's, it's much difficult to think about going through all the stuff from there. Maybe we should start with the recent ones that you're working on. 2020 has been long. Yeah, man.
00:02:44
Speaker
So I joined a company with Ray for disclosure, right? Everyone knows it named Vouch. And that's what led to the thing that we're going to talk about, which is...
00:02:56
Speaker
we were getting into microcontrollers for some reason. We were digging into making our software, getting our software's tentacles into every place we could. And it turned out that building hardware was kind of an interesting thing for us at Vouche. And Vouche is pretty much a closure shop, right? Pretty much. I don't know if you'd agree, Ray? Oh, definitely. Yeah. So we were faced with, oh, man, the whole microcontroller thing. That's pretty much C, or whatever, or Rust, maybe if you're fancy, right? Yeah.
00:03:26
Speaker
So even before then we were talking about like, ah, what if we could somehow get some sort of closure dialect to run on these microcontrollers that we don't have to like.
00:03:38
Speaker
face the pain of writing stuff in C, really. I mean, I like the language, but man, you know. It's a closure from, I think closure started like the back end, and then front end, and then front end, back end, and then all the way to the, all the way, I'll just say like, all the way down, so. Yeah, and for me, interestingly, like the whole closure script thing was really, I'd never ever been a web developer, really. And yet,
00:04:05
Speaker
I have a huge thing to do with ClosureScript, but I've never done that web thing. I don't develop web pages. I did once in anger, and I walked away from that. So for me, ClosureScript has always been the whole reach argument that Rich has of where that language can go. And it's
00:04:23
Speaker
And for me, initially it was, I was producing iOS apps at the time. This was before React Native. And that was the first thing, that was why I actually got into ClosureScript was basically, it

JavaScript on Hardware: Challenges & Solutions

00:04:35
Speaker
was a suitable language that you could use to code and write, you know, execute something inside of a mobile app, inside of an iOS app. And then, yeah, so that was not the web, that was, you know, a mobile app, a native app, really. And then things like self-hosted has its own reach in different places.
00:04:55
Speaker
But yeah, this whole microcontroller thing is yet another example, I guess, of that reach thing. Yeah, so maybe I think obviously I have not much memory of microcontrollers and stuff. Yeah, that's pretty good. So ask all the questions you can, because I may easily
00:05:15
Speaker
assume knowledge. Especially for the audience, because I was the same way just a year or two ago. Microcontrollers are often referred to as MCUs. Those are little details that the audience may not even know.
00:05:30
Speaker
I think the only MCU that I know is the Marvel Cinematic Universe or something. Yeah, exactly. Well, maybe the thing about it is I think a lot of people think of these embedded systems and everything to do with the American community. There's obviously things like Raspberry Pi and
00:05:54
Speaker
And what's the other one? The other one with the breadboard, what's it called? Arduino. Arduino, yeah. So maybe as we start there, because the problem with the Raspberry Pi, the nice thing about the Raspberry Pi is it's quite competent actually. For a very small, cheap computer, it's got a lot of capabilities. But then obviously you get further and further down. Maybe it's worth just going down the kind of like... Yeah.
00:06:17
Speaker
So set up the stage, you know. And that's actually where we were at Vouch was when we were demonstrating applying our product to unlocking cars at the time. And we had to come up with a way to do that, and we were actually using a Raspberry Pi to do that.
00:06:37
Speaker
And that was great, because Raspberry Pi is effectively a computer. It's running Linux. And we were doing that using Node. And we could have been running Java on the thing if we wanted to. It's completely capable of doing all that. But isn't Raspberry Pi with a, it's, say, the Intel, or is it what kind of chip it is using, then, CPU? Oh.
00:06:59
Speaker
Is it with, um, is it an arm maybe? Is it on? Yeah, probably. Yeah. Okay. Yeah. And that didn't even really even matter when you're, when we're doing stuff like a node and closure script, you do see which CPU it is. Yeah. You've got an operating system like Linux. So it's, yeah, exactly. So you're like, you're like multiple levels of both stack anywhere. That's true. Yeah. Yeah. Yeah.
00:07:21
Speaker
And I'm trying to remember what so we were we were basically building our stuff on Raspberry Pi. And we were trying to harden it at the time because we were going to start using it to give demos and whatnot. And it's just like you could argue a Raspberry Pi.
00:07:37
Speaker
is a little bit fragile, at least the ones I had. You can buy enclosures, industrial strength enclosures to put a Raspberry Pi within. Wait, when you say hardened, you mean physically? Because I was thinking hardened doesn't execute it twice. Yeah, physically. Oh, no, no. Physically, the thing is just fragile where, for example, you have to be careful not to cut its power because you might corrupt its
00:08:03
Speaker
uh, file system. Uh, and, and I did that. I like lost my file system at one point. So, so we were like at the time and voucher, we were like, is there, um, is there something that's more robust? Uh,

Nostalgia & Practical Hardware Experiments

00:08:15
Speaker
and, um, we actually started to work with, uh, bill heard at that, at that point in time to help us make some real hardware. Um, people don't know who bill heard his mic. Yeah. Thank you. Yeah. Um, I just assumed everyone know that.
00:08:29
Speaker
Okay, so first of all, do you even know what Commodore is as a company or what Commodore computers were? The whole audience may not even know that, right? That's true. Yeah. Especially when we start episode 69 and then we're targeting younger audience.
00:08:45
Speaker
Yeah. This is the age group that we're targeting. And this actually, this thing that we're going to talk about with the microcontroller kind of like hearkens back to that day where when we were all kids, you would buy a basic computer and you flip it on and it had like basic and it's ROM. Within milliseconds, the REPL was up. Effectively, it was a basic REPL. Yeah.
00:09:09
Speaker
As a kid, you could start typing and learning, instant gratification back then. No internet back then, you just flip on your basic computer and start coding. So Bill Hurd worked at Commodore and he designed several computers, but I think the most notable one was the Commodore 128, the one that followed the Commodore 64. The Commodore 64 is the popular one.
00:09:29
Speaker
So, so Bill basically has been doing electronics his entire life and he helped us basically in taking what we had at the time and converting it into like a more like, I don't know, a more real or going down one layer, you know, making it out of my microcontroller and
00:09:51
Speaker
Because of what we needed to do in Vouche, we needed to basically deal with CAN bus messages in automobiles. Bill basically went and found a microcontroller that could do CAN, and that was the ESP32. And CAN is like the car network, isn't it? A car area network. So the network of components within a vehicle.
00:10:12
Speaker
Yeah, basically. Um, so what we were doing is like, if you, if you think about those, um, if you're going to get your car worked on, there's the, I'll say it wrong OBD or OBD ODB, the port, the little Jack that they stick the thing in the underneath the steering wheel and they measure like your engine stats and stuff like that. That's, you can get to the canvas in a vehicle that way. And on older vehicles, you can actually, um, send some messages across that, that network and unlock your car. Now, since then cars have been, uh, you know,
00:10:39
Speaker
the security round cars has been increased, but I have like an old 2011 Prius that you can unlock it that way. So we were doing stuff with Kian and that was why Bill picked the ESP32. He

Optimizing JavaScript for ESP32

00:10:53
Speaker
actually didn't even know about the ESP32 himself. He just went looking around and talked to some of his
00:10:58
Speaker
his associates and they said, hey, check out this microcontroller. And it turned out to be a really suitable one. And the interesting thing about that one was it actually has a, it's a pretty capable chip in terms of RAM and processor speed.
00:11:17
Speaker
So it's almost as if when you think about the Raspberry Pi and then the Arduino, and then you go all the way down to things like you would normally think of as the ST or Nordic chips, the low end things, the ESP32 kind of floats in the middle there somewhere. It's got like a megabyte of RAM if you get the higher end. Oh, wow.
00:11:41
Speaker
same, same amounts in flash, you know, it's like, it's a pretty beefy MCU. And, and we had prior to that, we, so we were, we were always just looking into this thing called Esperino, which is a JavaScript engine for, um, microcontrollers. So we had always thought like, I mean, we might get into this world and we'd, we'd had our eyes on this thing called Esperino. And it turns out that, um,
00:12:09
Speaker
Once we had picked the ESP32 for the thing we were doing, I realized, I thought back to the SS Perunia thing, and I went and looked and found out, oh, it actually supports the ESP32. And that was where the light went off in my head. I'm like, oh, this thing has enough RAM to actually pull it off where you could run ClosureScript in the thing.
00:12:31
Speaker
Whereas, we had actually been looking at the Esperino previously, and we were thinking, oh man, maybe there's all types of shortcuts we could do to try to get ClosureScript to seem like it's running on it. So I guess we could talk a little bit about what Esperino really is. So before that, so ESD is the microcontroller, right?
00:12:55
Speaker
ESP32 is a microcontroller, but it's also, it's also kind of like, um, 32 as in 32 bit, or is it, uh, it is a 32 bit thing. Yeah. The previous one was ESP852 something or other. So, so, but yeah, so the, the name might have something to do with the fact that it's 32 bits.
00:13:17
Speaker
I probably have plenty of dumb questions, I guess. Yeah, no, go ahead. Because I think my electronics knowledge is from, I don't know, 20 years ago with my engineering. I'm assuming the audience is mostly into Clojure and ClojureScript and may not necessarily even know about these things at all. Yeah, so we can talk.
00:13:37
Speaker
Maybe. What is the difference then? I know I studied it a long time ago, but there is a difference between microprocessors and microcontrollers. Is it like an instruction set? This is where I'm speculating a little bit too. When I think of the stuff that's inside of all our computers, that's a microprocessor.
00:13:59
Speaker
Maybe it's just the way the terms are used, commonly used, but when people say microcontroller, they typically mean one of these little embedded devices. But to be honest, what is the real definition and the distinction? I don't know. They're doing pretty much the same stuff. They have the instruction set and then they execute it and they interface with the hardware that you have.
00:14:23
Speaker
Yeah, and these microcontrollers typically don't really have an operating system, or if they do, it's like a low-level thing that might let you do something with threads or something like that, but it's really like... There's typically no file system. The typical model for these things for the audience may not know is you typically write a little C program that can do something
00:14:48
Speaker
It will calculate something or interact with the world through some facilities that the chip may have. You just compile that program and that's the thing that runs on the microcontroller, like a single program. They're very, very specialist. That's the idea. They're not general purpose.

Microcontrollers vs. Microprocessors

00:15:04
Speaker
They're very specialist. They're meant for particular industrial applications, for one or two particular things.
00:15:11
Speaker
usually to read sensitive data or to either to read data or to push data to again other small controllers. So ESP32 is the microcontroller that you're using and now this one can run compiled JavaScript
00:15:32
Speaker
Well, what is the idea between SQL and SQL? OK, yeah. So if you say, OK, the main thing you run on a microcontroller is some C program that you wrote, right? Yeah. Whatever. So you may say, well, what if that C program could interpret JavaScript, perhaps? You could feed it strings and it could say, oh, I'm going to execute these things.
00:15:53
Speaker
So there's several of these kind of things in this class that run like there are several, you know, target things that will run higher level languages on these things. And one very popular one is like Circuit Python. And there might be another variant to that. So Esperino is basically one of these things that will run JavaScript. And, you know, there's a handful of these, maybe half a dozen of them.
00:16:19
Speaker
and I don't remember the names of all of them, but Esperino, the way it works is it's not truly, it's not really interpreting the JavaScript that actually parses it down and puts it into some internal memory representation inside of it. We could talk about the how, but really that's what it does, is basically you can say, oh, if you get Esperino, you can put it on not only just the ESP32, but other
00:16:44
Speaker
even smaller microcontrollers. And once you do that, you can basically connect to your typically when you're working with my control microcontrollers anyway, you connect to them using some sort of serial cable like like a USB cable you hook to it. And then you can basically type commands to it through a terminal. And and Esperino basically makes it so that you're basically at a JavaScript repo or prompt, and you can start up you can you can type in one plus one and hit enter and you'll get back to
00:17:15
Speaker
It's actually surprisingly performant. It's not blazingly fast, but it will execute JavaScript.
00:17:26
Speaker
I guess I'm going to slip into talking about the how again, but it's interesting technically. It mainly is really concerned about preserving RAM because you might think, oh, you don't have much CPU power, but really the main constraint is RAM when you're talking about this kind of things. You may only have kilobytes of RAM or several hundred kilobytes of RAM to run things in.
00:17:56
Speaker
So what it's doing is Esperino is pretty clever and it takes your JavaScript and compiles it down to very efficient in-memory representations. And as a matter of fact, there's a cool thing on the Esperino website where they talk about like, what is the smallest way that you can represent an algorithm? And they take like,
00:18:15
Speaker
the bubble sort or some algorithm that you can imagine is like 15 lines long. I can't remember which one it is. And they represent it in different languages and they look at like, well, what if you were to just write that thing in C and then get the machine code associated with that, right? And they showed that minified JavaScript is smaller than the machine code generated by a C compiler. It's like the most compact thing that we as humans can produce right now. And maybe that makes sense because we've all evolved to make JavaScript shipped to browsers, right? We can compress it down almost nothing.
00:18:44
Speaker
So it is the most efficient way as humans, as we know right now, to express algorithms. It's made up by JavaScript. I know, it's kind of funny. And that's effectively what Esperanto kind of leverages is the ability to represent its code in the tiniest way possible to fit in on those small things. And then it just arranges to execute it somehow.
00:19:03
Speaker
Okay, so when you write a program and then you compile it, quote-unquote, compile it down to JavaScript, then that's what is being stored in RAM, because you need to read it from RAM to execute this one, right? Yeah, so like if you imagine, like, FSParino is...
00:19:21
Speaker
running along and it hits a new function that it needs to like you, your one function calls another function. It's not it's not like looking up the text for that JavaScript and interpreting it. It's actually already turned it into some internal form and executing that in memory. And I think this is correct what I'm saying. So I could I could be wrong. You could go look at the way Esperanto is really working. But that's that's roughly the idea is that it and it's actually not it's not fully like ECMAScript compliant.
00:19:49
Speaker
JavaScript. It's not a full implementation because it's actually being pragmatic and cutting corners where it needs to in order to preserve. One example of that is in JavaScript, if you're dealing with a number, you might typically think of that as like a double in terms of its size. Well, on Esperino, it's like a float. It's like half the size.

ClojureScript Compilation & Deployment

00:20:10
Speaker
And just lots of things like that exist. And there's just other things that it just doesn't support, like JavaScript has labels. You can label things and jump to those labels. That's where it just says, ah, it's not going to support that. It's not important enough. Yeah. OK. So the language-wise, it's a bit, it's a scale, a little bit of scaled-down version to microcontroller level. Yes. Yeah. JavaScript. OK. It's like a profile of JavaScript. Yeah.
00:20:39
Speaker
Okay. So why not write JavaScript then directly? So where did ClosureScript come into the picture here? Have you ever written JavaScript in the future?
00:20:50
Speaker
I do. How dare you? Using Jake Clayton a long time ago. Yeah, okay. Exactly. No, you can. Yeah. So, no, you can. You could write. That's, and Esperun is very popular and it's a perfectly suitable approach. Yeah. Yeah. Let's be honest. I mean, that was definitely the approach we were looking at as well at the beginning because we didn't think that we would be able to get closure script on
00:21:14
Speaker
these devices, we definitely would rather write JavaScript than C, at least at the beginning. So anyway, Mike, hi to you. Okay. Yeah, and another thing to mention. Oh, okay. So it's just because we are who we are. We wanted to stick in the language that we were comfortable with, right? And
00:21:36
Speaker
I don't know if that's a satisfying explanation. I could write JavaScript, but... Well, it is a closed script. Closed your podcast, so I think that's the reason. Yeah, I mean, this language has value. I hope we all agree. Maybe it's a better question because I think we always want closed script.
00:21:53
Speaker
The better question is, why did you think it was possible? Or how did you get to the point where it was possible to execute on such a small constrained device? Oh, okay. Yeah, so even before that, I had tried running, for example, the ClojureScript unit tests. I took that.
00:22:13
Speaker
When you enclose your script, when you say, Hey, I want to make, I want to run its compiler unit tests. It spits out in it like an advanced file. That's just a chunk of JavaScript. And you could take that JavaScript and try to run it anywhere. And I had done that with like Esperino in the past and it never did run properly. And at one point, and this, this is part of what, what it took to get the stuff running. It's just like finding out the little reasons or what it was. And, and at one point I ran them and I don't recall what.
00:22:36
Speaker
changed, but it worked. It worked on the Esperino command line version of the thing. You can take Esperino and put it on your Mac or your Linux box, and it's basically a shell. It's the same C program, basically. I got it to run there. I'm like, oh, wow. ClosureScript can actually run on Esperino.
00:22:57
Speaker
To answer your question, Ray, what made me think that it could fit there? I think it was just the amount of RAM that existed in that thing, and knowing that in order to actually have a REPL, the main thing you need to do to have a REPL is you need to have basically all of the ClosureScript standard library available to you. Basically, CLGS core.
00:23:21
Speaker
like map and filter and all those things, they need to be there. Or ideally, they should be there. Otherwise, you're dealing with a whole different problem where you're trying to say, oh, you just called filter, but it's not on the chip right now. Let me go somehow get it on there. But isn't the toolchain then
00:23:38
Speaker
So you write closure script on your computer, you compile it to produce advanced JavaScript, and then you just copy it over onto microcontroller storage and then run it. So you don't really need to have the whole closure script on the chip, right?
00:23:56
Speaker
Right. And what you just described is a perfectly valid model where it's like, okay, I'm going to write my stuff in ClosureScript, compile it down to advanced, take that thing and put it on Esperino and just let it run, right? Yeah.
00:24:11
Speaker
That's that's most likely what you would do if you were like making like a release build of something and you're just okay, you know But but the repel you got to have a repel to have the full experience. Yeah So and if you were if you were to do things in that mode like where you just compile it down and put it on there Then it's almost a lot like what happens when you're just working with C where you come higher C and you put it on the chip
00:24:34
Speaker
Now it's not a completely fair comparison because typically with these microcontrollers, when you're doing C, you can establish a debugger session and you can hit break points and, you know, yeah. But what I wanted was a REPL onto the thing. I wanted to be able to, um, and part of the, part of the story there is, um, things like Esperino, what they do is they take the facilities that your chip has like, um, well,
00:25:01
Speaker
Well, so one thing all microcontrollers typically have is what are called GPIO pins, general purpose IO pins. So if you imagine like you want to hook up to something else, you have all, you know, everyone when they think of a chip, there's all these pins sticking out of it. Some of those pins

Future of ClojureScript: Native Code Possibilities

00:25:16
Speaker
are used for data to drive things, right? And you, when you're writing your program, you may say, hey, take this pin and raise its voltage high or raise it low so that you can light up an LED or
00:25:25
Speaker
unlock a lock or what do you want to do? Or you may want to, you're sending messages to a can controller and you want to like do that through GPIO pins or there's other higher level protocols above that, I squared C and spy. But essentially, Esperino takes those low level facilities that are available, GPIO pins and whatnot, and basically turns them into kind of like first class things that are visible in the JavaScript environment.
00:25:54
Speaker
Okay, so you can just refer to them so so if you if you manage to have like if you have an Esperino or Apple into one of these controllers you can just sit there and you can like Drive your GPIO pins in real time like you so it's basically having like a file handle and then you can just Write bits to it or data to it directly
00:26:17
Speaker
Yeah, so the GPIO pins, they're really lovely. You just say, hey, raise this thing high, raise it low. And the thing about having a REPL, and this is why Esperino itself is fundamentally a cool thing, is that you can do it in real time. You can get a terminal into it.
00:26:37
Speaker
and you can just sit there and change the world by typing things into your thing. And that's what we all think of when we think of a REPL, right? You're changing the state of your program or adding new functions to the mix. So, you know, ClojureScript having a REPL into it is the same idea as just in a different language expressed one level higher. You're defining new functions, you know. And the cool thing is that if you're trying to prototype something,
00:27:04
Speaker
it's really nice to be able to say, oh, let me try driving this line high and see what happens. Rather than the traditional C model, where I guess you would change your code, compile it, and put it on it, you might mess with it in the debugger to try to force things. But yeah, come on. Yeah. So basically, what's weird about it, if you look at it the way, is that embedded programming, embedded controllers, or ECUs, or microcontrollers,
00:27:34
Speaker
They essentially take you back to the mainframe, where you're batching your programs, sending them over there, getting them run, and then seeing what the results are. It's not usually taken all day, but you know. Yeah, one cool example of that, there is a guy who helped a lot or contributed a lot to Esperanto, his name's Kieran Sheila, not to confuse
00:28:00
Speaker
things by mentioning another Kieran here. His first name is Kieran. So he basically was working on something with Vouch and he took one of these Esperino things out and basically with ClosureScript
00:28:15
Speaker
and I was basically doing an experiment effectively with it with a fob to his car and actually like at the REPL messed around and managed to unlock his car that way by finding the right sequence of things you know and you could figure that out the old-fashioned way like you know but it was you know he's basically oh because he was in the um
00:28:34
Speaker
in the mode where he was learning and experimenting and seeing what the FOB does and how it actually works. So he basically said, oh, I need to set this line so that it drives at low and open. So he could quickly iterate and prototype and say, oh, here's how you do it, and then capture that knowledge and carry it forward. But that's the kind of stuff that you can do if you have a REPL into something. You can be in that experimental playful mode where you're just typing and seeing what happens.
00:29:05
Speaker
But is there a chance that I can burn the microcontroller? That was, I remember that was the old thing, right? With basic computers. Yeah. You could always, you could go into Sears and type in a command and burn it up. Yeah. Um, well, I guess what you're saying, Mike, is that, is that Espino gives you kind of safe access to the hardware. So it's kind of got like these, uh,
00:29:30
Speaker
high-low things that are probably pretty standard boundary. What Vijay was saying was you could actually hook up your

Comparing Circuit Python & JavaScript

00:29:39
Speaker
microcontroller to something that's affecting the real world. And because you have so much freedom, you may actually make the robot
00:29:47
Speaker
break the hole in the wall or something. It's almost like, okay, let me, let me raise it to one. And then I type hundred and then. Yeah. And I guess that could happen if you're writing stuff in C anyway, but yeah, but it's even, you could do it much more quickly at a repl. Yeah, basically.
00:30:10
Speaker
Yes. I think that's the experience you want to have. Immediate feedback. If you have like an increased RPM to whatever and then I forgot to make it 20 and then I just like 2,000 of them just blows up.
00:30:25
Speaker
Do you think though, Mike, coming back to the closure script, do you think the fact that you had a good experience with self-hosted closure, sorry, self-hosted closure script, helped you with these embedded controllers? Because like you say, you know what's needed to bootstrap the whole thing. Yes. For me, it was fair to say that I knew what it meant to make a REPL.
00:30:51
Speaker
I mean, I think everyone's familiar with what a REPL is, but if you actually had to sit down and make one and know all the pieces, and it's not that complicated, but it gave me the confidence at least to say like, yeah, I've made REPLs before. I think I know the pieces that would be needed to make a REPL into this chip. One thing that, for example, that you don't get with the
00:31:14
Speaker
with the Esprit REPL into the chip is you don't get the ability to load files. So you can't require files. And that's just a limitation that exists in the implementation right now. So to back up a second, I'd have to explain, how does that even work with ClosureScript? If you say, I'm going to require some namespace that you have on your disk on your computer,
00:31:42
Speaker
And the way that typically works is locally, the ClosureScript compiler will compile that namespace down to JavaScript. And then the trick is somehow getting that JavaScript into the execution environment. So if you are, let's see, if you're coding in a browser with ClosureScript, typically that involves, I guess, just, well, how does that work? Since I don't deal with browsers, I don't even...
00:32:08
Speaker
Maybe Ray, maybe you know, how does the browser get the resulting JavaScript into it? Does it just pull it across a web socket or something like that? Yeah, for at least one big wheel, it's automatically pulling it from the socket, right? Yeah. But otherwise you can just refresh it and then it's attached to the HTML already. So one JavaScript thing is loading the other files. There is a loader, app.js or whatever. Yeah. So you can do it like that. But obviously you can just load it from
00:32:39
Speaker
from the browser's local storage as well, if you really want to go crazy. Yeah. Okay. So for me, like, so for my experience has been like, um, doing, uh, well, there's the Ambli REPL, which is a ClosureScript REPL into iOS, right? Yeah. And the way that that works is it sets up a web dab.
00:33:00
Speaker
and the web tab is on the phone, so it becomes like a thing that you could mount from your computer, and then you have a file system and you just make the Closure Script compiler right there. For self-hosted, if it's plonk, the files are just there. You can read them directly, right?
00:33:21
Speaker
For things like replete, you can't do that. Replete on iPhone, you can't require a file. It's just not set up for that. So for this Esprit REPL that's into an ESP32 chip,

Community Contributions & Technology Exploration

00:33:35
Speaker
if you were to try to require a file, it just doesn't have the facilities to kind of get that JavaScript over the quote wire and into the REPL.
00:33:44
Speaker
But other things do work. You can have your own namespaces if you'd like. And part of the way that works is when you're compiling the REPL itself to get it onto the chip, you can have it also at the same time compile your own custom namespaces that you may have that you'd like to have pulled over as well. And they would just kind of get bundled into the same thing that's put onto the chip.
00:34:07
Speaker
So what is the, I'm trying to understand how the, how the setup works. So I have this, this, this microcontroller, and then it has somehow S burrito installed on it. So it's working. And then the closest script stuff that you said, it's also installed there.
00:34:23
Speaker
Now, how do I, so how do I write an emax now and then comply with it? Yeah. And then connect, connect to the double from. Yeah. So, so the way I chose to do it is I made it so that, um, the ESP32 actually supports wifi. Um, it actually, it also supports Bluetooth. Um, but so I basically, I, I arranged things and there's multiple ways you could do this. Um, but I just arranged it so that, uh, the, um,
00:34:50
Speaker
the ESP32 will join your local Wi-Fi. So you basically, you give it the password to your Wi-Fi and you give it, and this was not something I created. The ESP32 or Esperino already had this capability built into it. And so then I just established a TCB connection into it.
00:35:08
Speaker
Okay, give me the address and then you know, yeah, basically, I have it. Exactly. I make it run a little server. Listen, yeah, yeah. And then from that, that's, that's basically the REPL connection. And that's like when you say, hey, you know, you know, evaluate some form, the the JavaScript for that form is sent directly across that TCP connection. So what does that look like in terms of like, because BJ probably wants to use n REPL or something like that, to get to it is this support, like,
00:35:37
Speaker
and REPL and bank code and all these things. OK, yeah. So the cool thing is ClosureScript has an ability for you to define your own custom REPLs, your own custom REPL implementation. And so it's got this base functionality in the ClosureScript shipping code base. And you can make your own REPL by basically following a few patterns, implementing a protocol,
00:36:03
Speaker
And that's all this particular, a street REPL is, is one of those. And because of that, it plays in the normal ecosystem like any other REPL. And you can use Emacs. There's actually, Kieran, Kieran Schiele wrote instructions for how to set up Emacs to work with it. And I imagine that those instructions, I don't use Emacs, but sorry. But, I know. Okay. That's what I've said number 69. I think, thank you, Mike.
00:36:34
Speaker
But I'm, I'm assuming the instructions are just like any other, um, so how do you use it with a proper editor? I use, um, yeah. So let's see with cursive, I would use this thing that I created called tubular that basically makes it easy to hook in. Um, okay. I never did forgot the P ripple thing. Sorry, Ray. Yeah. Well, we'll have to, we'll have to do a PR for that one. Yeah.
00:37:01
Speaker
But yeah, to answer this, it's just a REPL like almost any other. And it really is a standard ClosureScript REPL. And apart from that deficiency where it can't load files, it looks like any other REPL. So if you've got a requirement where you want to do map filter reduce, then it's all good. But if you want to do some sort of closure set operation or something like that,
00:37:29
Speaker
Do you have to arrange that beforehand or can you, what comes with it, what's built out in the repl? Because I know that some repls come with those kind of like, and I think some repls you ship come with some of these like common libraries, closure string, that kind of thing.
00:37:48
Speaker
Okay, yeah. So the best way to explain it is the Esprit REPL is partially a tiny little ClojureScript program that implements that server that I was talking about. And it actually does all the replisms, all the things that it needs to do to be a REPL.
00:38:07
Speaker
And in that closure script namespace that implements that REPL, whatever it requires ends up being in your target environment. So, like, Ray, you mentioned, what if you want to do something with closure set? If that thing is not already including or requiring closure set, then it just wouldn't be there. You'd have to, like,
00:38:28
Speaker
either add it to that REPL or add it to another side file that you're gonna have compiled with the mix inhabit over there. And then it would just be there. It would end up getting put together. And what happens is the way this works is when you compile this thing, when you compile the little ClosureScript program that represents the REPL, it gets compiled down and we use, so in the ClosureScript compiler, you can choose like advanced,
00:38:55
Speaker
or typically when you're dealing with a REPL, you do none, or you could do white space in simple or different closure modes. So what we do specifically for this Street REPL is we do a simple. And simple is basically a fairly compact representation of things, but it has this characteristic where it preserves all the top-level functions. So map and filter and all those things and CLJS core are still actually there.
00:39:21
Speaker
So they're not minified or they're not having this weird naming, like in the dance. Yeah. Or mangled. Yeah. Yeah. Like the insides of the functions might get mangled. But the top level, yeah. So you can actually see all the symbols pretty easily and then use them.
00:39:36
Speaker
Yeah. Yeah. And so that what that part of like, I guess me delving back into the how is what happens is it produces a simple output, which is one big concatenated JavaScript that everything needed to run everything. And that's typically, if you go back to closure script and the way it works, when, when you apply glue Google closure to it, it's doing whole program optimization across that big file. Well, that's the actual file that we take and we put onto the microcontroller.
00:40:03
Speaker
And we put it into a place, into a special, to make this work, we actually had to take Esperino and kind of modify it a little bit. And one of the modifications we had to make was to repartition. There actually is like on the flash, there's partitions for different places of things. And they had one partition which is called JS code.
00:40:24
Speaker
And if you put anything in that, any text into that partition, when the Esperino engine starts up, it will execute whatever JavaScript happens to be in that particular partition. So we basically just put our symbol into there and it wouldn't fit normally. That was one of the things that had to be solved. And the solution to that is to figure out how its partitioning scheme works and just make a gigantic partition that can hold. And it has to be about a megabyte in size because
00:40:51
Speaker
When you use simple to make CLGS core, it's about 900 kilobytes of text. I think this is like the other end of the spectrum because people are writing the web programs these days. I mean, nobody cares about space or memory or anything.
00:41:11
Speaker
We just add like a million node modules and then see what is going to happen. But here you have to be very careful in what you're adding and then how much you have. I think that's a bit unfair though, Vijay. Things like yarn and stuff like this, they strip out or they do all the tree shaking before you ship it out.
00:41:31
Speaker
Yeah, that's true. But it's not, I mean, I'm talking about normal websites these days, which have like a million trackers and all the crap and everything. Cookies and the trackers. Yeah, exactly. Yeah. Well, I think IoT will eventually get to the point of, you know, I think the only place where the surveillance state will exist is, you know, probably optimistic.
00:41:58
Speaker
So people will be installing it on a Google ad block or so to microcontrollers. Well, Mike's already kind of like bit mining on the ESP32, I'm pretty sure.
00:42:09
Speaker
So you're mining cryptocurrency on that one. Good, yeah. I have quite a few of these things lying around. I might as well put them to good use. So what is the memory efficiency of these things? Sorry, not memory. Power efficiency. So how much do they need? So the coolest tweet I have on that subject is I had one of these ripples running and it was using less than half a watt, I think.
00:42:34
Speaker
Wow of power to run. Yeah. Yeah, so it's like yeah these things and that's you know You could actually like the way these things are designed is you could put them to sleep? You know and kind of have them wake back up again So you could even like amortize and get like almost no consumption. Yeah. Yeah. Yeah One of the other things though Mike if I remember rightly coming back to the beginning of the discussion was that you wanted to talk about like the start of time and
00:42:59
Speaker
Because Raspberry Pi was taking a while to start off, and all the bootings, all these things. Yeah, that was one thing that caught me off guard was how microcontrollers are instantly on. You turn the thing on, and it's running. And that's just weird to me. I think it's weird to a lot of us who are used to things having to quote boot, right? There is no startup ding, like ding. It's exciting.
00:43:26
Speaker
Well, there isn't like there isn't like 1980s BIOS running on there. Right? Yeah. So it's just like runs your C program immediately. And if you get Esperino, and you put it on one of these things, you you actually you boot the thing and it like, hey, maybe it takes like a second, you know, it's not instant, but it's and then your your JavaScript REPL is available, you can start typing commands like that within a second. And
00:43:50
Speaker
The thing about ClosureScript, though, is there's that megabyte of code that it has to run upon starting. So Esperino fires up and it's like, oh, let me go see if there's anything in this JS code partition. And it runs that. And that code takes about 15 seconds to run. So when you start the thing up, it just takes about 15 seconds to load up, basically, CLJS core. You could look at it now. Now, there's things you could probably do to make it faster.
00:44:16
Speaker
You don't have this. I mean, this is only for the development mode, right? When you want to actually have a raffle into it. Because on production, you have the instant loading stuff anyway. Yeah. So you can do advanced. And I think my memory is fading now. I think the numbers are around four seconds if you do advanced. So it's not instant. And I even went down. This is one thing I kind of went down this rabbit hole of trying to see
00:44:40
Speaker
how fast you could make that work. And it turns out like if you, let's say you make a simple program that does some stuff, like it does a reduce and calls a few map calls, you know, like maybe like a program that's not trivial, you know, just does a few things, but it's not like a gigantic program. It's just like, imagine like a 15 line program that you want to like start up and do something. And I went through that exercise and I made it be advanced. And then I found interestingly,
00:45:05
Speaker
that Google Closure Compiler, which does dead code elimination, it actually leaves a lot of code behind that it doesn't know is actually dynamically dead. It does static analysis to see things that it knows cannot be called. But in fact, there was like, I want to say if I remember correctly, like two thirds of the code that was in there was like,
00:45:29
Speaker
truly never going to be called. It was, and so I went through and I, I, you know, I spent like an hour and I would like to remove a function and see if it still worked and just like went through. Yeah, I know. I was like, I was a man on a mission. I wanted to see like how small I could make it. And I went through and that's where I think I got like two thirds of the code gone. And the, and the remaining bit was the stuff that actually was needed to execute this little non-trivial program. So that's kind of an interesting point is that Google closure, um, compiler when it's doing advanced,
00:45:59
Speaker
is only getting rid of stuff that it statically can see is never called. There's still a lot of stuff that dynamically is never called, but yet it just can't tell.
00:46:12
Speaker
So we have Closure Script REPL now, but that is not, I'm assuming, obviously it's not gonna be in production because otherwise people will be just connecting to my car chips and rippling into my car. Yeah, yeah, so to be honest, a lot of the stuff at Vouche what we've done is we've actually stuck to more pragmatic, traditional ways of doing things with C to make solutions that will, like if you think about cars have ECUs in them and you're gonna perhaps make some code that's gonna run on an ECU,
00:46:41
Speaker
I don't think we're there yet in terms of like these higher level languages running on ECUs. Maybe, maybe another half a decade to a decade. It'll be like, yeah, the stuff is fine. And those ECUs will be much more powerful. But for now, I kind of think of this whole thing as like a foray in that direction, where you can like experiment and see how things work. And it also is like a little slow, right? It still is like, if you say, I want to unlock my car, and it has to turn around and like,
00:47:11
Speaker
maybe process a seaboard message that you sent across the wire to it. You're starting to run up against performance problems where you're like, ah, maybe I should do this in a native language still. But those things change, right? Given the few years gone by. Exactly. Well, especially with your comment about JavaScript running very fast, eventually we'll get there. Cars running on closure. Well, another thing is like, for example, Scala has a
00:47:39
Speaker
an equivalent Scala dot JS, like a, a, a JavaScript analog. And I think it was like maybe two years ago now, somewhere in there, they came out with a native thing that compiles Scala down to native and closure starting to have the same thing with raw, right? You can basically make native things. And I think that's ultimately an interesting thing for framing stuff down on these microcontrollers. This is, you can somehow take these high level languages that we're writing code and compile those down to machine code.
00:48:09
Speaker
Yeah. And just that's the thing you put on the chip in the end for your production delivery. But don't you think maybe, well, not don't you think, but, um, what's your opinion on cutting the middleman then completely remove the spring on them, make closure.
00:48:24
Speaker
Yes. Compile to C, then. That's exactly what I was trying to say. Yeah. Thank you. You said it better than me. Basically, no, that's exactly it. Closure compile to C. Or either C, or even if it knows the machine language of the particular chip you're cutting. Yeah, exactly. But C might be a good intermediary. Yeah, exactly. Because then you cut the middleman completely, and then you have much more, I don't know, there is no reason to have another. Well, I mean, I think the other way is looking at WebAssembly, isn't it?
00:48:54
Speaker
WebAssembly is another path to get there. Because what you also kind of need is garbage collection to make this language work. And I think WebAssembly might have an answer to that now. Yeah, it does. Additionally, it didn't. But I think that's what it does anyway. Yeah. Or maybe you could even do reference counting. Kind of like they do with Object to see an arc. Yeah.
00:49:17
Speaker
Because I understand you're working in the cars domain. If you move that to a general purpose thing, what you're saying is that I can get these ESP chip, put your program there with CLJS REPL, and potentially I can connect to, I don't know, some other Bluetooth devices, like my lights or whatever, and then use ClosureScript to drive them.
00:49:41
Speaker
Is that, yeah, is that a possible scenario? Yeah. So in theory, like, um, so vouch for a while for some of the prototypes, we were using, uh, ESP 32 boards or ESP 32 chips on our boards. And we would, we would program them and see, but in theory, everything could have been done and closure script. It would just be slower. Um, but there's conceptually it's turning complete, right? Anything could have been done that way. Um,
00:50:07
Speaker
So we can connect to some other Bluetooth or whatever, or Wi-Fi thing, and then send signals to other connected home devices by writing closed script program. Yes. Essentially, that's the dream. Yeah.
00:50:22
Speaker
Because the closest I got to this level was I had this NXT thing on Lego. Well, I still have it, NXT3. Yeah, I guess I know what that is. Yeah, yeah. My son has one of those, yeah, like a Mindstorms. Yeah, exactly, Mindstorms, NXT, NXT3. So it came with Lego's operating system, some shitty thing with the blocks and nonsense and other stuff.
00:50:44
Speaker
So I had to flash it with something called Lejos, L-E-G-O-S. So that actually brings JVM onto that thing. I remember experimenting with that one with ClosureScript back then, no ClosureScript on this one. It was incredibly slow to do anything on that one.
00:51:03
Speaker
I mean, you can imagine there's already Java, and then rest sheet, and then on top of it, there's ClosurePlus. Yeah, so if you hook up to an ESP32 with ClosureScript, and you do say, map ink over the vector one, two, three, and hit return, it will do that in a matter of two seconds, say. It's not blazingly fast, but as a human, you can go now. But if you say, do that over reduce plus over range 1000,
00:51:30
Speaker
Yeah, that actually takes like 20 seconds or so somewhere around there, you know, it's, you know, you have to be careful. So it's like, at this current point, you can only really use this to kind of like be a high level coordination of actions that may be, you know, themselves implemented in native things. Yeah. Yeah. I think what you're trying to say as well, Mike, is that like, based on the previous examples, if you want to try and do interactions with the hardware facilities interactively,
00:51:59
Speaker
That's really the benefit that we're getting out of it, not necessarily the, you know, the kind of general purpose, the general purpose. Yeah. Usage across, you know, in, in sort of like setting up your smart home using ClosureScript is still a bit distant, you know, in production, but it's definitely super useful for experimenting with these kinds of things and, you know, driving these, these, these different parts of the embedded devices capabilities.
00:52:29
Speaker
That you wouldn't that you wouldn't easily get without languages. Yeah, and like what's happening big time in that whole space is circuit python. I mean, people are starting to see that you can just use that as a high level language to interact and drive these chips and as opposed to like.
00:52:46
Speaker
I wonder how many people even know C these days, to be honest. It's just so much more accessible to everyone if you say, hey, for example, a lot of the people who are into hardware are not also programmers, right? And vice versa, programmers are not into hardware.
00:53:05
Speaker
Um, so so like for hardware folk if they say I just want to I know my heart I know the hardware stuff I know how to do voltages and resistors and leds but yet they want to program their thing that they just made then they're faced with this another another whole problem and And for them the answer is probably not closure script, right? That's uh, you know, but python, you know, it runs on the ship So that's becoming popular. It's like yeah, you can program stuff in a higher level language and and uh
00:53:32
Speaker
even for people like us who are programmers, it's, it's easier to do something in ClosureScript than it is in C, right? Yeah. Like C doesn't have a map, right? If you want to pull up a map, you know what I mean? That, that pain, it's like, oh, you're like, how do I do this? Oh, I'm going to make a fixed size buffer and put pointers in the thing and walk that buffer. I'm going to try to, yeah, you, you know where you've been there. It's like, yeah, even, even if you are an experienced programmer, C is. Yeah, it's still, yeah. It's just, I think once you get to, yeah, exactly.
00:54:02
Speaker
I mean it's just yeah exactly it's nicer looking assembly pretty much you know see at this point so yeah once you get used to these these higher level i mean see is supposedly higher level but even one more level highest level programming like closure and everything it's pretty difficult to drop into that level and then lose all the all the idioms that we could we use.
00:54:24
Speaker
So how do I get this thing, Ben? So I just go and then buy ESP chip? Yes. Okay, so if you want to mess around with this, the main thing is they're different ESP32 variants. And you got to make sure you get the one that has the RAM, all the RAM. And there's this version called the WRoom, which is the smaller one. You want the WRover, the bigger one.
00:54:48
Speaker
Maybe we can put show notes in because it'll be hard. Yeah, but there's like a 16 megabyte version or really you only need like the 8 megabyte version because Espressive the folk who make the stuff that you use that the tooling that you use to code to the ESP32 Even though some of these bigger chips have that much RAM They don't make it it's not possible to access all of it yet. So you only need like 8 meg so you can you can buy if assuming
00:55:16
Speaker
you can convince yourself that you're buying the right one. You can buy one of these things off. It really is. Philip Meyer helped me with this one. He's also in the Closure community. He helped me pick the right one. Because you go on Amazon and there's so many of these variants and you want to get the one that has the right amount of RAM. Then as long as you have one of those, you can
00:55:38
Speaker
get the esprit repl and hook it up to it. It's all you need. Oh, no, they all come with, they all come with wifi. You're all good to go with any of that.
00:55:51
Speaker
And, uh, yeah, you can, you can then, um, any of these, it is off the shelf ones can pretty much work. Um, I also made one for myself because I was interested in that, but you don't, you don't need that. That's just a, it's basically, um, the way you could look at is these ESP32s. Um, if you back up a little bit, they are basically, um,
00:56:13
Speaker
A chip that's inside of a thing that you typically would call a module and it looks, it's a larger thing that has like a big silver RF can on it. Um, and so it's basically, it's a low level chip with enough stuff, uh, supporting circuitry on it to make it work easily. And then typically those things are sold on a board.
00:56:35
Speaker
a development board that has all those pins broken out into GPIOs and additional circuitry for USB, so you can plug in your USB into it. And those are the things you can find on Amazon or wherever you want to buy them from. Yeah, yeah. So you just buy the board instead of just the chip, just the microcontroller. Yeah, because if you buy the microcontroller, then you're going to have to solder it onto something. Yeah.
00:57:01
Speaker
But you have the CLJS board thingy, right? Yeah, so I just kind of did it while I was giving a talk on this stuff at Closure North. And I wanted to make something for the talk, basically, to kind of show it all working. So I made a board that has this chip on it. And it has like, for me, it was also just kind of fun to learn how to make all that kind of stuff. So I put like, a lot of these boards will have the ability where you could plug a battery into it.
00:57:29
Speaker
Lithium ion polymer battery into it. Well, I wanted to make one that And I don't know if these other boards do this, but I wanted to make it so that it could recharge that battery
00:57:38
Speaker
So I wanted to make it act much like a cell phone where if you plug it into USB, it's charging it, and then you can disconnect it. And for me, it was almost like a gimmick, but I wanted to make it so that the REPL could work just on Wi-Fi, right? So you can hook it up and get all the stuff flashed to it, and then you establish your REPL into it, and then you can disconnect it, and it's sitting there running, right? And you're actually still controlling it through your REPL over a Wi-Fi teaspoon connection.
00:58:03
Speaker
So that was part of my motivation was just kind of like to learn how to put all these things together. So if you want, you can buy those on Tendi. My daughter actually makes them. So there's a video that I have where... So essentially, a big part of it is taking all the little electrical components
00:58:26
Speaker
and putting them on the board, right? So the way PCBs are typically made is there's robots that do it, right? And they're called pick and place machines and they'll put things on there. Well, my daughter is a pick and place machine. Because we're not making enough of these things where you're not going to have like a huge production run of like,
00:58:43
Speaker
enough to justify firing up the robots. So my daughter is a human pick and place machine, and she makes these things. And we basically put these boards up on Tendi. So if you want to get one, you can get one there. And the cool thing about it is it has a little ClosureScript logo on the board on the PCB. But it is no different than in these other things you can buy off Amazon or
00:59:07
Speaker
but it comes pre-built or how do you call it? Like pre-installed, pre-flashed with ClosureScript. Oh, so that's what I wanted to do. Actually, I wanted to do that. But the thing that prevents you from doing that is you have to like basically get your IP address or you have to get it to join your Wi-Fi.
00:59:27
Speaker
Yeah. And there's ways to kind of like make it so that it could like, I guess I could, I could do that and like make it do a hot spot. You already have like a manufacturing, how do you call that? Like a floating assembly line. Like a QA assembly line, exactly. And then you have like a QA controller and then. Yeah, so it is so close to that. Yeah, so that was my initial dream was just to say, hey, if you get one of these at 30 pre and you just kind of
00:59:50
Speaker
I wanted to make it even work over Bluetooth. So you could just like power the thing up and then see it through the REPL through Bluetooth and it would just discover it and it would just work. Right. Yeah. Yeah. Yeah.
01:00:01
Speaker
But it's not that way now. You basically get the REPL, and you compile it, and you flash it onto it. And you follow some instructions. And this is the stuff that Kiran Sheila kudos to him. I made the stuff fundamentally work, but it was messy. He came along and made it nice and polished and added a lot of the depth seed and aliases and scripts around it to make it all automated so that you could
01:00:24
Speaker
do it without going crazy. Nice. So it's not prepackaged, but thanks to the stuff that Kieran did, it's pretty turnkey. Well, it has the CLGS logo on it. That is cool. That's the most important thing. That was one of my motivations. I wanted that logo on the board.
01:00:47
Speaker
And I also I also on that board I put as another little gimmick as I put little read about print LEDs on it. Oh, because I'm like, I'm like, Oh, you know, as you're using it, because like I said, like, if you evaluate a form that takes a long time, um,
01:01:03
Speaker
Basically, the eval light will sit there and flash while it's doing it. Wait, is it really read? Well, it's going to turn on at that time, or is it one of those turbo LEDs that we had on the computers back then? They don't do much. There is a little bit of faking involved where the read
01:01:20
Speaker
the read is actually done on your computer when you're typing in a form. It's done there. But it will light up that light right around that same time. And then once the JavaScript is sent over there, and then it's evaluating that JavaScript, maybe it's like,
01:01:35
Speaker
reduce plus range 1000. And that's like blocking the main thread inside there when it's doing that. But it flashes the LED by telling it to do what's called pulse with modulation PWM. It basically uses a low-level facility of the hardware to say, flash this LED at this certain rate. So it starts it flashing and then stops it when it's done. But it's a gimmick. It's just kind of cool. If you're going to have a board that's got a REPL, you need those LEDs on it. Totally cool. Yeah, yeah, certainly.
01:02:05
Speaker
So it's redeveloped, printed, and then light up. And then there is all four of them lighting up like a firework thing. And it's also got another LED that will tell you if you're connected to it or not, little things. And there's also three other LEDs that you can use that are RGB LEDs that you can light them up. If you hook into the REPL, you can evaluate forms. But then you're like, well, I want to actually do something. So there's some LEDs on there that you can light. And there's GPOs. You can hook it to other stuff. Nice.
01:02:35
Speaker
If you're interested in it, there's a part near the end of the Closure North top where I give some demos of doing stuff with the board that actually interacts with the real world. Nice. But it's a fascinating journey, taking Closure Script closer to the hardware, almost near native. Mike, what about getting Closure Script on even smaller devices?
01:03:02
Speaker
where how, you know, because I think you did try that, you're trying to put it on some smaller devices at one point, didn't you? And like partially loaded the partial the REPL and then sort of brought in other functions on demand. So you so that's yeah, like, if you think about it, like Esperino works on even lower end hardware that does not have like enough RAM to hold off all a CLGS core. So
01:03:26
Speaker
you could imagine arranging things so that you could at least establish your TCP connection into it. And then if you typed in something that said map filter, whatever, and it hit those functions, it could perhaps fault them in, but I haven't gone that far. I've never built that, that facility. And, but that might work where you're like, yeah, you know, because then it would fault then what it needs as it needs it. And then perhaps that fits in the Ram that you have available. Okay.
01:03:50
Speaker
Yeah, it's an interesting journey. Yeah, but you said that maybe last question because you said that Esperino is kind of a smaller set of JavaScript, right? That's a subset, yeah. That didn't pose any problems for any of the ClojureScript compilation mods then so far. The main thing that I ran into is the lack of support for labels.
01:04:18
Speaker
And for some odd reason, Google Closure Compiler emits labels in the code. And the reason I say it's odd is because when I look at them, you say, here's a label, and you go look at it, and the label seems to be unnecessary. It's just sitting there on a code block. So you can remove it, right? And it's really weird because that's the whole point of Closure Compilers, to make the code be as small as it can.
01:04:44
Speaker
So that was, to answer your question, that was one small problem. There's some other things surrounding like, I can't remember, like little things here and there. And what we do is, this is kind of painful, when you basically use the Esprit tooling to say, hey, make a ROM that I want to put on there. It basically does a pass over the code, and it modifies the code to remove labels and stuff like that.
01:05:09
Speaker
Oh, okay. And that's the painful part is that it's not using anything to parse the JavaScript. It's just kind of like regular expressions. Yeah, basically. And this is actually kind of a thing that David Nolan, one time I was talking about new things to add to the ClosureScript compiler. One of the things he has in mind is at the
01:05:30
Speaker
I don't know if it's the back end of the compiler, the part where the code comes out, that part that emits the code, that part is kind of vulgar in the sense that it just spits out strings. It spits out JavaScript. And you could say, well, we could probably be a little bit more sophisticated and spit out like an AST or something like that, some sort of representation that could then further be
01:05:52
Speaker
manipulated by tools. And if it did that, then this this discrete tool could say, oh, I'm going to go through and basically get rid of the labels programmatically more easily, things like that. So there are there are there are a few things. And I was surprised that like it actually like, as far as there could be things lurking in there that haven't been discovered yet, but
01:06:12
Speaker
When I set up a REPL and interact with it, everything works. I haven't been able to find some code that breaks it. Having said that, I just tried the latest version of the Closure Script Compiler that's not been released yet just to see if it would work and it broke. There's something that gets emitted with arrays in a weird way that's basically like you're talking about some feature of JavaScript that it doesn't understand. I think that's a fair point, given all the constraints and the amount of stuff that you're getting.
01:06:40
Speaker
you can have the complete closure core then, right? It's not just the first level function, but also Jackson, whatever the things that are implemented using map and reduce and then higher level ones as well. Yeah, basically all of your core. Yeah. And there's space to have even more like closure set and whatnot. So it's not like it's completely full. Like if you, and if you have, I have,
01:07:02
Speaker
I don't know if I've even tried this. Like if say you wanted to use like core async or something, you know, some library that's, you know, another library, um, you could bring those in as well. And, and they theoretically would work, you know, it's all, there's nothing it's, this is not like self-hosted where it's like, uh, maybe it'll work. Maybe it won't. This is normal closure script. And the only real constraint is whether or not you have enough RAM to hold all of it and whether or not Esperino's implementation of JavaScript can cope with whatever you do. Yeah. Yeah.
01:07:30
Speaker
Nice, super awesome. I think it's a completely different topic so far, I think, in the past four years. I think we never went into this direction with Closure, the lower direction towards the hardware and microcontroller levels so far. Yeah, yeah, it is novel. Even to me, still, it's very novel. Yeah, it's super exciting because, I mean, we always talk about, like, the web, you know, frameworks or, you know, whatever, Closure in the front end or JVM. And pretty much, you know, we are
01:07:59
Speaker
we are kind of stuck in the, you know, well, we don't care about memory, you know, we're already running Slack that is feeding 20 gigabytes RAM. So yeah. Yeah. Yeah. This is a new like engineering challenge. How would you get this stuff to run on there? And even if like, let's say it's soft. Let's say someday we come up with like a native version of a closure. Like that would be just beneficial for like command line tools and whatnot. And you know, anything or anything we might want to write, like even a server side program that's native could be
01:08:28
Speaker
I don't know if that's a good thing or not, but it would start off quickly, right? Like maybe like if you're trying to do like, um, what are they called? AWS lambdas. Yeah. Yeah. Yeah. Yeah. Yeah.
01:08:40
Speaker
Nice. This is super exciting. I think so people can order it from, what is it again? I don't, I'm not familiar with all this hardware websites. Oh, it's called Tindy. Yeah. Yeah. So Tindy is a place where like, if you make your own little project board or whatever, and you're like, ah, I just want to put it up there for people to buy. It's a marketplace for those kinds of things. It's like Etsy for electronics. Yeah, basically. Yeah.
01:09:05
Speaker
It was kind of cool because the Closure and Closure Script community took some interest in it at the time. This board went up near the top of that list on that marketplace. It's like, yeah, cool. It's like we're basically introducing other people.
01:09:23
Speaker
This is actually truthful. There were other people in the hardware community. There was a bit of crossover, where people in the hardware community are like, what? There's this language that runs on MCUs, and they take an interest in that kind of stuff. And they're like, well, it's Clojure and ClojureScript. So it's good for us. It gets the whole Clojure and ClojureScript name out there to a new crowd of people.
01:09:44
Speaker
Yeah, yeah, it opens up a new audience. Yeah. You've been on these embedded podcasts, haven't you, Mike? They're only run on ESP32s now. You have to buy them on ESP32 to listen to the podcast. That's what Matt is doing now. Yeah, I've got the secret handshake now to get into this place.
01:10:11
Speaker
So you can buy the ClojureScript podcast version of ESP thing. In all seriousness, you have been spreading the words to these YouTube channels and other players' stuff. You're about how it runs on these smaller controllers.
01:10:34
Speaker
Yeah. It's, it's kind of like, you know, there's, there's the closure community. There's also the hardware community and there's a small intersection between the two. It is super exciting. And, um, yeah, I think I, I, wow. Uh, we are almost pretty much reasonable size of the podcast already episode, but, um, this is super exciting stuff, Mike. I think, um, we'll, we'll put a link to.
01:11:04
Speaker
Tendi? Yeah. And you could go check that out. Go on Tendi and search for ClosureScript. And you don't even have to buy one of those. Just go get one off of Amazon and just get one and mess with it just for the wow factor. You know, it's novel. You're like, oh man, I have like this little tiny thing running ClosureScript.
01:11:21
Speaker
Yeah, I think it's enough of reframe work now, you know, just just go and run this on a small, small microcontroller and then get excited. I think that there is there is some sort of a visceral thing, right? I mean, when you write these, you know, okay, there's the same feeling that you get first time when you write JavaScript.
01:11:40
Speaker
to run in a browser to do something, you know, that's so exciting. And then now everything is layers and layers and layers, and then we get used to it. But I think every time I do anything with the small add-in board I have, and also on NXT thing,
01:11:54
Speaker
It's kind of magic to see, I can control the RPM of that small Lego motor with some C-code somewhere, which is super exciting to see the little movement stuff. The thing that this is... Yes. Yeah. It's just all about empowerment now. If you know that this thing exists, if you say, ah, I want to do my Lego next thingy with ClosureScript, you now know that you can.
01:12:18
Speaker
Yes. It's pretty much all packaged up for you and you can just go get it and get one of these little boards and hook it up to your system and just knowing that you can do that is good to know, right? Because who knows what kind of project you might be on next or some hobby thing you might try to do. You might want to build a cat feeder or something. Who knows? Exactly. Important things in life. Yes. Solving day-to-day problems properly with closure. Yeah.
01:12:45
Speaker
instead of building yet another web application, but super nice. It's super exciting, Mike, I think. Thanks a lot for explaining all the stuff right now. It's still pretty, you know, hardware. How do you call that?
01:13:02
Speaker
level stuff that I don't understand that much, but I'm pretty sure bringing closure script there is like an awesome stuff. So you can actually ripple into something, into the microcontroller, which is amazing. But I'm pretty sure I think this is supported by your company as well. Yeah, Vouche has supported me in making all this. Yeah, it's pretty much
01:13:27
Speaker
They're vouching for your CLJS boards. I think it's interesting with these boards, to some extent, in the whole IoT world, it's just the cost of the board is so low that you can't afford to buy them just for fun. You don't have to spend a thousand euros on these things. Yeah, the main ship if you were to buy. I think the Amazon boards that you can get are like on the round of US dollars,
01:13:55
Speaker
$15, 15 US dollars, somewhere around there. If you get the actual ESP32 chip and you like design, if you're into making your own boards and you want to solder one onto something, the chip itself is like three or four US dollars for one of those. And that's, you know, like if you were to actually just get the chip by itself, that's getting down to like a dollar or less. So if you ever want to make something that expensive,
01:14:21
Speaker
You know, you just use one of these things here and then write closed script on it.
01:14:26
Speaker
Yeah, exactly. Yeah, you know, I mean, I think if you go and buy Mike's chip, it's not going to break the bank. No. If nothing else, it's a nice little like souvenir in your bookshelf or something for the next. Hey, it is. It has rapidly these what else do you want? So for the next pandemic, you can have it in the background and impress your friends.
01:14:52
Speaker
Yes. On your Zoom call, certainly this is going to be something that you can show. Exactly. And then maybe hook it up to, I don't know, like a network REPL or something so everybody can collaboratively turn on the lights on. Share it on a TeamWorks thing. Nice. Okay. On that shiny REPL note, I think we reached the end of the episode number 69. And I think we're pretty much starting again with Mike. So, you know,
01:15:21
Speaker
It's super, super excited to have you back, Mike. Yeah, maybe another four or five years from now, I'll be back on again. Next time with, you know, complete logic script running, you know, natively on the, on the microcontroller. Who knows? No, it'll be like a quantum computer at that time. Exactly. Yeah. Quantum closure. Quantum closure. Nice. You heard it here first, folks.
01:15:50
Speaker
Or maybe if it is quantum closure, then it won't be forward in the time. We'll go backward in the time. We can just time jump to anything.

Humor, Resources, & Listener Engagement

01:15:58
Speaker
That's true. That's going to be crazy then. So it doesn't necessarily be the future. So it might be in the past. Who knows? So we'll open a time warp thingy like MCU. We come back to MCU to MCU, like microcontroller units to model cinematic universe.
01:16:18
Speaker
Back to square one. OK, so that's it from us for this episode. And yeah, so go and check out the stuff on Tendi. Search for ClosureScript, and then get your REPL on your microcontroller, the ESP. I don't know what ESP means. It sounds like extra sensory perception or something. I don't know. Yeah, I don't know what it means, either, actually. I think it's from the company, probably. So yeah, I think that's it from us, Mike. Thanks a lot. And yeah.
01:16:46
Speaker
So keep listening and then keep hacking. No, you can even hack hardware with ClojureScript. So what is stopping you? So have fun. Thank you for listening to this episode of DeafN and the awesome vegetarian music on the track is Melon Hamburger by Pizzeri. And the show's audio is mixed by Wouter Dullert. I'm pretty sure I butchered his name. Maybe you should insert your own name here, Dullert.
01:17:13
Speaker
If you'd like to support us, please do check out our Patreon page and you can show your appreciation to all the hard work or the lack of hard work that we're doing. And you can also catch up with either Ray with me for some unexplainable reason you want to interact with us, then do check us out on Slack, Closureion Slack or Closureverse or on Zulep or just at us at Deafened Podcast on Twitter.
01:17:42
Speaker
Enjoy your day and see you in the next episode.
01:18:09
Speaker
you