Elm Town 70 – Getting out of the basement with Jim Carlson

NOVEMBER 28TH, 2023
|
57:48
Jim Carlson shares his discoveries in software development through the people he's met in the community and the projects he's building. We also discuss how a history in mathematics shapes his work.

Details
/
Transcript

[00:00:00] Jim: Well, my wife had told me this, she said, Jim, if you really want to do this, you've got to get out of the basement.

[00:00:05] That was a metaphorical remark, and talk to people.

[00:00:09] Jared: Hey, folks. Welcome back to Elm Town. I'm your host, Jared M. Smith. We'll be visiting with Jim Carlson today.

[00:00:16] Sponsored By Logistically

[00:00:16] Jared: But first, let's talk about our sponsor, Logistically. At Logistically, we make intuitive software to help logistics teams make better decisions and improve efficiency. Logistically pays me to record Elm Town episodes, as well as pays for our production and hosting costs, we build the front end for all new features in Elm.

[00:00:37] If you're interested in our mission and enjoy writing Elm, please drop us a line elmtown at logisticallyinc dot com. I'll put a link in the show notes.

[00:00:45] Introducing Jim

[00:00:45] Jared: Now, Jim. Jim is a recovering academic with a history in Math. He loves typed functional languages, especially Elm. He's done some parser related work, making a LaTeX to HTML parser in Elm, which he presented at Elm Europe 2018. He also presented Tarring files with Elm at Oslo Elm Day 2019. He also has a couple of packages. Several, but a couple parser related ones, including jxxcarlson slash elm-markdown and jxxcarlson slash elm-l0-parser. He's done some simulations work, including the random exchange model, Schelling's segregation model, heat equation, as discussed in Making Elm Talk to Your Personal Computer at elm-conf 2019. There's some other fun stuff, including a fake drum language app. The culmination of a lot of this parser related work is, I see it, in Scripta dot io, where he has an editing and publishing platform for the web, which supports MicroLatex, Xmarkdown, and L0. He's also done some work on Elm Notebook, which we'll talk more about later.

[00:02:03] Jim, welcome to Elm Town.

[00:02:05] Jim: Oh, thanks, Jared. Really glad to be here.

[00:02:08] Jared: Yeah, I'm excited for this.

[00:02:10] History in Mathematics

[00:02:10] Jared: So, to get into it, one thing that I want to go back to is mention that you were on Elm Town one time before, and it was Elm Town 29, knode.io with Jim Carlson, and this was in 2018 Murphy Randle, correct?

[00:02:27] Jim: That's right, yes.

[00:02:28] Jared: Okay. Yeah, so you gave a little bit of your history, then, and so I'll refer folks back to that, but do you want to kind of give us your, uh, abridged version of that today and how you see it,

[00:02:41] Jim: Yeah, I can give the abridged version. So, you know, I, uh, I went to college in 1964, long time ago, and the summer of my second year I had a job in the physics department where I had to learn some quantum mechanics, some numerical analysis. and some Fortran to do a project for my professor. And in those days, uh, well, what I had to work on was an IBM 1620.

[00:03:09] And I had access to it from 10 p. m. at night until 6 a. m. behind locked doors. So, and the way I did my programming is I had to punch up my cards. Send it through the card reader, get the output in the line printer, and, you know, you talk about a, uh, a long development cycle. That was, that was it. So it's amazing that I actually learned how to do this.

[00:03:33] But I did, and it was a lot of fun. And then I'd sort of been in and out of programming most of my career, which was, uh, you know, I got a PhD in mathematics and, uh, I did mathematical research and taught and so forth and I would occasionally get really hyped up about some new language and maybe use it even a little with my research.

[00:03:54] But I never really started doing serious software development, I mean, such as it is, until I retired about ten years ago. And I think I made all the wrong moves. And I got really frustrated, but I eventually found Elm and that really opened things up for me. So that's, that's the brief history.

[00:04:15] Jared: All right. Yeah. And so one thing I want to mention is that we kind of teleported Jim here. Uh, due to some internet troubles, but I think we're, we're good now.

[00:04:27] Serious software development

[00:04:27] Jared: So yeah, Jim, you were saying that in your initial programming history, as you were learning, you had a rather laborious task of using punch cards to write code.

[00:04:40] And so I imagine with that, there was probably a very meticulous process of going through the code and thinking about it before actually running that to the computers. Is

[00:04:53] Jim: sure, yeah.

[00:04:56] Jared: as you then retired from mathematics and academia, and then went into doing more serious development work, as you called it, would you have carried over that meticulousness, or had you maybe started to use the more iterative process that we use

[00:05:15] Jim: Well, uh, I think I'm... My basic modus operandi is to just try stuff, and then if it succeeds, that's great. And if I fail several times in a row, then I have to start thinking. So that was, that was sort of my process.

[00:05:32] But what I did, you know, one of my early experiences, well, I started out with Ruby on Rails, and then got into various JavaScript frameworks, and um, What I found is that as long as a project was small, it didn't really matter what language I was using, everything was cool.

[00:05:49] But as it grew in size and complexity, then the problems began to surface. And I learned this new and wonderful term, refactoring. And, um, it, it was, for me it was basically a scary process. Because beyond a certain level of complexity, refactoring, or maybe even thinking about refactoring, could break the code.

[00:06:11] And it would be, and I may not know about it until later, but, uh, and that was an especially bad way to learn about things. And at one point I had moved to using Elixir on the back end, and, you know, I realized, okay, this is a functional language. And that was a big step up, and so I thought that, uh, you know, maybe I should look for a front end functional language.

[00:06:35] That's how I discovered Elm, just by internet searches.

[00:06:37] Getting out of the basement

[00:06:37] Jared: Alright, well, related to you and Elm I have a question from Mario Rogic. And he says, quote, I believe I met Jim at the first Elm Europe conference. I remember being really impressed that he'd had a little experience with Elm and decided to fly to Paris to attend a conference. Could be fun to hear about how he came to that conviction, end quote. So, Jim, what made you decide to go to a conference after learning a little bit of Elm?

[00:07:05] Jim: Well, my wife had told me this, she said, Jim, if you really want to do this, you've got to get out of the basement. That was a metaphorical remark, and talk to people. So, I went to, uh, Elm Europe 2017.

[00:07:19] That was my very first software conference. And, the talks were great. I, I met Evan, and I described to him what my problem was. I had been using... Some Ruby stuff, and I used a, there was a parser for, um, uh, that I had been using, and it was based on all RegExs. And as you know from computer science, there's a limit to what you can do with RegExs.

[00:07:44] So anyway, I talked to Evan about this, and he said, well, you know, maybe you should take a look at elm/parser. And when I got home, I did. And then I realized at some point, holy cow, I can actually write a LaTeX parser using this. And so that was for me a huge revelation and that really changed my life such as it was as a programmer.

[00:08:09] Jared: Okay. Yeah. Well, that definitely sounds like it was a... Big, uh, discovery, if you

[00:08:16] Jim: It was.

[00:08:18] I remember Mario was the second person that I talked to at this conference.

[00:08:23] Jim: I was quite nervous about the whole thing because I had heard about these horrible flame wars in the software world and how nasty people could be. But, I must say my experience... There and then, and after that has been just really fantastic, very, very welcoming. But, um, yeah, it was a great conference. I learned all kinds of things.

[00:08:43] I can't remember whether it was, uh, at that conference or the next one that I also heard about Elm UI. Uh, and I remember, actually, I had fallen asleep during Matt's talk. But I got sort of the gist, and then I saw a bunch of people clustering around him and Evan afterwards, and, uh, And I thought, oh, well, this is probably pretty good, so I also investigated that, and I've been using it ever since.

[00:09:10] Jared: Okay. Yeah, that's a, an important discovery as well, I'd say.

[00:09:15] Jim: I mean,

[00:09:15] Jared: Yeah,

[00:09:15] Jim: I also heard, you know, I think, at the first. one I heard Mario talk about, I may be getting the sequence wrong, but he talked in one conference about, uh, Evergreen, and then one after that about Lamdera. And that's also been a big step forward for me. I've, you know, for about three years now, I've been using Lamdera in almost all the apps that I do because the, uh, the lack of glue between the front end and the back end and being able to do everything in Elm and not having to manage database migrations.

[00:09:46] I mean, those things just used to make me very nervous. So it's, that's also a big step up for me.

[00:09:52] Jared: yeah. So I do want to talk about your use of Lamdera as well, but

[00:09:59] Problem-solving approaches

[00:09:59] Jared: to kind of step back and, and talk a little bit more about this, this kind of coming out of the basement and then having these discoveries, talking with Evan with Mario. One of the things that you had mentioned on the episode with Murphy Randle was a few things that you loved about Elm that I took away as being really important, and they're mentioned a lot today, but one of them, of course, is the fearless refactoring.

[00:10:30] Um, another was modeling the problem well, being able to do that with Elm. And then another one that you, I believe, took away, took from your math days was changing the approach to a problem. So with those, particularly this one about changing your approach, I know that, you know, you just sometimes have to try things, right?

[00:10:53] Is there, is there a, a pattern to how you go about that or do you just keep

[00:11:00] Jim: Well, I think it's similar to what I said, my usual approach is I just dive in and then when, when I'm faced with a lot of trouble, then I start thinking about things. Uh, it's maybe not the best approach, but it's just, I guess, it's part of my personality. So, and I've, this is where Elm really, really shines because, for example, in my work on the LaTeX HTML compiler, I call it a compiler because there are lots of stages, you know, there's a parsing stage, and then there's a rendering stage, and there are various other stages.

[00:11:33] But it, um, you know, I found that my original approach was not always the right one. And I had to change, you know, absolutely core data structures. Uh, and one of the great things about Elm is that you can do that. You just go in there and you rip up some stuff and you change some stuff and nothing works.

[00:11:52] And then an hour later, or maybe in a really bad case, a day later, it's all working. And you can be completely confident in it. It's not like worrying that there's some hidden defect that will surface. You know, two months later when a user complains about why stuff is not working right. Mm

[00:12:10] Jared: yeah. So, that for me was a, a huge win when I came to Elm after having worked in large code bases for my career, throughout my career, and kind of living with this growing anxiety, and particularly working in healthcare, it was very important to have that, confidence

[00:12:33] in, in what I was writing, so, yeah, I, I share that, and, and so, Yeah, you, you try things, you try things, and then when you get stuck, you then start thinking.

[00:12:45] I think that's a good approach, you know, because it allows you to get a sense of how things

[00:12:50] Jim: Yep. Yeah, I mean, another comment on that is that, you know, ideally you want to think about it, and, uh, you know, figure out the right way to go, and then just do that. The problem is, is that when you're looking at a really new problem, You don't really know what the right way is, so this, uh, diving in, getting frustrated in thinking is, I think, uh, inevitable because what you're really doing is trying to figure out what the problem is.

[00:13:16] It's a, it's both a research and a development problem. If it were only development, then maybe a more thoughtful approach from the beginning would work.

[00:13:26] Jared: Right, yeah, so, if the problem already has the specification laid out for you, then maybe it's more of a, an approach where you can say, okay, we'll plan this out, we'll break it all out and just go to town, but,

[00:13:39] Jim: Right, I, I don't have a boss to give me a specification, so...

[00:13:42] Jared: Yeah, yeah, well, I think that's, uh, that's probably best. I don't like, uh, getting too exacting of specifications and not have creativity in the approach, so. Yeah, okay, so, one thing I wanted to mention about Elm is you have a quote on elmlang. org. It is, quote, you just follow the compiler errors and come out the other end with a working app. End quote. So, I think, you know, of course, this goes back to that having the confidence and, and, and fearlessness, um, with, with coding.

[00:14:21] Jim: hmm.

[00:14:22] Jared: And so, you're able to do this and you're able to tackle some, what I would say are fairly complex problems, right? So you're writing multiple parsers and, and rendering, you know, so multiple steps here.

[00:14:35] And doing a lot of this. This work that then you can build upon.

[00:14:42] Jim: Right.

[00:14:43] Scripta.io

[00:14:43] Jared: So, with the parser related work, and I mentioned this earlier, the scripta. io is the, is what I understand is sort of the product that's come out

[00:14:55] of that work. Do you want to talk about that a little bit?

[00:14:57] Jim: Uh, sure. So, you know, that's sort of the, well, the current endpoint of a long chain of development, which began with what I called Mini Latex at the time. And, um, uh, one of the changes was I, I rewrote everything in Lamdera. And I basically, I had started it actually in the... Summer of the, of my son's gap year, which also was the COVID year, we, the family was in France.

[00:15:22] And I'm not a great beach person, so when my wife and son were on the beach, I would find a cafe and work. And I tried, I tried it out. Uh, I sort of got stuck with the rendering of the math formula. I was using Katak, and I was in touch with Mario, and he almost immediately gave me a solution to that, so.

[00:15:43] Long story short, the work went really, really well. And then at one point I decided that I should try to parse and render not just one language, but several. And I had done that before, but I decided to take a new approach here. Basically because, you know, I'm a solo developer and my resources of time and energy are limited.

[00:16:05] Um, and so, what I decided to do is that I would use a, a common AST for everything. For LaTeX, for a version of Markdown, and for an experimental language, which I called L0. It has more or less the same functionality as LaTeX, except the syntax is vaguely like, uh, like Lisp. You know, the, for example, if you want to make something bold, it's left bracket, B for bold, space, your text, close bracket.

[00:16:34] And I think of those as being functions, and you can nest them and compose them and blah, blah, blah. So, anyway, this, this was a major, uh, rewrite of what I had done before. But it's turned out to work really, really well. Uh, so the, you know, you have these three languages that anybody can work in. For a lot of people, just, uh, markdown with, with math, and maybe some easy way of having extensions to that is enough.

[00:17:01] You know, maybe a high school teacher, for example. Uh, for other people you need the full LaTeX thing. And, you know, another advantage of this approach is that, you know, since I control the parser and the renderers and all that, you can, you can render Markdown and L0 to standard LaTeX and then you can use that to print it because, uh, uh, standard LaTeX can be sent to a program that converts it to PDF.

[00:17:31] And so what I did for that was I wrote a little Haskell app. I'm sort of proud of this. It's only 300 lines long. I was originally thinking, oh, I'll just do this in Elixir, but, you know, again, my time is limited, so smaller is better. And so anyway, you push a button, it renders it to standard LaTeX, regardless of the input language, sends it to this little app.

[00:17:55] It's somewhere in the cloud. It, you know, chugs away at it and sends back a link to the rendered PDF file. So, um, anyway, that's sort of the main shtick of Scripta. And what I need to do is, you know, get out of the perfecting it phase, which seems to last forever with me, and start pushing it out into the real world a little bit better.

[00:18:24] I'm not so good at that, I'm afraid. Mm

[00:18:27] Jared: Well, I don't know. I mean, I think, um, you know, you've definitely shared a lot of the work on it, so think it's much appreciated.

[00:18:37] Jim: Yeah, thanks. Yeah. Mm

[00:18:39] Jared: for all the work that done on it and all the packages that have come out of it as well. Okay, so, yeah you mentioned the Lamdera discovery. And so is Script dot IO built on top of Lamdera these

[00:18:56] Jim: It is. It is. Yes.

[00:18:58] Jared: You have a quote on the Lamdera website as well, it is, Quote, Lamdera provides a warp speed, high productivity, and pure joy environment for developing web apps that just work.

[00:19:11] End quote. Ha ha

[00:19:13] Jim: I definitely stand behind that. I guess I'm getting better at marketing speak. But, uh, yeah, I think those words represent my My actual experience with Lamdera.

[00:19:25] Learning Haskell

[00:19:25] Jim: By the way, one little note back to when I met Mario. You know, we talked about this and that, and he, he talked, he said, Well, you know, as a mathematician, you will, you will certainly learn Haskell.

[00:19:39] And, uh, it took me a while. I actually, I can't say I have learned it. Maybe that's an impossible task, because it's such a big, big language. But, indeed, I have dipped my toe into Haskell. And, uh, you know, trying to learn more of it as time passes.

[00:19:52] Jared: Sure. And actually, that brings up a question, because, yeah, as Mario noted, I think that makes a lot of sense, and a lot of folks, I believe, who come from that realm, who have an understanding of the mathematics behind it and the language there, love Haskell, from what I gather, and, and then folks who come from A more, industry background, maybe, let's say, not related to that, uh, prefer Elm.

[00:20:29] So, but you still use a lot of Elm, so what, how, how do you match those? How does that match up in your

[00:20:37] Jim: Right. Well, I mostly use Elm, that's for sure, and I'm pretty proficient in it, so I can move a lot faster in Elm than I can in Haskell. Actually, I've been using ChatGPT to help me with Haskell, so I'm cheating a bit, but, uh,

[00:20:51] Yeah, so, you know, I love the ideas behind Haskell, actually behind functional programming in general.

[00:21:00] I think Evan made some really, really good decisions about nomenclature and, um, and the way he presents the language, because, uh, you know, Haskell can be fairly tricky, and I think the way Evan designed, um... Elm, it makes it accessible, you know, it makes a type functional language accessible to a much, much wider audience.

[00:21:24] And I think it's also a matter of, um, you know, what is it that you're trying to accomplish and what, uh, audience are you really addressing? So, you know, one thing I discovered is, uh, well yes, Elm actually does have monads, uh, we just don't commonly use that word. And, uh, You know, Evan has a way of describing things as, you know, uh, a monad has and then.

[00:21:51] I think that's the way he, he puts it. So, uh, in other words, it's sort of an operational definition of what a monad is. Now, I don't mind using the word monad. That, that doesn't scare me. And in fact, I kind of like it in that I, I'm interested in the history of ideas. And, um, as far as I understand it, monad was first used, uh, by some mathematicians, uh, in the context of the theory of sheaves, whatever that happens to be.

[00:22:20] And then, uh, there was a computer scientist by the name of Eugenio Moggi, who, um, sort of made the connection between monads and computer science. And then I believe it was, um, Phil, Philip Wadler, who really used these to make Haskell. Do various wondrous things. So, you know, I'm kind of interested in that history and, you know, how do you trace that history?

[00:22:46] Well, one of the ways is you trace the usage of a certain term. So, but, uh, and, you know, there's a, just a side comment. I've looked at various explanations of monads on the web, and there are many terrible explanations. Uh, what my understanding of it is this, I got this from, uh, let's see, who's the fellow who...

[00:23:08] He's done a lot of podcasting and web blogging on, on functional programming. Um, his name, he's very popular, but the name escapes me right now. But anyway, what I learned from some of his stuff is that it's all just about composition. Monads are a way of making things compose when they aren't really set up to do that.

[00:23:30] Because, you know, the domain and the range don't match. So, anyway, too much of a digression there.

[00:23:36] Jared: ha. No, that's good, that's good. And I think to your comment about... Looking at the history of things and using etymology, you know, the, the, where words come

[00:23:46] Jim: Yeah,

[00:23:47] Jared: to do that,

[00:23:47] I think is a, a great, uh, a great way to find out more and to understand, yeah, that with Elm, we don't have to think about that,

[00:23:56] Jim: That's right. That's

[00:23:57] Jared: uh, I've been working with Elm for a long time and I, yeah, I have enough of an understanding to, to be able to say that when I see and then that, yes, monad,

[00:24:06] but, you know,

[00:24:07] Jim: but, you know,

[00:24:08] Jared: that's all I need.

[00:24:09] Jim: that's exactly right. Yeah, that's exactly right. Mm

[00:24:12] Jared: so, to be

[00:24:14] able to know how we got to that point is an interesting

[00:24:18] Jim: hmm.

[00:24:18] Jared: to discover. So, yeah, I think that's great to hear about.

[00:24:25] And so, yeah, alright, so you did dip your toes into Haskell a little bit. Elm is really productive. And you've built scripta. io. Uh, you're building things on Lamdera.

[00:24:40] Elm Notebook

[00:24:40] Jared: Some of the other things that you've built include a book lib app And, and then more recently this Elm Notebook.

[00:24:50] Jim: Right.

[00:24:51] Jared: So do you want to talk about any of those things?

[00:24:54] Jim: Yeah, so, actually, BookLib was a, that's kind of an old project, which I need to get back to and, and improve it. It's mostly used by my son and me to keep lists of the books we're reading and, you know, make notes about them. And, uh, he's become an even more avid reader than I am. I mean, his room and the hallway leading to his room are lined with books.

[00:25:15] Um, but, um, uh, Yeah, so, let's see, what was the other app that you mentioned besides BookLib?

[00:25:23] Jared: Elm Notebook.

[00:25:24] Jim: Oh yeah, so that's a very, that's a very recent project. It actually began when I was at Lambda Days in Krakow this summer. And a friend of mine recommended that I go to this talk by José Valim about, uh, Elm Livebook, and watching the talk, I thought, Oh my gosh, this is great.

[00:25:47] We should have something like this for Elm. And I especially, you know, the idea is to have some kind of like Jupyter notebooks, but which executes Elm code in its cells. And I think that, uh, among other things, that would be great for teaching. It would be, you know, you could actually run a computer science course.

[00:26:04] Where you have a notebook that has various explanations and examples of code and then problems where people run code in the notebook. And so that's actually getting very close to being done now. And, uh, after the talk I went up to and asked José, you know, if that would be possible. And he said, well, yes, but you would have to, uh, compile Elm to Erlang.

[00:26:26] So I thought, okay, well, I'll, and he gave me a few tips about that. So I said, okay, well, I'll hack the Elm compiler and make it do that. But, which was a totally crazy idea. And, um, after a couple of weeks of not doing anything, I realized there must be a pure Elm way of doing this. So I, um, I asked Martin Janicek whether his Elm in Elm compiler would do the job.

[00:26:48] And he said, no, you've got to use Minibill's, uh, Elm Interpreter. And, uh, so I did that. Actually, it was very quick. In a couple of days, I had a proof of concept working. But, you know, one of the things that is necessary if this is going to be useful to people, especially for people who are beginning, is that you've got to have good error messages.

[00:27:09] And I had some sort of half assed error messages, but, you know, what you really need is the Elm compiler's messages. So, um, I started thinking about that, and I talked to Evan about it at Elm Camp this summer. And he gave me a few tips. As usual, you know, he says very few words, but they have high information content.

[00:27:31] And he wrote down in my little notebook a couple of lines about places to look at in the Elm Compiler. So... When I got back, after I sort of freed up some time, I started working on that. And that work has gone really, really well. I've got a fairly good version of a Lamdera app that talks to the Elm compiler.

[00:27:51] And, uh, you know, I ship code to the Elm compiler. It replies with either an error message, which I had to kind of reverse engineer so as to properly decode and display, or with the result. So, you know, I hope that in a few weeks... I'll have something I can show to people.

[00:28:10] Jared: Oh, okay. Well, that's exciting. Yeah, what you already have up on the site is already really interesting. And yeah, of course, having nice compiler errors is important for us. But, but what, what you have is really interesting because for example, you bring in charts and you can create charts and, and immediately see those results in there.

[00:28:37] Yeah. And type your code, and so yeah, that's

[00:28:40] Jim: Yes, I eventually want to have that functionality in this app as well. I mean, this goes again to something that, uh, Evan has talked about, which is having, uh, uh, you know, Ways of doing data visualization, working with data, uh, so I'm kind of exploring that. I mean, I, uh, yeah, so that's an eventual goal.

[00:29:00] But I want to get the, the REPL part of it working first. And I should say Mario has been a great help to me on this because, uh, you know, just knowing the code, the code base for the Elm compiler is rather large. Also, it's in Haskell, which is not my native language. So just knowing where to look. Is key.

[00:29:20] So, Evan's little notes to me, plus Mario's little tips, have been invaluable. I mean, I would not be where I am now without those.

[00:29:29] Jared: Yeah, yeah, that sounds really great then. And again, this is, you know, getting out of the basement, going and discovering these things by talking to people. You seem to have done a great job of that. You mentioned going to Elm Camp, and, and then the more recently, I didn't get to catch up with you, but I know you were at Strange Loop as

[00:29:51] Jim: Right. Right. Lots of people to talk to there.

[00:29:54] Jared: Yeah, yeah. Um, did you find any discoveries there?

[00:29:57] Jim: Actually, I had a really good talk with, well I talked with Evan some more about Elm Notebook and that was very, very helpful. And I talked to Ryan, he actually sat down with me one day after the talks and sort of worked up a prototype of what an Elm Notebook might be in Elm Land. That's his product, right?

[00:30:24] And, uh, Actually, I learned something from him which I haven't yet used but I will have to use to extend the functionality of Elm Notebook, and that is that you know, instead of just instead of always working in the REPL what I really need to do is to ship out to the Elm compiler code for a little mini Elm application.

[00:30:49] And, uh, Ryan did a few things that sort of gave me some tips on that. So, you know, I'm gathering all the information that I get from other people, like, you know, Ryan, uh, Mario, Evan. Eventually, I'll, I'll get there.

[00:31:02] Jared: Yeah, yeah, that does sound like an important discovery there. So, yeah, so you had this, this idea that sort of came from going to Lambda Days. Seeing what the Elixir Livebook could do, and also, I believe you mentioned Jupyter Notebooks as

[00:31:21] Jim: Right.

[00:31:22] Jared: um, yeah, as, as some of inspiration for

[00:31:26] Jim: Yes. Yes, indeed.

[00:31:28] Jared: Okay. Yeah, well, I'm, I'm excited to see what comes out of it, and yeah, I think it will be a really nice contribution to the community and be really useful, so, yeah, thank you for your work on that.

[00:31:41] Jim: Yeah, it's been fun. Yeah.

[00:31:42] Jared: Yeah, it looks fun. It is fun to play with.

[00:31:45] Jim: It is. It is. Yeah.

[00:31:46] Jared: what's already out there. So, yeah. All right. Um,

[00:31:50] Simulations

[00:31:50] Jared: and so we've talked a lot about kind of the parser related work, what you've been doing now with Lamdera and Elm Notebook. We haven't talked a whole lot about the simulations. Did you want to talk about those a little bit?

[00:32:03] Jim: Yeah, let me say a few words about that. So, you know, I used to do this kind of stuff in my prior life as an academic. Actually, I should say, you know, once a mathematician, always a mathematician. It, uh, it's, uh, it's part of your being, it's not a lifestyle choice. Uh, and it's not something you do for a while and then you just stop because it's, and it also helps in understanding lots of other stuff.

[00:32:26] But anyway, um, you know, like a typical thing that I've, I've done in almost every language that I've had contact with is to simulate gambler's ruin. So, that's an easy one that, you know, involves stuff with random numbers and whatnot. But then I've done other things that are sort of more interesting. So, one of them is there's this Schelling segregation model.

[00:32:48] All these, by the way, are on my github. io page. So, it's jxxcarlson. github. io and there's a list of these things there. So, that's kind of an interesting thing. It presents itself as a grid. And, uh, Schelling was a sociologist, and, uh, What he found was that even very, very slight preferences of, you know, whom you wish to associate with will almost always result in a quite strong segregated housing pattern.

[00:33:20] So, you know, if you combine that with real measures that encourage segregation, uh, you're, you definitely have it big time. But even slight things can, can cause that to occur. And it's a little bit like, um, The phenomenon of crystallization in physics, uh, very, very slightly. So another one that I did, and again, this is something I've done in practically every language that I've looked at is, uh, to simulate heat flow.

[00:33:47] And, uh, this can also be done on a grid. I mean, the basic idea is that, you know, if you, if this temperature is, you look at the cell and its temperature will tend to evolve towards the average temperature of nearby cells. So if it's hotter than average, it will become colder. If it's colder than average, it will become hotter.

[00:34:06] And, you know, in, uh, physicists think of this in terms of partial differential equations, but when you discretize them, you have what I just said. Um... And, uh, you know, more recently I've been fiddling around with this, uh, random exchange model, which is a, uh, a physicist's way of understanding how inequality of wealth and income can arise.

[00:34:30] And it's similar to Schelling's model in the sense that, um, well, it's even more extreme. In the random exchange model, you can think of it as a game. So, you have, say, 200 players. They all start out with, uh, say, 10 bucks. And at every tick of the clock, maybe every second or maybe every minute, two players are chosen at random and the first player gives one dollar to the second player.

[00:34:57] Now, I put gives in quotes because maybe the second player provides a service or some goods to the first player, but we're only keeping track of the money here, okay? So everybody starts with the same amount of money. Everybody is subject to the same rules. So it's totally egalitarian, but the outcome is not egalitarian.

[00:35:20] What will happen after, you know, a relatively short period of time is that you will evolve towards a state where if you divide it into quintiles, the top quintile will have most of the money and the bottom quintile will be very, very poor. So I call them plutocrats and, and, uh, and peons. And, um, so, uh, What's interesting is this is very much like, this distribution of income follows what statisticians would call the exponential distribution, or what physicists would call the Boltzmann Gibb distribution, which is used in describing the distribution of energy states in a gas, say.

[00:36:03] And, um, so I fiddled around with that for a while, made a little Elm app that simulates that. And, you know, it has disks that get fatter. as they accumulate more wealth and they shrink as the wealth declines. And then I said, well, you know, what happens if we impose universal basic income? So now we're going to change the rules and say every thousand moves, uh, the government is going to collect a tax.

[00:36:28] It's a fixed proportion of everybody's current Stock of money. So if you have one buck, it might be 1 cent, and if you have 10 bucks, it would be 10 cents, something like that. And then the total tax revenue collected at that stage is divided evenly and distributed to everybody, whether you, uh, a plutocrat or a peasant.

[00:36:49] Okay. And, uh. Well, the, the outcome is dramatically different. I mean, the distribution is no longer a Boltzmann distribution. And moreover, if you track the Gini index, which is an index of inequality, you'll find that especially the lower classes are much, much better off. I mean, they're still poor. But they, they are not destitute as they were in the sort of pure free market model.

[00:37:15] So, you know, this, these kinds of models are, are controversial among... Economists, uh, some physicists quite like them and, well I have, I have an affinity for physics so I sort of like it myself too. So yeah, so those are the models and they're really fun to play around with and, you know, one thing that I want to go back to which is, um, when I did this heat equation business I was, you know, of course you want the models to run as fast as they possibly can.

[00:37:42] So, uh, there's this amazing language called Futhark. Uh, if you go to, if you search Futhark Lang, Futhark by the way is, it's not a Klingon word, it's a real word. Uh, it's a, I think maybe an Icelandic word or a Danish word. Anyway, it's F U T H A R K. So it's a typed functional language.

[00:38:06] And the, um, The creator of this language, uh, says, well, I'm not really a language developer, I'm a compiler, uh, writer. And the amazing thing about this is that, um, because the language is a typed functional language, the compiler has enough information to perform extremely good optimizations so that the code can run very fast on a GPU.

[00:38:30] And, uh, I don't know about this because I've never done it myself, but, uh, it is said that writing... GPU code or especially good GPU co, GPU code is very, very difficult. And, uh, the, um, the advantage of Futhark is that it, uh, you know, normal human beings can write Futhark code and then because the compiler is, has such good optimization properties, the code one runs really fast.

[00:38:58] And I fiddled around, I wrote some code in Futhark. I. Unfortunately, I haven't had much of a chance to pursue that of late, but, uh, Anyway, to, to summarize, you know, what I would like to do with some of these models, like with wealth inequality, is to, um, have some kind of a back end that does the computations very fast, and then communicates that very fast to the front end, which will naturally be written in Elm.

[00:39:21] So that's kind of a dashboard for talking to these simulations.

[00:39:27] Jared: Yeah, and so this is what, Futhark is what you talked about in the elm-conf 2019

[00:39:33] Jim: yes.

[00:39:34] Jared: Yeah, making Elm talk to your personal supercomputer.

[00:39:37] Jim: Righto.

[00:39:38] Jared: Yeah, and what's interesting is just yesterday, before we are recording this, we are recording this on Friday the

[00:39:46] 13th.

[00:39:46] Jim: Uh oh.

[00:39:47] Jared: by the way, yeah. But, um, anyway, yesterday there was this episode of Software Unscripted with Richard Feldman, where, uh, the creator of Futhark, um, is talking on there.

[00:40:04] I haven't had a

[00:40:04] chance

[00:40:04] Jim: Oh, wonderful.

[00:40:05] wonderful.

[00:40:06] Jared: but yeah, but I'm, uh, I'm excited for that and I think it kind of ties into, of course, what we're talking about now, so. Yeah, that could be something interesting to, uh, to look at.

[00:40:17] Jim: Yeah, I, I'll, I will listen to that. He, he's a great guy. Um, I actually met him finally, uh, uh, when I was in Denmark a couple of years ago. And, um, he's at the University of Copenhagen there. And, um. He has a couple of videos up about Futhark, and he describes things in a typically Danish way, which means extremely understated.

[00:40:43] And so he gives these amazing performance figures, and he says, yeah, pretty good. Yeah, but actually it's really, really good.

[00:40:53] Jared: We've talked about a lot of the simulations that you've done, and, and how you've been able to make Elm talk with other languages, and...

[00:41:05] Fake drum language app

[00:41:05] Jared: There's some other fun stuff, um, the, uh, the fake drum language app. Did you want to mention that?

[00:41:10] Jim: Yeah, absolutely. So that's, um. I was inspired to do this by a little passage that I read in James Gleick's book, The Information. And he describes this amazing thing, which I'll say only briefly. A few words about it, because it's linked to in the app, there's this drum app, this drum language in parts of Africa, I think there are many such drum languages, and the people who speak the native language are able to communicate over quite long distances by drumming, and there was an American missionary who was there who figured out how they did this, I mean, obviously they knew how it worked, but uh, The way it works is as follows.

[00:41:53] These languages are usually tonal languages. So they have long vowels and short vowels. And so the, uh, the drums, the drum language involves just two tones. Let's say a low one and a high one, corresponding to long tones, or long vowels and short vowels. So what they do when they drum, they just drum the pattern of vowels.

[00:42:17] Long, short, short, long, long, long, short. Like that. And of course, the people who do this are highly trained. Both the, I mean, the people who do the drumming and the people who receive the messages are, they have the same training. And, um, So, what I decided to do is to make sort of a fake drum app, and you put in a piece of English text or some kind of text, and it will convert that to, uh, it analyzes it into phonemes, and then it maps the phonemes to pitches, and maybe, uh, maybe links of notes, and then it synthesizes this and plays it, and to make it more fun, I have it do this with two voices.

[00:42:59] So if you go to the app, it has two little pieces of text in there, and you can press run. By the way, as far as I know, it only works on Chrome, so that's an important thing. And it's quite fun to listen to, and you can change the text yourself to experiment with it. So, yeah, it's another thing that I would like to get back to at some point, and among other things, make it work on things other than just Chrome.

[00:43:21] Jared: That was a fun one. I did play around with that as well.

[00:43:24] Jim: Did you like the music that it produced?

[00:43:26] Jared: yeah, Yeah.

[00:43:27] I liked what it, what it made. It was, uh, it was a lot of, a lot of fun to just, yeah, type basically randomness and, and see what would come out of it.

[00:43:36] Jim: The interaction between the rhythms in the two parts is quite fun.

[00:43:41] Jared: Yeah, and when you talked about this original drum language, it made me think with this short and the long, it made me think of Morse code.

[00:43:49] Jim: Yes, yes.

[00:43:51] Jared: Um, do you know if those, uh, work in similar ways, or?

[00:43:54] Jim: Um, well, you know, Morse code is longs and shorts. And what I don't know, I think my sister... I don't know if you've had an opinion on this, but, uh, you know, is Morse code really related to these drum languages, uh, you know, from the point of view of evolution? Was it inspired by that? I don't know the answer to that, uh, but it's, uh, they are very similar in that.

[00:44:18] Well, I guess what's different is that, um, Morse code is not an, I mean, English doesn't have long and short vowels. So it's, uh, I guess it's different. It's different, but it, it, it's the same in the sense that the output of the language is longs and shorts, but the passage from text to Morse code is not based on vowel lengths or, uh, some acoustic quality of the spoken word.

[00:44:47] Jared: Mm, yeah, yeah, that's a good point. Okay, well, that's really interesting though, and so I'll put a link to that app in the show notes as well as all the things that we've been talking about. Um, and so, yeah, you've, you've made a lot of really cool things. Is there anything else that, uh, you wanted to talk about before we get to picks?

[00:45:09] Jim: I, I can't really think of anything else. I just, I hope to discover... Uh, other ideas to, uh, to do fun stuff with, uh, I mean, the, uh, you know, like the idea of Elm Notebook, it's not something I'd been working on a long time, uh, just, uh, I was inspired to do it by a random event, at Lambda Days, and, you know, so I hope to put myself in situations where more random events can occur, uh,

[00:45:34] Jared: Yeah, I like that. Well, actually, this reminds me, I do have a question for you before we get to picks.

[00:45:40] Inspiration for work

[00:45:40] Jared: Is there an underlying thread or motivation for your work? You've done work with parsing and simulations, teaching science, art, music, even AI, we didn't even talk about

[00:45:53] that app, and these fun things like the, uh, the drum language app. And so, yeah, is there some type of

[00:46:02] Jim: Well, um, I think, I think again it's sort of a personality related thing. I mean I, a lot of my friends think of me as an extremely disciplined person because I can sit and work for hours and hours and hours. Uh, you know, that's a typical behavior pattern of mathematicians. But, um, the fact is, is that I'm driven much less by discipline than by enthusiasm.

[00:46:29] So, if I... Uh, you know, if something inspires me, I'll dive in and spend a lot of work on it. Of course, one of the things I've worked at a lot are things that are related to my prior professional life. You know, uh, tools that will make it easier to do certain things like, you know, put up class notes that involve mathematics.

[00:46:50] So, Scripta is very well adapted to that, say in math or physics. So there's, there's that sort of sub theme, but the real theme is just, um, you know, an idea comes and you go for it.

[00:47:04] Jared: Yeah. So, what is inspiring you today?

[00:47:09] Jim: Well, um, my latest obsession, uh, besides Elm Notebook is, um, is wealth inequality, wealth and income inequality, which I think is a, one of the larger problems that, you know, both the U. S. and the world faces. Uh, and it'll face it even more as AI. It becomes more and more powerful of an influence in the economy.

[00:47:35] And, you know, I don't think I personally can do anything about it, but I want to understand it better. Um, I've been interested in this ever since I read this, this book, um, called The Price of Inequality. Um, which, um, you know, it, it lays out the, you know, one, one view of inequality is that a fairly substantial amount of inequality is needed.

[00:47:58] in order to motivate people to create things. But, uh, uh, the point of this book is that, uh, too great of a degree of inequality actually is a drag on the economy because it results in misallocation of resources. You know, instead of roads and schools, for example, it goes into yachts and, uh, second, third, fourth, and fifth homes.

[00:48:20] Uh, so I don't want to get too much into the politics of things, but it's a, you know, it's a problem that is deserving of study. Yes.

[00:48:30] Jared: Yeah, I agree. I think that's really interesting. And I like that, you know, kind of as we're talking about the thread and motivation for your work, you know, when I think about mathematics, I think about, you know, there's this area that's looking at how to make logic and then make things To understand things and equality between things.

[00:48:54] And then there's this part of mathematics that's applying that, right? Creating simulations and trying to understand the unknown and, and to, and to get that of an understanding. Um, and yeah, I think that that's really important because, you know, when you come out of the basement with that knowledge, right?

[00:49:12] Then you can, you can share that with folks and, um, and, and that discovery can then lead to whatever, changes

[00:49:22] Jim: Right. Right.

[00:49:23] Jared: may want to make. So, based on that understanding. Yeah, I think it's important. Very well, very well put.

[00:49:30] Picks

[00:49:30] Jared: Okay. Well, Jim, what picks do you have for us today?

[00:49:34] Jim: Well, let's see, I have two. Let me, let me do the first, the second pick first, which is, uh, both of these are, sorry for all the paper noise there, uh, both of these are, are books that have influenced me a lot. So one of them is the, uh, uh, The Structure and Interpretation of Programming Languages. So I read that many, many years ago, but, um, you know, for example, it gave me some, Basic understanding of parsers, for example, and it sort of infiltrated my mental DNA and has been very, very useful ever since then.

[00:50:07] And also I think just the general philosophy of program construction. So I highly recommend that. And I think when the book was written, it was the target language was Scheme. And these days one can use Racket, either with Scheme as the chosen language in Racket or just Racket itself. So that's one pick.

[00:50:29] I think you can learn a lot from that book. And the other pick is, um, The Mythical Man. The Mythical Man Month by Fred Brooks. So, uh, a friend of mine recommended this to me many, many years ago, long before I discovered Elm. And I want to read a little quote from the book. By the way, if you don't read the book, read the Wikipedia article, because it sort of encapsulates many of the important points of the book.

[00:50:59] So here's the little quote I would like to read. To make a user friendly system, the system must have conceptual integrity, which can only be achieved by separating architecture from implementation. A single chief architect, or a small number of architects, acting on the user's behalf, decide what goes in the system and what stays out.

[00:51:22] And the quote continues, but I think those two sentences, uh, very much describe... Elm, and also Evan's philosophy in creating Elm, and, um, you know, there, there are different ways that projects can be organized, but, uh, Evan has a, a different, a philosophy that is different from that of many language architects and many developers in general.

[00:51:49] It's not one of putting releases out every, Every week or every month or even every year. It's a very deliberate process and I think that, um, Well, I respect it because I look at the results and the results are fantastic.

[00:52:06] Jared: Yeah. Agreed. Definitely. Yeah, and when I think about this, this quote that you have here about conceptual integrity, it makes me think of auteurs.

[00:52:20] So this, you know, the, the, the idea that there's this one person, you know, in, in Elm, we may call Evan the BDFL, but, you know, in, in movies, they're called the auteur. And so, you know, you think about Werner Herzog,

[00:52:35] or more recently,

[00:52:38] Quentin Tarantino, um, you know, these folks who have a particular vision and, In order to get that vision out, it needs to kind of follow that particular person's view and, and, and, and way of thinking of the world.

[00:52:52] And so, yeah, I, I agree. And, um, I think that, yeah, you look at the results. That, that's, that's what's important from it, right, is, is, is looking at what we, we have from it. And, I mean, that's definitely the motivation for me to, to be here today, to

[00:53:08] Jim: hmm.

[00:53:09] Jared: talking about Elm. Because... Well, I use it for work and I enjoy using it.

[00:53:14] So,

[00:53:14] Jim: Right, same here, although in my case work is, uh, just playing around with stuff. I'm privileged in that I'm retired and I can work on whatever I want to.

[00:53:24] Jared: yeah, yeah. And so, but since you can do that, you can choose whatever language, right? So, and, and the fact that you, you choose Elm, I think, you know,

[00:53:32] Jim: hmm. I

[00:53:33] Jared: uh, is a big win, um, for the community. And, and of course, um, if it, if you enjoy it, then that's, that's wonderful. Excellent, excellent. Um, did you have any other picks for us?

[00:53:46] Jim: I think that's it. I don't want to drone on too much. You know, I'm reminded of Ezra Pound's description of what a professor is. A professor is someone who can talk for 50 minutes. it doesn't necessarily mean that you're talking for 50 minutes, you know, full of great content, but you're just talking for 50 minutes.

[00:54:07] Jared: right... All right, well, um, I have a few picks, and the list kept growing as we got closer to this. We had to reschedule, and so, unfortunately, my pick list got pretty long.

[00:54:21] But I feel like it's been short recently, so I'm going to allow it for

[00:54:26] Jim: Good, good.

[00:54:27] Jared: if you don't mind. So the first thing is Evan's talk from Strange Loop. 2023, this year, was just released. It's called The Economics of Programming Languages. Beautiful talk. It really makes you think if our conversation about, you know, income inequality doesn't make you think, then I think looking at programming languages and, and how it, uh, relates to real estate, uh, can be a pretty interesting thing that you might get out of this.

[00:55:02] So, um, that's all I'll say about that, but, uh, if that sounds interesting, you might want to check it out.

[00:55:09] Um, and then, uh, two books. One is, and this relates to talking about the history of things, it's called In the, In Pursuit of the Unknown by Ian Stewart, and it takes 17 math equations that change the world and talks about them and their place in history and how they, uh, have changed things.

[00:55:34] So, um, that one was, was really fun. I mean, I can't say I've read all of it, but I've read almost half of it. If you, if you can, if you're watching the video, I'm holding up my little, uh, bookmark there. Um, and then the other one is Things to Make and Do in the Fourth Dimension

[00:55:51] Jim: Hmm.

[00:55:52] Jared: by Matt Parker. And this one is also about, uh, mathematics.

[00:55:58] It's the sub... Title is A Mathematician's Journey Through Narcissistic Numbers, Optimal Dating Algorithms, At Least Two Kinds of Infinity, and More. Um, but, one of the things that I did out of this was I made this little, uh, tetraflexagon, which is this little thing that you cut out, and then you fold this paper together in a particular way, and then when you open it up... You can fold it open and get different numbers depending on how you fold it.

[00:56:31] Jim: Beautiful.

[00:56:31] Jared: so, yeah, it's a lot of fun to play around with some of the different things that, um, that this book will give you. And then, um, it's very approachable, I think, from somebody without a degree in mathematics. So, um, Yeah, if you, if that sounds interesting, check that out.

[00:56:50] And the last one, because my source for this book was a YouTube channel called Vsauce, uh, hosted by Michael Stevens, and of the things that, uh, that, that he, a lot of the things, actually, I think that, that are in this book, then Michael Stevens will, uh, present videos on. So I think they kind of go hand in hand, so I thought I would, um...

[00:57:14] Share that one as well. And I'll put links to all of these things. Um, and yeah, including the, the ones that you have, all the different projects you've been working on, Jim. Um, so yeah, I appreciate you taking the time. Thanks to all the folks listening out there. Please rate and share if you're enjoying the show and thanks, Jim, for coming to Elm Town.

[00:57:35] Jim: Great chatting with you, Jared.

© 2024 Jared M. Smith