Algorithms + Data Structures = Programs - Episode 152: Ruby in Rwanda with Jonathan O'Connor
Episode Date: October 20, 2023In this episode, Conor and Bryce chat with Jonathan O’Connor about his career path from C++ to Java to Ruby and back to C++, as well as his work in Rwanda and a discussion about quines!Link to Episo...de 152 on WebsiteDiscuss this episode, leave a comment, or ask a question (on GitHub)TwitterADSP: The PodcastConor HoekstraBryce Adelstein LelbachAbout the Guest:Jonathan O’Connor in 1988 joined Glockenspiel, a small Irish company. C++ had no virtual destructors, but it did have a coroutine library! I spent 2 years teaching C++ and OOP. In 2000, he switched over to Java. But by 2010, he started 7 wonderful years writing in Ruby. In 2016, he returned to a completely different C++, where one never had to see a pointer if you didn’t want to. These days he is helping to make the world a better place writing C++ code for LADE GmbH, a company building electric car charging infrastructure.Show NotesDate Recorded: 2023-10-18Date Released: 2023-10-20Jonathan O’Connor Meeting C++ BioMeeting C++ ConferenceAlices adventures in Template Land - Jonathan O’Connor - Meeting C++ 2018Ruby String to_iRuby Integer to_sRuby Slices ..Number of Automated Teller Machines (ATMs), Country Wide for RwandaPython Index SlicingM-Pesa appCommon LispFranz LispFranz Liszt (composer)DylanPicoLispHistory of Lisps YouTube Video (Structure and Interpretation of Computer Programs - Chapter 1.1Rosetta Code: QuineLightning Talk: How to Write a Quine? - Dmitry Kandalov [ ACCU 2021 ]Quine-Relay (Uroboros)ACL2 LanguageIntro Song InfoMiss You by Sarah Jansen https://soundcloud.com/sarahjansenmusicCreative Commons — Attribution 3.0 Unported — CC BY 3.0Free Download / Stream: http://bit.ly/l-miss-youMusic promoted by Audio Library https://youtu.be/iYYxnasvfx8
Transcript
Discussion (0)
I was just corrected that it's definitely not Pascal.
It's Pascal.
And I got called out on the last episode for mispronouncing that.
And we had homemade apricot.
Is that apricot?
Apricot 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 ran all the ATMs in the country.
And I started doing it in Java
and it was just so awful.
And then 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.
Welcome 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 Java
to Ruby and back to C++, as well as his programming experience with Ruby in Rwanda, Quines, and more.
Let us introduce our guest first. Let me hop over because I actually 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 entitled Hands-On C++ 20 Ranges, Code Routines, Concepts, and Modules.
And the bio...
No, that's not me.
No? Oh, no, 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 of your profile picture and your name.
And then in very small...
I guess it's the same font size as the bio.
It says, talks, 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' part, the organizer of the conference and the designer of the website.
I'm actually, I got to take a screenshot of this so we can put this in the show notes just so that people don't come at me for thinking like it is, it's definitely, and it also,
it has no border.
So like on 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.
And if you look closely
in the bottom left-hand corner,
it says capital A-D
in what looks like size 7 font.
Anyways,
whether that stays in or not,
I mean, personally,
I know Jonathan because we met.
I mean, I believe you were
at the conference too.
This was 2019, meeting C++.
The three of us had dinner at a Vietnamese restaurant.
Oh, that's right.
About 10 minutes walk.
That's right.
And I think both of you at the time were not drinking any alcohol,
which seems to have changed during your road trip.
I mean, for 50% of bryce is still for 50 percent
yeah bryce is still on that uh you know the golden path to success is that the first time
that we met jonathan i think it's probably the only time we've met in person i don't think i
don't think we've met since no however i met jonathan for 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 going to tweet about it.
And then I didn't tweet about it.
It was, and if I recall the flavor, it was apricot.
Am I, am I correct in that?
It was, yes, apricot, as we say in Ireland.
I've discovered that I've been pronouncing all these words.
I was just corrected that it's definitely not Pascoal.
It's Pas-cal.
And I got called out on the last episode
for mispronouncing that.
And we had homemade apricot.
Is that apricot?
Apricot ice cream, yes.
Apricot ice cream.
And it was divine.
And that was, I think, the second time we met.
But yes, back to this bio.
It reads, in 1998, I joined, I'm'm gonna mess this one up glockenspiel no that was 1988 1988 if it's then it's maybe i wrote that
wrong or something but no no no i just have uh what do you call it not dyslexia there's a word
for it with numbers called uh what is it called? Dyscalcula.
Dyscalcula.
Ah, okay.
Who knows?
I just misread it.
Okay.
But Glockenspiel, yeah, I joined Glockenspiel in 1988.
I had two friends of mine were working there, and they recommended me to their boss.
And I had a 40-minute conversation with them and was hired. that was how people used to get hired in the old good old 40 minutes 40 minutes yeah how many leak code
questions in that 40 minutes you know how many how many linked lists did you have to reverse
i don't think any, actually. Wow.
But yeah, you worked there?
Yeah, I worked there for a few years.
And I wrote, yeah, that's where I learned C++.
And two of my fellow colleagues there,
they worked on the compiler on the C front,
which was the predecessor to an actual proper compiler. It would generate C front, which was, you know, the predecessor to an actual proper compiler.
It would generate C code,
which you'd then get a C compiler to compile to assembler or machine code.
But yeah, there was Martin O'Riordan,
who was the only member of the Irish,
from Ireland, who was on the standards committee
for many, many years.
And he helped to write the first,
Microsoft's first C++ compiler back in like 1990, 1991.
And John Caves, who I suspect Bryce has met John Caves.
Yes, I have.
He's still on the standards committee.
And he's still working for Microsoft.
And the two of them were in Glockenspiel at the time.
What a time and what a group of folks to get to work with.
It was a lot of fun.
And yeah, I mean, I worked on a GUI framework for it.
We wrote a library where you could create Windows programs
and also OS2 programs,
which is another operating system that has come and gone.
And I then got involved a lot in education so
i would i would go off and 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 I think, we had no standard library.
We had no string class.
There was a coroutines library that shipped with Seafront,
which was in, I think, the first edition of Strewstrup.
There's a chapter at the very back of the book that that describes how to use it and and that of course disappeared in the second edition and and later editions and finally we've
got back some kind of what 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
and famously or not famously,
but according to the bio,
you left the world of C++ for Java.
And then Ruby.
Although Ruby, I love Ruby.
Ruby is a lovely language.
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 was his name Mats?
Was a huge fan of Smalltalk.
And there's a bunch of stuff in Ruby that is basically completely borrowed
from the Smalltalk model.
So you did that for how many years, 10 to 15?
No, I did it for about six or seven
um and that was that was just ruby or it was just yeah it was ruby was i 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 uh wait wait i want to understand here you did that in Rwanda, which was great fun.
Wait, wait, wait.
I want to understand here.
You did that for the Rwanda market?
Or you did that while you went to Rwanda? I was in Rwanda for six weeks and I wrote this.
What happened was the company that we had connections to, 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 wait 14 14 1 4 yes wow and that's about
one one per what 800 000 or something like or something like that? Something like that, yes, exactly, exactly.
And the company had bought another 10 ATMs,
but those ATMs were not quite compatible with their server software.
And if they wanted to update their server,
they could get a module for their server software,
but that module would cost like 50 grand.
And they thought, nah, they'll get somebody like me
to do it for a few weeks.
I'll just write a little translation program
that sits in the middle on a little 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 it just goes all the way through it's passed through but there's a few type there'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
of 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 this is very true for for leak coding purposes sometimes
ruby is the best uh language for speed slash length because it has a ton of convenience methods
on strings like uh t o underscore i and like t o underscore b i believe and that one is super
useful because it's like uh to base and then
you provide the base or so yeah if you have like a string number it will actually maybe that's on
integers i can't remember the point is 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 going to 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 can be sometimes they they have odd names but once you
figure out what it's called uh they are very very nice to have yeah i think for me that the nicest
thing there was that you have slices in Ruby.
And so you can slice an array or slice a string
and you can give 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 closed square bracket. And that'll give you a close square and that 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 ruby is that if the string is only like 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,
you want four characters, it's only got two. Oh, sorry, I'm throwing an exception here.
So from that point of view, it was much simpler to do this in Ruby.
But doesn't Python have
slicing? Yeah, Python has that now too.
I'm not sure if they have the short-circuiting
only give you
what it has.
But I'm not sure. Maybe at the time
Python didn't.
I have to admit, I know
very little Python.
I can just about read it.
Yeah. The key thing is read it, but... Yeah.
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 was,
uh,
you were jumping through hoops to do like very simple things.
Um,
which is,
you know,
a,
a large inconvenience if,
if you're not used to having to do that.
Um,
even in C plus plus,
like dealing 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 remember like
java was i was like what i gotta go learn about a builder now like i just i just want to do
something real simple they're like well if you want to do something that involves mutability
then you're going to need a builder and i was like really yeah i think that went away in by by
java 5 or or Java 6 but anyway
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
I think no I think
I think we had a net
I think that we were going to have a netbook
per ATM okay okay
so is each is each atm in rwanda still still running this uh ruby code that you wrote i have
no idea but i suspect the answer is definitely no um i mean at at the time that they we had the best internet connection in rwanda and it was 360k baud so uh
that's not a lot for our younger listeners um and i know now that they have excellent uh internet
in the country from from talking to friends of mine who live there um so there yeah things 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 good battery life so you could survive survive power outages and the system would continue to work, which was also pretty important.
And the last point about the netbook was that like these were they cost, what, 200 bucks and they were they cost nothing.
But 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 therefore totally fine there was no speed constraints on the system
so what year was this this was 2010 yeah so that that's's pretty consistent. I just looked it up, and I don't know how accurate this data is,
but what is it, the Federal Reserve Economic Data website,
something like that, and it says that 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 going to 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 weishin or we they have a they have an app it was
the first i think it was the first um app in the world it was done by a kenyan company and they called it x so mpesa
mpesa is swahili for money i believe um yeah and a lot of banking happens on like cell phones
yeah exactly 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 m-peso was it wasn't even on the smartphone it was on the old like nokia and
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 want to send you type in um 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 um yeah 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 i don't think they had Raspberry Pis back then.
No Raspberry Pis back then, no.
But the battery thing, the battery thing is so clever.
Like, one, they're super cheap.
And two, like, you know, your little Raspberry Pi
or your edge computing device doesn't have a battery backup system built into it,
but a laptop does.
Yeah. Yeah, it was cheap and it worked um so yeah i love that i love that story but 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
he'd been somewhere traveling in maybe america or somewhere like that and the hotel had asked
to take 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 going to have credit cards for people or or electronic cards and that's why they they
this company was started um interesting yeah that is a what do you call it a uh fortunate or
unfortunate series of events that like you know leads to and so 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 oh okay so they actually had they had some then right
yeah but i mean it's if it's two i mean odds are there you know uh that you're going to find
yourself standing next to one when you need one is pretty astronomically low, the probability of that.
Yeah.
All right.
So you found your way back to C++ in, what did the bio say, 2016?
In 2016, I started reading stuff about it again and found that the language had totally changed from what I remembered.
I last wrote
c++ 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 what was your what was your you were, you know, your mind was, you know,
befuddled by move semantics, but from 2001 to 2016, that's, I guess, 11 and 14. What was like
the biggest, or I guess, how do you phrase the question? What was your favorite change? And like,
what was the biggest paradigm shift
from when you were coding?
Well, you had a standard library for a start.
That's not what I was expecting you to say.
But I guess that is a big deal.
Things we take for granted.
Yeah, I mean, we had strings.
We had vectors. Not very good ones, but they're still strings. We had vectors.
Not very good ones, but they're still strings.
Yeah.
I mean, exactly.
Vector's okay.
Yeah.
Vector, you had all these, you know, useful, you know, you have maps, hash maps and whatever.
It's fantastic.
And that's something that the old languages never had.
You know, Pascal, I don't think had...
No, it didn't have any standard.
It had standard output.
You could print stuff to files into the console, but that was it.
Interesting.
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.
Although Smalltalk had.
Smalltalk had, yes.
Smalltalk had a Smalltalk, yes. Smalltalk had a big library.
Absolutely.
And I guess Java is also a descendant of Smalltalk, you know, even though.
It's not really.
It's not really.
Kind of, yeah.
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 Java is.
I'm wondering.
I'm trying to remember Lisp,
which was my favorite language in college.
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, you've got the core,
and then everything else is kind of added on.
I feel like I've heard that Common Lisp famously also had massive amounts that like shipped with it.
And that was kind of both a pro and a con because Lisp is famous for being this very small, nuclear, homo-iconic, 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 shipped with a bunch of stuff but i've honestly never programmed a common list but
yeah i haven't either i used i used a lisp called franz lisp which had lots of puns. Franzlisp? F-R-A-N-S?
No, F-R-A-N-Z.
Franz, as in Franz Liszt, the composer.
It had lots of jokes about the 19th century composer.
Have you heard of Franz Liszt, Bryce?
No, it's got to be a pretty obscure language for Connor.
I 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 PicoLisp.
And I don't know, there's a bunch I have heard of.
There's one also called Dylan, I think, that was out of Microsoft.
Oh, that sounds later. That sounds a lot, I think, that was out of Microsoft. Oh, that sounds later.
That sounds a lot later.
Yeah, yeah.
That was the 90s.
But anyways, the whole point is like, you know, there's a whole world of LISPs out there.
People think of like there's the LISP LISP, there's Scheme and Racket, and then there's Closure.
But like behind the scenes, there's like 50 other LISPs that all vary in their language features and whatnot. The thing about lisp, you were saying it's homo-iconic,
which means data is program and program is data.
And I got interested there.
Well, I was interested a long time ago, but there was about quines.
Do you guys know what a quine is?
Yeah, yeah.
A quine is...
I've heard it before, but i don't remember aquine 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 aquine 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 i want recently well maybe the last three years about quines and how to write a quine
and it was i can't remember i think that the
i think the person who gave it was french i suspect they were
but i could be wrong we'll find uh well i'll do some searching yeah there's definitely a bunch
of talks out there there's there's a famous set of quines 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 their 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 100 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 is there
one of these that's simple enough that we could uh like talk through it right now on the podcast
just because like i'm i'm i'm trying to mentally imagine like how one of these works. The main problem is that you've got to handle quotation marks and emitting quotation marks.
Because basically what your quine is going to be, it's going to be like int main bracket bracket.
And then you're going to have like printf or std cout or whatever and a big long
string and the
problem with that is that you've got to handle
the extra
double quotes and
they get swallowed
so you have to produce them
and that's
where all the tricks come in
and you have to use
the circumventive interaction I understand the And that's where all the tricks come in. And you have to use a certain amount of interaction.
You understand the essence of what a coin is though, right, Bryce?
I understand the essence.
I would still like to see a simple one.
As I said, a guy did a lightning talk and he showed how to write a coin in about seven minutes.
It was in one of the c++ conferences
over the last few years all right folks 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. I, however, do. That's true.
I, however, do.
And I am at rosettacode.org slash wiki slash quine.
And I am not going to be able to count how many languages, but we're looking at roughly I'd estimate 200 or 300.
So I'm going to scroll and I'm just going to give you the guesses.
So 80, 80 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 is the language.
Is that a lisp? I've never heard of this. If I click on ACL2, it says ACL2 is the language. What is ACL2? Is that a lisp? Never heard of this.
If 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.
Ah, common lisp. You see, it's a lisp language. Ah, common lisp.
You see, it's a lisp language.
Yeah, okay.
A-C-L.
I'm jumping down to the bash one.
This is how my mind works.
Oh, look at that.
A-P-L.
Single line as well.
Unsurprisingly.
Connor is so pleased.
Now I'm going to read this out for the listener.
And it's going to sound like C++.
It's one rotate, ravel.
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 going to be the exact same thing. And the nine reshape is going to give you this,
this code twice, because you have one, two, three, four, 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 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 to reshape the shape of your string
if you specify more
it actually cycles
so in this it'll cycle
you know if you've got 1, 2, 3, 4
and you're trying to do a take 10
you'll end up with 1, 2, 3, 4, 1, 2, 3, 4, 1, 2
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 I'm not
sure if that made sense to the listener bryce have you made sense of the bash the bash yeah i've
looked at the c++ and the bash ones and the bash ones are not very helpful because they just cheat
and do awful things but i i hey there's no such thing as cheating when writing a quine the whole
point of a quine is that you just generate the source code that you initially wrote. That's the only rule.
There's no such thing as cheating.
Didn't we say
just a few minutes ago that you can't
read in the source file?
Correct. That's cheating.
Alright. I stand corrected.
And I'm fairly certain that
the first one of the bash examples here
is essentially... 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 oh and i just realized when i said ravel
in apl that was actually the monadic it was was the dyadic definition. So it would have been catenate. I want to see the make one.
This 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.
Low quality, high quantity.
That is the tagline of our podcast.
It's not the tagline.
Our tagline is chaos with sprinkles of information.