I was just corrected that it's it's definitely not Pascal, it's Pascal. And uh I got I got called out on the last episode uh for mispronouncing that. And we had homemade apricot, is that apricot?
Jonathan O'ConnorApricot ice cream, yes. Apricot ice cream, and it was divine. I was in Rwanda for six weeks and I wrote this. What happened was the company that we had connections to, they they ran all the ATMs in the country, and that and I started doing it in Java, and it was just so awful. And then um my boss of the times suggested that I do it in Ruby, and that was a fantastic decision because Ruby is great for string handling.
ConorWelcome to ADSP the podcast, episode 152, recorded on October 18th, 2023. My name is Connor, and today with my co-host Bryce, we interview Jonathan O'Connor and chat with him about his journey from C to Jenni to Ruby and back to C, as well as his programming experience with Ruby and Rwanda, Quines, and more. Let us introduce our guest first. Let me hop over because I actually went and found. I went and found Mr. Jonathan O'Connor's bio from Meeting C, which is a conference I know that you've given a couple different talks at, I believe. This one is uh entitled Hands on C20 Ranges, Code Routines, Concepts, and Modules. And the bio No, that's not me. No? Oh no, wait. Correction. That is a very poorly placed advertisement right on top uh of your your uh profile picture and your name. And uh and then in very small, I guess it's the same font as the font size as the bio. It says Tox Colon Alice's Adventures in Template Land. But I guess this is an advertisement for a book, which I mean I'm pretty sure it's very unintentional on Jens's part, the organizer of the conference and the designer of the website. I'm actually, I gotta take a screenshot of this so we can put this in the show notes, just so that people don't come at me for uh for thinking like it is it's definitely and it's it also it has no border. So, like on um Compiler Explorer, they have ads at the top in the banner, but they're always in like a little green kind of highlighted thing. It's very clear that this is an ad. This is just like a hyperlinked image. Uh, and if you look closely in in the bottom left-hand corner, it says capital A D in what looks like size 7 font. Um, anyways, whether that stays in or not, uh I mean personally, uh I know Jonathan because we met. I mean, I I believe you were at the conference too. This was 2019 meeting C.
Jonathan O'ConnorThe three of us had had dinner at a Vietnamese restaurant. Uh, that's right. 10 minutes walk. That's right. And I think both of you at the time were um not drinking any alcohol, which seems to have changed uh during your road trip.
ConorI mean, for 50% of us, Bryce is still For 50% of us. Yeah, Bryce is still on that uh, you know, the golden path to success.
BryceFair enough. Is that the first time that we met, Jonathan?
Jonathan O'ConnorI think it's probably the only time we've met in person. I don't think I don't think we've met since now.
ConorHowever, I met Jonathan for a sec I believe it was the second time, because I have a sister that currently lives in Dublin, Ireland, and you live just outside of Dublin. And my sister and I went and visited you at your lovely home, and you hosted us. You had some family there. And the highlight, of course, enjoying Jonathan's lovely company was amazing, but the highlight was something I don't even I actually think I said I was gonna tweet about it, and then I didn't tweet about it. It was, and if I recall the flavor, it was apricot. Am I correct in that? It was yes, apricot, as we say in in Ireland.
Jonathan O'ConnorUh ice cream.
ConorI've discovered that I've been pronouncing all these words. I was I was just corrected that it's it's definitely not Pascal, it's Pascal. And uh I got I got called out on the last episode uh for mispronouncing that. And we had homemade apricot? Is that what apricot ice cream, yes. Apricot ice cream. And it was divine. And that was, I think, the second time we met. Um but yes, back to this bio. It reads in 1998, I joined. I'm gonna mess this one up, Glockenspiel. No, that was 1988. 1988.
Jonathan O'ConnorIf it's uh then it's a misb maybe I wrote that wrong or something, but no, no, no.
ConorI just have uh what do you call it? Not dyslexia. There's a word for it with numbers called uh what is it called? Discalcula. Discalcula.
Jonathan O'ConnorOkay.
ConorWho knows?
Jonathan O'ConnorI just misread it. Okay. But Glock Glockenspiel, yeah, I joined Glockenspiel in 1988. Uh I had two friends of mine were uh working there, and they recommended me for to their boss, and I had a 40-minute conversation with him and was hired. That was how people used to get hired in the old good old 40 minutes. 40 minutes, yeah.
ConorHow many leak code questions in that 40 minutes? You know, how many how many link lists did you have to reverse?
Jonathan O'ConnorI don't think any uh actually, yeah. Um you worked there? Yeah, I worked there for a few years and uh I wrote uh yeah, that's where I learned C. And two of my fellow colleagues there, they worked on the compiler um on the C front, which was uh you know the predecessor to an actual proper compiler. It it would generate C code, which would you then get a C compiler to compile to uh assembler or machine code. Um, but uh yeah there was Martin O'Reardin, who was uh the only member of the Irish uh from from Ireland who was on the standards committee for many many years, and he helped to write uh the first um Microsoft's first C compiler back in like 1990, 1991. And John Caves, who I I suspect Bryce has met John Caves. Uh he's be still he's still on the um standards committee, um and he's still working for Microsoft, and and the two of them were were uh in Glockenspiel at the time.
BryceWhat a what what what a time and what a group of uh of of folks to get to work with.
Jonathan O'ConnorIt was a lot of fun. Um and yeah that I mean I I worked on a on a GUI framework for it I wrote uh we wrote uh a library where you could you could create Windows programs or and also OS2 programs, which is uh another operating system that has come and gone. Um and uh I then got involved a lot in education, so I would I would go off and and uh train a company for a week in how to write good C ⁇ uh as it was in the day. Um and yeah the language was so small and we had I think uh we had no standard library, we had no string class. There was uh a um a co-routines uh library that that shipped with Seafront Um which uh was in the I think the first edition of Struwstrop. There's a a chapter at the very back of the book that that describes how to use it. Um and that of course disappeared in the second edition and and and later editions, and finally we've got back some kind of well we've got I'm not sure if the if the coroutines that we have now are are the same or quite different from the ones that were back in this library. It's a long time ago.
ConorAnd famously, or not famously, but according to the bio, you left you left the world of C for Java. And then Ruby. Although Ruby, uh I love Ruby. Ruby is lovely. Uh uh uh what do you call it? A not derivative language, a child language, if you will, of small talk, which I think most Ruby people know, but maybe there's some that don't. But uh was his name, Matt was a huge fan of Smalltalk, and there's a bunch of stuff in in Ruby that uh is basically completely completely borrowed from uh the smalltalk model. So you did that for for how many years? 10, 10 to 15?
Jonathan O'ConnorNo, I did it for about six or seven. Um and that was that was just Ruby or it was just yeah, it was Ruby. The first project I got to write in Ruby was I wrote a little a little translator uh for ATM messages. Um and I did that in Rwanda, which was was great fun.
BryceUh wait, wait, wait, wait, wait. I I want to understand here. You did that for the Rwanda market, or you did that while while uh like you went to Rwanda and I was in Rwanda for six weeks and I wrote this.
Jonathan O'ConnorWhat happened was the company that we had connections to, they they ran all the ATMs in the country, and that happened to be, I think, at the time in in 2010, they had 14 ATMs in a country of 10 million people. There were 14.
Bryce14?
Jonathan O'Connor14, one four, yes.
BryceWow.
Jonathan O'ConnorAnd so that's about one one per what 800,000 or something like that? Something like that, yes, exactly. Exactly. Um and they the company that had bought another 10 ATMs, but the those ATMs were not quite compatible with their server software. And if they wanted to get um uh if they want to update their server so they could get a module uh for their server software, but that module will cost like 50 grand. And they thought, nah, they'll they'll get somebody like me to do it for a few weeks, and we'll just I'll just write a little translation program that that sits in the middle on a on a little um netbook and it listens for messages from the ATM and it listens for messages from the the server, and it just translates. Most of the messages are the same, so you it it just goes all the way through, it's passed through, but there's a few types, it's a few messages that have to be tweaked. Um and uh and I started doing it in Java and it was just so awful, and then um my boss at the time suggested that I do it in Ruby, and that was a fantastic decision because Ruby is great for string handling and slicing and all that kind of stuff, so it was just so much easier um than Java.
ConorThis is very true for leak coding purposes. Sometimes Ruby is the best uh language for speedslash length because it has a ton of convenience methods on strings like uh TO underscore I and like T O underscore B, I believe. And that one is super useful because it's like uh two base, and then you provide the base. Or so yeah, if you have like a string number, it will actually maybe that's not integers. I can't remember. The point is that there's a bunch of these like tiny four-character convenience methods where if you need to convert like an integer to its base two representation, which is gonna be like you know, a 10-line program in C if you're going through it, uh you can just do that in like literally 10 characters in Ruby. And uh yeah, a ton of super nice convenience. Sometimes they they have odd names, but once you figure out what it's called, uh they are very, very nice to have.
Jonathan O'ConnorYeah, I think for me the the nicest thing there was that you have slices in Ruby. And so you can s you can slice an array or slice a string, and you can you can give it like a little sub-range with I think it was dot dot. So you can say like zero, you can take a string square bracket zero dot dot three, and that'll give you a close square bracket, and that'll give you the first four characters of the string. And the nice thing the nice thing about that is that uh well nice thing about uh Ruby is that if the string is only like uh two letters long, two two characters long, it doesn't matter, it'll give you those two, and it'll say, Oh, I know you wanted four, but you know, two is all you can get, and I'm not going to complain about it. Whereas in java, uh it's uh you want four characters, it's only got two. Oh, sorry, uh I'm throwing an exception here. Um so from that point of view, things were very nice. It was much simpler um to do this in Ruby.
BryceBut doesn't Python doesn't Python have Yeah Python has that now too.
ConorUh I'm not sure if they have the short circuiting um only give you what it has. Uh but I'm not sure. Maybe at the time Python didn't?
Jonathan O'ConnorThis is I have to admit, I know very little Python. I I can just about read it, but yeah.
ConorThe the key thing is though, is Java definitely did not. And like Java, I know modern Java has introduced like 20 or 21 introduced some new string facilities and types that makes it way, way easier. But like back in the day, they had like you know, strings were immutable, and then they had string buffers and string builders, and it was just like coming from a language where you can, you know, manipulate strings easily. Uh Java, it it was uh you were jumping through hoops to do like very simple things, um, which is you know a large inconvenience if if you're not used to having to do that. Um even in Caling with strings is pretty you can you know add two strings together, it's not it's not too bad. Like sure, you have to make sure you don't trip up on string literals and constructors and stuff, but uh I I remember like Java was I was like, what? I gotta go learn about a builder now? Like I just I I just want to do something real simple. They're like, well, if you want to do something uh that involves mutability, then you're gonna need a builder. And I was like, really?
Jonathan O'ConnorYeah, I think that went away in by by Java 5 or Java 6, but anyway, nevertheless.
BryceI I have some I have some questions about this Rwanda ATM situation. So are all the ATMs in Rwanda still run by this netbook that's running your Ruby code?
Jonathan O'ConnorUm I think no, I think I think we had a net I think that we were going to have a netbook uh per ATM.
BryceOkay, okay. So is each is each ATM in Rwanda still still running this uh Ruby code that you wrote?
Jonathan O'ConnorI have no idea, but I suspect the answer is definitely no. Um I mean at at the time they they we had the best internet connection in Rwanda with and it was 360k baud.
BryceSo uh that's not a lot for our younger listeners.
Jonathan O'ConnorIt's not a lot, um and I know now that they have excellent uh internet in the country from from talking to friends of mine uh who live there. Um so they're yeah, things are are are fine now. Um but at the time it was pretty poor, and also the other good thing about using a netbook was that it was like it had uh good battery life, so you could survive uh power outages and the system would continue to work, which was also pretty important. And and the the last point about the netbook was that like these were they cost what 200 bucks, um they were they they cost nothing, but uh we were only getting maybe when somebody was using the ATM, you might get a message every second, you might get like 10 messages, and that was it. So you didn't have you didn't have to be high powered at all. Um so that and Ruby was there for totally fine. There was no speed constraints on the system. Um so what year was this? This was 2010.
ConorYeah, so that it's that's pretty consistent. I just looked it up and I don't know how accurate this data is, but uh what is it, the Federal Reserve Economic Data website, something like that. And it says that in t in 2010 there was only 84, but just like three years earlier it was 16. So I mean that's definitely consistent with what you're saying, and it peaked according to this site in 2017. They had 406 countrywide. I was assuming that that number was gonna be like in the thousands, and it's actually gone down. So currently, as of 2022, this website says that there are 347 ATMs in Rwanda. And that is very, I mean, surprising, but then I guess I've heard that a lot of African countries um use like I don't know what the name of the app is, but like the equivalent in China is Weixhin or Wheat.
Jonathan O'ConnorThey have a th they have an app. It was the first, I think it was the first um app in the world. Uh it was done by a Kenyan company and they called it X uh M Pesa. M Pesa is Swahili for money, I believe.
ConorUm a lot of banking happens on like cell phones. Yeah, it's they skip, they skipped a whole uh I don't know, like evolution step that you know Western countries went through because everyone had cell phones before they had and in fact MPESA was e it wasn't even on the smartphone, it was on the old like Nokia.
Jonathan O'ConnorAnd you'd basically you'd actually they would install this tiny app onto the phone and you would then type in the phone number of the person you wanted to send, you'd type in um uh an amount of money, and you'd click send, and and there'd be maybe one other thing, and that would that would send your money.
BryceUm the net the netbook thing, you know, I think a lot of people's first reaction is oh you're like that's so like hacky, like yo, you should go get a put it on a Raspberry Pi, put it on some you know, like they had Raspberry Pi back. But the battery thing, the battery thing is so clever. Like one, they're super cheap. And two, like you know, your your little Raspberry Pi or your edge computing device is doesn't have uh uh you know a battery backup system built into it that a laptop does. Yeah.
Jonathan O'ConnorYeah, it was just it was cheap and it worked. Um so yeah. I love that. I love that story. But uh the the reason why uh there were only like 14 or ATMs in the country at the time was about maybe three years before the president of the country, Paul Kagama, he had been uh he'd been somewhere traveling in maybe America or somewhere like that, and the hotel had asked to take a a scan of his credit card, and he didn't have a credit card. And he felt somewhat embarrassed about this. So he when he came back home, he said, right, we're going to mandate uh we're gonna have credit cards for people or or electronic cards, and that's why they they this company was started. Um interesting.
ConorYeah. What do you call it? A uh fortunate or unfortunate series of events that like you know leads to uh and so it before that point I guess they they didn't have I guess what does this graph say? It says Yeah, in 2004 there was only two.
Jonathan O'ConnorOh, okay. So they actually had they had some then, right?
ConorYeah, but I mean it's if it's two, I mean odds are they're you know uh that you're gonna find yourself standing next to one when you need one is uh pr pretty astronomically low, this the probability of that. Uh yeah. Alright, but you so you found your way back to C in what are the bios?
Jonathan O'ConnorYeah, that would be about twenty twenty sixteen I started uh reading stuff about it again and found that the language had co totally changed from what I remembered. From like I last wrote C for about 2000, 2001, and then I switched to to Java at that stage, and then 10 years later I switched to Ruby. But 2016 came back, there was Move Semantics. Wow, that was like that took me forever to figure out.
ConorWhat was your what was your favorite? So you were, you know, your mind was uh you know befuddled by move semantics, but from 2001 to 2016, that's I guess 11 and 14. Uh what was like the the biggest or I guess how do you phrase the question? What was your favorite change and like what was the the biggest paradigm shift from when you were coding or well you had a standard library for a start.
Jonathan O'ConnorThat's not what I was expecting you to do. But I guess that is yeah, we had strings. Uh we had we had vector ones, but they're still strings. Yeah. Yeah. Vector, you had you know all these you know useful you know, you have m maps uh hash maps and whatever. It's it's It's fantastic. And that's something that that the old languages uh never had. You know. Pascal I don't think had No, it didn't have any standard it it had it had standard output. You could print stuff to files and to the the the console, but that was it.
ConorUm so Java, I mean, because Java famously has a massive standard library. Was that the first language of the languages back in the 90s that kind of started to ship with code that you could use and not have to write yourself? I would think so.
Jonathan O'ConnorAlthough small talk, small talk has small talk had yes, small talk had a big had a big library, absolutely.
ConorAnd I guess java is also uh a descendant of Smalltalk, you know, even though it's not really people hear object-oriented and they think of both of those languages, but yeah, I guess you could argue that you know there's some other language that that Java is.
Jonathan O'ConnorI'm wondering, I'm trying to remember Lisp, which was my favorite language in in college. Um that was that had a lot of stuff in it. You could do a lot of but I'm not sure if I don't think well with Lisp, like you've got the core and then everything else is is kind of added on.
ConorI feel like I've heard that Common Lisp famously also had massive amounts that like shipped with it, and that that was kind of both a pro and a con because Lisp is famous for being this very small, nuclear, homo iconic, uh, you know, data is code kind of thing. But then Common Lisp went this other direction, and this is all just third party from having heard people give talks on this, is like it shipped with a ton of stuff that kind of like ruined that. Like it still had the core somewhere inside it, but it it shipped with a bunch of stuff. But I've honestly never programmed a common list.
Jonathan O'ConnorYeah, I I haven't either. I used I used uh a lisp called Franz Lisp, which had lots of puns. Franz Lisp. Franz Lis-N-S? No, F-R-A-N-Z. Franz L as in Franz Liszt, the composer. It had lots of jokes about about uh the the 19th century composer. Have you heard of Franz Liszt, Bryce?
BryceNo, it it's gotta be a pretty obscure language for Connor.
ConorI mean, I made a whole video at one point when I was working through the structure and interpretation of computer programs that was like the history of Lisps, and I discovered a ton of Lisps that I had never heard of, like Pico Lisp, and I don't know. There's there's a bunch I have heard of. There's one also called Dylan, I think, that was out of Microsoft that Oh, that must that sounds later.
Jonathan O'ConnorThat sounds a lot later.
ConorBut um Yeah, yeah, that was the 90s. Uh but anyways, the whole point is like, you know, there's a whole world of Lisp's out there. People think of like there's the Lisp Lisp, there's Scheme and Racket, and then there's Clojure, but like behind the scenes, there's there's like 50 other Lisp that uh all vary in their language features and whatnot.
Jonathan O'ConnorThe thing about Lisp, you were saying it's homo iconic, which means data is program and program is data. And I got interested there. Uh well, I was interested a long time ago, but there was uh about quines. Do you do you guys know what a coine is? Yeah, yeah.
BryceA coine is I've heard it before, but I don't remember.
Jonathan O'ConnorA coine is a program that when run produces its own uh source code. Um and it doesn't just do like you know, read the file and spit out the answer. Um but I remember writing a coin for Lisp and it was like six lines long. And that checks out. That's yeah, and and and but if you try to do it for for C, it's probably I think 50 lines or something. I know there was a great talk. There was a I think there was a lightning talk there at one recently, well, maybe the last three years about coines and how to write a coine. And it was, I can't remember, I think that they I think the person who gave it was French. I suspect they were, but I could be wrong.
ConorWell, I'll I'll do some searching. And there's definitely a bunch of talks out there. There's a there's a famous set of coines, which I'm not gonna remember the name of, but it's like they generate it's a it's a huge loop, like and it's named after a dragon or snake that's eating its own tail. Yeah where like it started off with like a few languages, but now it's up to like I don't know if it's a hundred plus, but so it's like you know, the Java generates the C, generates the Ruby, and it goes through a hundred different languages all the way back, and so you know, every every once in a while.
BryceLike talk through it right now on the podcast. Just because like I'm I'm I'm I'm trying to mentally imagine like how one of these works.
Jonathan O'ConnorThe main problem is that you've got to handle uh quotation marks and and emitting quotation marks. Because basically, basically you what your coin is going to be, it's going to be like like int main bracket bracket, and then you're gonna have like um uh printf or or stud C out or whatever, and a big long string. And the problem with that is that you've got to handle the extra uh double quotes, and and they they get swallowed, so you have to produce them, and that's and that's the that's where all the tricks come in.
ConorUm, what's the coin is though, right Bryce?
BryceI understand the essence. Um I would still like to see a simple one.
Jonathan O'ConnorAs I said, there there is there is uh a guy did a uh a lightning talk and he showed how to write a coine in about seven minutes. Um at what uh it was in one of the C conferences over the last few years.
ConorAll right, folks. We're we're taking a little mini detour. I will not share the screen, but I have up because we don't do that on ADSP the podcast anymore. Bryce sometimes does because he doesn't care about you, dear listener. I, however, do I, however, do, and I am at rosettacode.org slash wiki slash quine, and I am not gonna be able to count how many languages, but we're looking at roughly I'd estimate 2 or 100 or 300. So I'm gonna scroll and I'm just gonna give you the guesses. So 8080 assembly looks to be a couple hundred, ABAP looks to be 30 lines, although there's a bunch of extra stuff. ACL2 is six lines, and they actually have a shorter one that is a single line. I don't know if ACL2 language is that's a Lisp?
BryceI've never heard of this.
ConorIf I click on ACL2, it says ACL2 is a logic and programming language in which you can model computer systems together with a tool to help you prove properties of those models. ACL2 denotes a computational logic for applicative common Lisp.
Jonathan O'ConnorAh, common Lisp. You see, it's it's a Lisp language, yeah. Okay.
BryceACL I'm I'm jumping down to the bash one.
ConorThis is how my mind works. Oh, look at that. APL. Single line as well, unsurprisingly.
Jonathan O'ConnorConrad is so pleased.
ConorNow I'm gonna I'm gonna read this out for the listener. It's and it's gonna sound like C. Uh it's one rotate, uh Ravel, uh it's ravel commute, nine reshape, and then single quote, single quote, single quote, and then inside the inner quotes, one rotate, ravel, commute, nine reshape. Interesting. So what is that doing basically? It's basically kind of performing a no-op, I think, or a small operation on what is essentially just gonna be the exact same thing. And the nine reshape is gonna give you this code twice because you have one, two, three, four, five, six characters inside your string. And when you reshape on a on a string, so similar to actually what we were talking about in Ruby earlier, instead in that case, we had we were trying to take more than we had where we gave and it gave you back just what what was there. In APL, when you do that with a reshape, which is basically trying to reshape the shape of your string, if you specify more, it actually cycles. So in this, it'll it'll cycle, you know, if you've got one, two, three, four, and you've got trying to do a take ten, you'll end up with one, two, three, four, one, two, three, four, one, two. Which you can argue which behavior is better. Is it the APL behavior, is it the Ruby behavior? The point is that's how APL works. And uh I'm not sure if that made sense to the listener. But uh, Bryce, have you made sense of the bash, the bash uh code?
BryceYeah, I've looked at the C and the bash ones, and uh the bash ones are not very helpful because they just cheat and do awful things. But uh I I I think Hey, there's no such thing as cheating when writing a coine.
ConorThe whole point of a coine is that you just generate the source code that you initially wrote. That's that that's the only rule. Like there's no such thing as cheating.
BryceDidn't we say just a few minutes ago? You can't read in the source file.
ConorCorrect. That's that's cheating. All right. Yeah. I stand corrected.
BryceAnd and I'm fairly certain that what the like the first one of the bash examples here uh is essentially uh it does I don't think it actually reads in the source file, but it um it maps in No, that's what it does pretty much. It maps in the file where the script is, and then it just prints that out.
ConorOoh, and I just realized when I said RAVEL in APL, that was actually the monadic, it was the dyadic definition, so it would have been cat and eight.
BryceI want to see the make one.
ConorThis is probably part one of a four-part episode series. Be sure to check the show notes either in your podcast app or at adspthepodcast.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.