Transcript
Miles Sabin (0:00)
I basically submitted a talk proposal for FP Exchange. So I put in a talk proposal which was how we need a scrape in Scala with the idea of forcing myself to actually sit down and work out how to make this thing work. Otherwise I was going to be extremely embarrassed, not least because the keynote speaker, so someone who was actually going to be in the audience, was going to be Simon Peyton Jones. So I was going to have to come up with something at least moderately, moderately convincing to be able to get that past him.
Interviewer (0:31)
When Miles Sabin applied to speak at a conference on generic programming, he bluffed a little bit. He would present on porting Simon Peyton Jones's scrap your boilerplate functionality to Scala. Once his talk was accepted, he only had one thing left to implement the solution. Generic programming is the type of polymorphism your language does not directly support. To me, this definition seems paradoxical, as once you implement a solution, the language, or at least a library within the language, can now support it. This recursive definition and a speaking deadline led Miles to create Shapeless. Years later, he's still pushing the bounds on what you can do in Scala, including recently getting support for literal types added to the Scala C compiler. So Miles, in some point around 2014, I was writing some Scala and I had to write a function that grouped a tuple. So I had like a tuple with two values and I needed to kind of turn it into a. Sorry, I had a list of tuples and I needed to kind of group it by the first element into a map. And so I wrote that out and then a week later I have to write something that takes like a three element tuple and does the same thing, takes the first element and kind of groups the second elements into a map based on that value. And then I had the thought at that time, like I should be able to write something generic over this. And it's at this point that I learned about generic programming and shapeless. I don't think I ever got the generic version done, but it did take me on a path to learn about shapeless and generic programming. So what is generic programming?
Miles Sabin (2:20)
That's a big question. So for quite a few years now there has been a satellite workshop of icfp, the International Conference on Functional Programming, which is kind of the main sort of academic stroke industry sort of functional programming conference annually. And this, this workshop title has been the Workshop on Generic Programming wgp. And I guess I've been going to that sort of at least as regularly as I've been going to icfp. And a few years Ago, the workshop chair sort of had a sort of a kickoff session and I was always trying to sort of bat around ideas. I think a few years ago, generic programming was perhaps less visible outside academia than maybe it is now. And one of the things he wants to do was, you know, what's the sort of the elevator pitch for generic programming that we could sort of use to make it sort of more accessible, more visible to people kind of outside the academic community that was mainly involved with it at the time. And there were lots of various different kinds of ideas. But the sort of the catchy one liner that the group in the workshop came up with at the end was something along the lines of generic programming is kinds of polymorphism that your programming language doesn't support yet. Which I think, which I think is kind of nice. It really is about ways of abstracting which are perhaps richer than we're used to in the context of standard parametric polymorphism or subtype polymorphism in language like Scala, which has both. It's an idea of being able to abstract over shapes of data more generally than you typically find it easily expressed or represented. There are, there are lots of sort of gray fuzzy areas. Where does the kind of polymorphism that people typically tend to talk about in terms of generic programming, where does it begin, where does it end? What are the kinds of things that are included and what aren't? And it really isn't particularly clear, I think, as sort of type systems that people are get used to working with become richer and richer and more expressive. I think in some respects generic programming is a sort of separate, independent kind of discipline is likely to sort of disappear, be submerged into the general sort of discipline of programming the types. But at the moment, I think the way you would tend to characterize it as it's having a. It's programming which depends on having a representation of the shape of data in some very general sense of what the shape of a data type values of a data type might be. Being able to abstract over those shapes in ways that allow you to perform a variety of interesting operations on data independently of the particular shapes that it comes packaged into.
