Too simple for simply firmly ways. Even like just learning programming language. Word is my first programming language. I think the tutorials well laid out for the newcomers.
ConorWelcome to ADSP the Podcast, episode 159, recorded on November 13th, 2023. My name is Connor, and today with my co-host Brights, we conclude our conversation with Richard Feldman about the ROC programming language.
Richard FeldmanInteresting. I don't actually know if that downside does apply in rock. So let me describe the other thing which is the big idea of ROC, and we'll see if it does or does not. Well, so first of all, I actually am not sure to what extent people would want to use rock for GPUs. Anyway, but setting that aside, um so the big idea of the language is what we call platforms and applications. And the basic idea is that every rock program has exactly one platform and exactly one application. So if I'm going to build an application, like what we traditionally think of as a program, um could be a library also, I suppose. Uh but basically I'm going to pick a platform to build that application on. So let's say, for example, I'm building a command line application. I would probably choose a platform like we have one called Basic CLI, which is just a platform for building command line applications. Or let's say I want to build a web server, that's my application. I would pick a platform that's designed for building web servers, um, like we have one called Basic Web Server. Let's say that I want to build a native GUI desktop application. Again, pick a platform that's sort of good at that. So, in some sense, a platform from an application author's perspective feels like picking kind of like a framework. It's like just a starting point. It's like this is something domain-specific. It's like this is gonna give me the tools that I need to build whatever thing I'm gonna build. Um what's different between rock platforms and your traditional framework is what is in scope for them. So traditionally, in most languages, C included, in your standard library, you have a bunch of I/O operations as well as data structures and math and stuff like that. And then if you're using a framework for something, it's kind of like as a nice to have on top of standard library stuff. It gives you sort of like more that's like maybe domain specific. Uh and also your memory management stuff and like C is all gonna be kind of separate. You can do that however you want. Now, in ROC, what's in scope for a platform is yeah, it's all the domain-specific stuff. So like a web server is gonna have a way to do like HTTP, it's gonna have a way to do, you know, handle uh requests and turn them into responses. But also the platform is responsible for providing all of your I.O. primitives. So the ROC standard library doesn't have any I.O. in it at all, it doesn't even know how to do it. It's just like it's just 100% data structures. Um so all that comes from your platform. Separately, the platform is also responsible for memory management. So uh if I were to write a platform like for I'll give the use of the example of web server, um the basic web server platform, so rock does automatic reference counting, that's kind of the default memory management um system. But the platform is actually comprised of two pieces. One is the sort of public-facing ROC API, but the other part is something implemented in a lower level language than ROC that sits beneath that, that is responsible for actually implementing the like I.O. primitives and basically all of the like low-level stuff that you would normally associate with like a language runtime. Um, including memory management. So the way that that works is essentially if I'm writing my rock application, every time that application needs to allocate some memory, the rock compiler is going to generate a call to a function that's implemented in the platform somewhere called rock underscore alloc. It's basically like malloc. Um and whenever the reference count gets to zero, it's gonna call rock dalloc, which also is implemented in the platform. So here's an example of what's cool about this. Let's say I'm building the like on the basic web server platform. I happen to know that basic web server just does kind of your traditional malloc and free, so it's basically just feels like a normal automatic reference counting system. Fine. There's a work in progress web server platform that is planned to be API compatible with that basic web server one, so if you've built something on top of the basic web server platform, you could just try switching to this and see how you like it. But its main selling point is that instead of using Malik and free, it bump allocates on a per request basis. So if you have a request handler, a request comes in, that entire request is going to be doing bump allocation into an arena that's specific to that request for the entire duration of the request. It's not gonna free anything, and then once you get to the end of the request and you've sent the response back, it's just like cool, we'll just reset the arena and then move on. And you also set, uh you say, like, here's how much memory I want to allocate to each request. Each request gets this big of an arena. And if any individual request exceeds that, then you get a 500 error and nothing else happens to the rest of the in-flight requests. Um so this has like a number of cool properties. One of which is obviously it's we assume going to be faster than like managing a free list and stuff like that. Like bump allocation and deallocation is like about as fast as it gets in terms of memory management strategies for um heap allocations. Um, but secondly, it also means that you get this really nice granular control over um memory limits on a per request basis, rather than, for example, saying like, you know, this entire server has this memory limit, and if we go over that, then you know, maybe like something bad happens to the other requests that are in flight, etc. Um it's it's sort of very narrowly scoped and sort of isolates if something is misbehaving or using way more resources than we anticipated, it's really limited to just that one request handler and nobody else's experience is affected. So that's something that I don't know of any other automatically memory-managed language where you can do something like that.
BryceWhen when um uh can you write a rock application where like do you write code that is platform agnostic? Um, or do you write code specifically to a platform?
Richard FeldmanWell, if I'm writing an application, it's yeah, it's gonna be for that particular platform. Um but I guess the better answer is you can do both. So so certainly we expect like libraries in the in the ecosystem to be almost all platform agnostic. We have a plan, and this is something that's not implemented yet, but uh a design, I should say, for how to make it so that you can write platform agnostic I/O packages, like things that depend on I.O. but don't depend on any particular platform's implementation of that I.O. They just say, like, I depend on HTTP. It, you know, we have a common understanding of what HTTP IO means across multiple platforms. And as long as you're using a platform that provides that, cool, you can use this package for you know error reporting or something like that. Um uh so we have a plan for all that, but that's not uh that doesn't exist yet. So that's still in the uh designed but not implemented stage. So the the cool part about this to me is that it means that as an application author, I get a user experience that's quite familiar. I'm like, oh yeah, okay, I I choose this, it's not called a framework, but it's you know something similar to that, that like it's domain-specific, and I'm gonna use as my starting point to build on. Maybe it feels a little bit weird that my IO primitives don't come from the standard library, but rather they you know come from there. But like, whatever. That's not very different. It's just like a where am I importing them from? Um, but then you just sort of automatically get these cool benefits in terms of like you know, memory management, and another really interesting one, which is a whole long tangent, is security. Um, so one of the things you can do with this is somebody can implement a platform called, let's call it like SafeScript. And basically the idea here is it's like this is a command line application where the feature is anytime the rock program that you're running on this platform tries to do any kind of I.O. it will prompt you, like say, hey, do you the this rock program wants to read from slash etc slash password? Do you want to allow that? Yes or no? Um, this wants to write to this folder and you know on your direct on your hard drive. Do you want to allow that? This wants to do this network request to this URL, do you want to allow that? Um and the purpose of this would be I don't I'm I'm sure you guys have had this experience, but like you know, you download some program from the internet and it's like, hey, this is gonna do a convenient thing for you, and I'm like, cool, or it's gonna destroy my you know computer or turn it into a bot, or like, you know, install something that I don't want installed. Um there's there's really no nice way to verify that like something that you download from the internet is not doing something malicious. Like kind of the state of the art is like either like run it through a some sort of third-party checker that hopefully will tell you whether it's legit or not, or inspect all the source code and the source code of all of its dependencies yourself. Um, which is like nobody does. Um, so the cool part about this is that if you have this, a platform like that, you can verify something you downloaded from the internet just by looking at like the one line of like what platform is it using. And if I know that that platform is the one that does the prompting, then I'm like, cool, I don't have to trust this thing because it's gonna be like I'm running it in the browser, where like anytime it tries to do anything that could possibly harm my system, it's gonna prompt me. And because the platforms are in charge of 100% of I.O. and there's no workaround for that, there's no like escape hash that lets you get around that in the language. I know with 100% certainty that it's like, yeah, if it tries to do anything malicious, like I'm gonna get a prompt and I'm gonna find out about it, I'm gonna have to approve that before it can do the thing. Um, that's also something which I I don't know. I think the closest I have heard of any language doing something like that is Dino. And uh, you know, again, without going on a big tangent, like they don't really do it in that granular, granular of a way.
BryceInteresting. Yeah, it's interesting.
ConorI've heard this on uh your podcast because you've talked about people that are more familiar with security. And I mean, it sounds like it's just offering like rock is gonna be offering more than like any other language in this space in terms of Wait, was that was that your motivation for the platforms concept?
BryceLike what why what what what was your original motivation to the platform concept?
Richard FeldmanThat's a great question. So it actually wasn't security at all. I just kind of realized that part way through. The original motivation was actually just that um, so I'm a big fan of the Elm programming language. Uh that's before I got into ROC, I I spent quite a few years uh doing Elm and really loving it. Um I wrote a book about it called Elm in Action from Manning. Um I taught like courses on it. I spent more than a hundred hours personally standing in front of classrooms teaching beginners Elm. Um and uh the reason that that like I was I felt motivated to start ROC was basically wanting a language that had an Elm-like feel to it, but which could be used in sort of the long tail of domains. Like Elm is a very domain-specific language, it's like really focused on like building browser-based UIs, and if and when it expands to other domains, Evan's approach is to like look at that domain and try to answer the question like, how can we do a really, really great job, like you know, supporting this domain in this language? And that could potentially mean making language changes to do that. And um so there's naturally this sort of long tail of use cases that Elm is never going to address, like Elm itself. Um, examples that come to mind are things like editor extensions. Like, I was using Vim for a long time, and I was always like, I would like to write my own extension, but I don't want to do Vim script. Like VimScript does not have a good reputation in terms of like user-friendliness. I would really love to use Elm or an Elm-like language for that, or like database extensions, or you know, robotics making a clock. Like, there's just all these things where it's like Elm's never gonna get into that domain. And so I wanted a language that could try to recreate the Elm-like experience, but for all these domains. One of the things that I think is key to the the niceness of Elm is that for a given domain, Elm is like, look, here's all the primitives that make sense in this domain. Like you don't have um, like in the browser, for example, you don't have like file system stuff. Like Elm just doesn't have any file APIs because you don't have files in the browser. Um in contrast, like I know that you can use Rust um in the browser. Like there's uh there's a package called UYEW that is for like building user interfaces on WebAssembly and Rust in the browser. But of course, like in the Rust standard library, there's a whole module on file system stuff. Like if I'm depending on a third-party library that does a bunch of file system stuff, I don't even know what's gonna happen if I use that in the browser. I also don't even know which of my dependencies like are gonna do that or are gonna rely on that functionality being there if I try to use them as dependencies in my browser-based project. Um, so the whole ecosystem in uh in in most languages is sort of let's assume that like everything is available even though it might not be. I have similar questions about like database extensions. Like if I'm writing a database extension, I don't want that thing to be doing arbitrary network requests or like HTTP in the middle of my database. That's that's like not good for such a performance-sensitive environment. Um so uh, or and likewise, you know, if I'm uh running like a little you know servo thing on a Raspberry Pi, maybe it's not connected to the internet. Like, what if I'm using a dependency that's you know relies on doing a network connection? Um so basically, I really wanted to try to recreate that sort of domain-specific focus while still addressing the long tail of domains. And this was the solution I came up with was just to say each individual domain, you somebody can create their own little elm-like experience in that domain using a platform. They can say, here are the primitives that are available that I think make sense in this domain, in this use case, um, and you know, here's the memory management strategy that I think makes sense for this use case. Um, and you know, that they can sort of be in charge of that. And as a user, I don't necessarily need to think about like, oh, what can't I use here? It's just like, oh, well, just I picked my platform, and that's all the stuff I can use is there, and all the stuff that um you know doesn't make sense in this domain just isn't available, and so there's not really anything to think about.
BryceSo, but like what so you can only use one platform at a time.
Richard FeldmanYes, everybody asked that.
BryceOkay, but what if I want to use two platforms?
Richard FeldmanSo I mean the short answer is that um it's actually fascinating to me that um this is like a ubiquitous like question. Whenever I describe this, everybody's like, and uh so actually a common way that people phrase it is like can I compose platforms? So let me describe how platforms actually work under the hood, and then I think you can maybe see why the question doesn't as uh doesn't have like a reasonable answer. So literally what's happening is that rock itself actually compiles down to basically the equivalent of a C library, like just an object file. Um it just exposes a bunch of functions. That's it. Rock is not in charge of like main or you know, start in in the like in the binary. Um rock is just like here's a bunch of functions. The platform is actually in charge of main. The platform is like I have you know my C program or my Rust or or whatever you're using to implement the low-level stuff. Um, and you have main, and then at some point you call the rock function. And the rock that that sort of kicks everything off from the rock perspective. So another use of rock, by the way, because of this is like you can embed it in like a very large other project. So you could use it as like a Lua alternative and like a game engine or something like that if you wanted to. Um but because of that, it's like, well, how would you have multiple platforms? That's like saying, like, how would you have multiple mains in an executable? It's like, well, you you can't. There's like there's only one starting point, that's the whole point. So because the platform is in charge of all that stuff, um, it just doesn't really make sense to have more than one, you know, competing executable inside your one executable.
BryceThat makes sense. But like, what if I so like if like you mentioned uh a command line platform and a like a web server platform, right? Like what if I wanted to have some sort of command line tool that has a web server inside of it? Would I need a separate platform for that?
Richard FeldmanThat's a good question. I mean, so uh not necessarily. Um it just kind of depends on how you want to have things set up. So for example, in our command line tool, we do have like you know TCP socket support. So just using that, you can just build a web server on top of that in pure rock if you want to. There's nothing stopping you from doing that. What you won't get is you won't get the like bump allocated per request experience that you get if you get like a um uh yeah. But now another thing to note is that depending on what you're using it for, like, so actually I I actually have run into that at work before, um, that that exact use case, and it was specifically for doing um like an OAuth authentication flow, where you needed to like stand up a web server locally, and then the uh um the thing you're authenticating with would go hit that. Um but I think there's actually a pretty good reason that you wouldn't just want to always just use this you know command line tool that um like in addition to missing out on the potential um you know bump allocation benefits on the request handlers, um, which is that like I kind of don't want my web server, typically if it's if it's mainly gonna be a web server, to have the option to like read from standard in and like block on that. That's not good. Like that's not that's not gonna do anything, uh not gonna do anything good. Um that's something that totally makes sense for a command line app, but like for a web server, it's like if you're ever reading from standard in, like something has probably gone wrong. Um, because there's not gonna be a keyboard you know attached to that thing, most likely.
BryceYeah. Okay, that makes sense to me.
ConorI think, I mean, you mentioned this before, but it's worth highlighting again that you did say that there's gonna be a facility for writing libraries. I don't know if you want to call them like platform generic libraries, but if you're yeah, if if you're trying to write something generic enough that it should be able to work across a certain number of libraries, there's gonna be a way or a number of platforms. There's gonna be a way to do that in the future. You're not gonna need n different libraries for n different platforms, um which is, I think, the important part. Because a lot of the times applications, that's less when you care about like genericity uh versus when you're writing a library, you don't want to have to rewrite that library every single time you want a new application on a different platform.
Richard FeldmanYeah, totally. And and like we have a really uh that part of the design I'm super excited about. It's just like it's not it's not the top priority to implement it right now because right now we're more in the like, hey, let's make sure that people can have a good experience like writing on the one platform. There is no real ecosystem yet to like to make you know platform agnostic. Um, but but yeah, like I I am very excited for once we do implement that feature because I I think the design turned out really, really well. We could go into that, but I I think we're already uh probably over on time again.
ConorI was gonna say, I mean, we talked a lot about platforms and the you know the uh continuation monad, aka uh task chaining IO stuff. Is there any like in the last you know couple minutes though, if you just want a rapid fire you know ecosystem or language stuff for people to be excited about if it exists or will exist, is there gonna be a package manager?
Richard FeldmanYep, that's the plan. Um so you already can do packages using a URL thing. This is something I I think uh instead of rapid firing, I'll just mention this one thing because I think it's pretty cool. Um so the way that you do packages today, we don't have a package index yet, so like a searchable way to like discover them. But you can already just like uh automatically download packages, and we have, as far as I know, this is we're the only language to do it this way. And I think this design is awesome. Um, and more languages should steal it. Um so basically the way that works is let's say I want to depend on Luke's JSON parsing library. The way that I do that is in my dependencies, I say, here is I I'm depending on uh this this JSON parsing library, and here is the URL for it. Now, the thing that we do that nobody else does is that when I specify that URL, the URL has to be in a particular format, which is that the end of the URL has to be a Blake 3 hash of the contents of what's gonna be downloaded from that URL. It has to be in the URL itself. Which means that a couple things. One is once I download it, first of all, we can cache it forever now, if we want to, um, because we know that it's never going to change. If it does change, well, it's just gonna fail the the checksum when we download it, because the the hash is is different. Um this also means that if that domain expires or gets compromised or hijacked or whatever, somebody like publishes a new version, even if I have never downloaded this thing before, like I'm just reading about this off a tutorial, I copy paste the code in, I've never used Rock in my life, I have no, there's no infrastructure for this, there's no centralized anything. Like I just use that URL, somebody took it over, I still don't get a bad package. The worst possible thing that can happen is I get an error. Um, from a security perspective, this is I think unprecedented. I think every every other language that uses URL-based um uh like packages like lets you download a package direct from a URL as a dependency, um, either they're like not caching it, or uh even if they are, there's potentially some security vulnerability in there somewhere, or else there's like a well I should say and or potentially there is also additionally a security vulnerability, um, unless there is some like centralized system that is like proxying and caching all those, which I think is what Go does. Um but most languages I don't think do that. Uh like they don't have like a, oh, the last time anyone downloaded this, we checked it out and it had this hash, but the hash has changed now, so beware, you know, it's it's potentially malicious. Um but what I love about it is that it's just baked right into the URL. So if anyone does want to, you know, they they do successfully hijack the domain or whatever are are otherwise able to publish that URL, like what are they gonna do? Like if they want to publish something that's different, they have to change the hash, at which point the URL becomes different, and that's not what people are gonna be downloading. So
BryceAlthough I I gotta say it and it it makes for unattractive looking URLs. My first thought when I was looking at through the tutorial, my first thought on the first example where it's got a package line was to tell you like, hmm, maybe you could come up with a shorter URL for this.
Richard FeldmanSo, you know, I that was my fear with this system, and I thought like, okay, well, we'll start with this, and then we'll see like how many complaints we've gotten. Um, and and then like, you know, about the the URLs being really long, and then like maybe we can find you know some way to centralize and like shorten them. This I'm not even joking. This just now is the first time I've ever heard anyone complain about that.
BryceUh I and I'll I'll tell you the reason that that that I think you'll never hear anybody complain, because it it it looks bad in the tutorial, um, but nobody's ever typing it out. People are just copying and pasting it.
Richard FeldmanExactly. That's that's that's what I figured. Yeah, and that's what I do too. Like I I I also never like write it out by hand. Um but at the end of the day, like I think that's fine. Like it has a lot of really nice technical properties, and like if everyone's just gonna copy-paste it anyway and then never really look at it, like I don't know, it seems fine.
BryceI think it's fine. I mean I guess I guess the thing that um uh you know eventually once you have a package manager, then you can shorten a large part of the the URL before the hash, you know. You can just have it be rot dot rock.package or whatever.
Richard FeldmanYeah, potentially. I mean, so there's that's a whole like long tangent uh discussion, but um but yeah, it is definitely something we potentially can do.
ConorThis has been a whirlwind of uh talking about everything from Strange Loop to rock. And the beautiful thing about rock is unlike some of the languages we talk about, you can actually go and try it out now. That's true.
Richard FeldmanIs it rock.org? It's uh I I wish we had that. It's uh rock-lang.org.
BryceAnd and I and I do want to uh say I think it's got a really good tutorial. Um, and I uh w when you were talking earlier about how it's a language that's meant to be easy to use, that was one of the first things that I got out of the tutorial because the tutorial is um a tutorial that I think's designed approachable, like not not too simple for somebody who has a lot of experience programming, but I think also if I was even like just learning a programming language, Earth is my first programming language, I think um the tutorial's well laid out for for a newcomer.
Richard FeldmanWow, thank you so much. I I spent a bunch of time on it, so it's great to hear.
ConorIs the tutorial uh a preview of the new style for the upcoming Rocklang uh website? Because the rocklang.org just takes you to the what kind of looks like you have a markdown file and it's being rendered. But the rock tutorial has got lots of colors, lots of fonts.
BryceUm you got that great font that uh what is it? Permanent marker font.
Richard FeldmanYeah. Um I'll give you a preview after we sign off of the of the new one. Um but uh yeah, by the time people hear this, they'll just be like, what are you talking about? This is just what the whole website looks like.
ConorYeah, yeah. I imagine there's gonna be some uh orange site posts and buzz when the when the new website is up. Uh or maybe maybe not. Maybe that's not in the the the plan. But if you don't, I'm sure someone will. I I yeah. I I mean you can never tell with these things, but uh I wouldn't be surprised. All right, well, thank you for taking so much time out of your day to chat with us. I know the listeners, I mean, they love when we chat about uh cutting edge, bleeding edge programming language stuff. I mean, we love chatting about it, but uh our listeners I think also enjoy and this is in the I mean, like it's not a C successor initiative, but it's kind of in the uh space uh if you're trying to be fast, you know, that's that's C adjacent, you know, even if it's a completely different paradigm. So interesting. Uh, you know, we might have some people on the the Twitters or whatever the websites are called these days. Uh oh yeah, there's a great way to end it. Where can people find you? Are you on the Twitters? Are you on the Mastodons, or have you given up on social media sites? Or uh how can people reach out to you if they want to either get involved or ask questions?
Richard FeldmanYeah, I I I I don't post a lot, but uh I am on Twitter, uh RT Feldman, um, also on GitHub. Uh but if you want to get a hold of me, Twitter's a good place to do that. Like my DMs are open, so uh that's that's kind of the main thing that I use it for.
BryceThat's what we like to hear.
ConorI mean, it's what we like to hear because we hope the site doesn't go up in flames, but uh you know, every week that passes, um I have less and less faith in Bryce's conviction that the site's going nowhere.
BryceI'm telling you, we're look, look, I'm just a stubborn man. We're gonna outlast Elon. Okay.
ConorI mean, but is is the site gonna outlast Elon? That's the real question. We sure we will outlast him, but uh I'm telling you, any day now, man.
BryceAny day now.
ConorAll right. Well, thank you once again, Richard. Yeah, expect you know, some amount of uptick and interest, whether that's one person or you know, several. Um, I'm sure there's gonna be a few people checking out rock.
BryceAnd and all you can cut this out if you want, kind of everybody go make a uh a rock repo on GitHub in tax only.
ConorI mean, we have several thousand listeners, so uh if even a percentage of you did that, uh it would have to be even like if five percent of you went and did it, uh it would push it over the edge.
BryceSo I think it's kind of a silly GitHub thing. They don't just like allow you to like sell like they should have a model where you can self-serve and do the work on your end to add the syntax.
Richard FeldmanOh, I think I think you do have to do it anyway. It's just they won't accept your PR unless I I think the reason they do that is probably to prevent like extension squatting or something like that. Yeah, yeah.
ConorThat is exactly what I was thinking. Because like I think it's probably like there's 10,000 languages if you if you count everyone's pet language, like um it's I think even like not counting the pet ones, it's in the thousands. And if you count the pet ones, then it's like in the tens of thousands, and I guarantee you there'd be so many extension clashes. And a lot of languages they choose more than one, right?
BryceSo um, okay, fair enough.
ConorAll right, well, with that, signing off, and uh stay tuned, listener. I don't know what episode this is. We're probably on 156 to 159 inclusive, which means you might be hearing from Sean in episode 160, unless if that's right around Christmas time, in which case we might be bringing Zach back on and having our holiday special where we chat about random stuff, which is basically what we just do anyway. So, anyways, thanks for coming on again, Richard, and uh good luck with uh rock going forward and hope hopefully we uh expect to see it, you know, being used by the whole entire world in a year in the future. Well, thanks for having me. I appreciate it. This is fun. Be sure to check these show notes either in your podcast app or at adsphepodcast.com for links to anything we mentioned in today's episode, as well as a link to the GitHub discussion where you can leave comments, thoughts, and questions. Thanks for listening. We hope you enjoyed and have a great day.
BryceLow quality, high quality, that is the tagline of our podcast.
ConorThat's not the tagline. Our tagline is chaos with sprinkles of information.