The Unreasonable Effectiveness of Multiple Dispatch | Stefan Karpinski | JuliaCon 2019
The Julia Programming Language9 HN recommenders · recommended in 6 months, 2019–2025
talk · intermediate · evergreen · 2019–2025 on HN
Julia co-creator Stefan Karpinski explains why multiple dispatch makes Julia code and types reusable across packages with so little friction. He covers sharing basic types and sharing generic algorithms.
HN commenters recommend it as the definitive explanation, from a language designer, of why multiple dispatch makes Julia's composability work.
Up next
16 mo on HNHow Python was Shaped by leaky Internals, Armin Ronacher, Flask framework
Видео с мероприятий {speach!
15 HN recommender · 2017–2025
3 mo on HNArmin Ronacher - A Python for Future Generations
EuroPython Conference
4 HN recommender · 2017–2020
8 mo on HNAnalogy as the Core of Cognition
Stanford
7 HN recommender · 2012–2025
3 mo on HN“What is Success?” by Evan Czaplicki
Elm Europe
2 HN recommender · 2018–2023
4 mo on HNSteve Jobs on privacy, Steve Jobs at the D8 Conference (Video)
iwasjojo
4 HN recommender · 2017–2024
3 mo on HNAli Rahimi's talk at NIPS(NIPS 2017 Test-of-time award presentation)
ObservantVids
3 HN recommender · 2018–2025
3 mo on HNMaking R run Fast - Jan Vitek
John O'Neill
3 HN recommender · 2017–2023
3 mo on HNShared memory parallelism in Julia | Kiran Pamnany | Cambridge Julia Meetup (May 2018)
The Julia Programming Language
4 HN recommender · 2018–2019
12 mo on HNWhy Isn't Functional Programming the Norm? – Richard Feldman
Metosin
12 HN recommender · 2019–2025
11 mo on HNMaybe Not - Rich Hickey
ClojureTV
14 HN recommender · 2018–2025
10 mo on HNConway's Game Of Life in APL
Dyalog
11 HN recommender · 2010–2024
9 mo on HNLecture 1A | MIT 6.001 Structure and Interpretation, 1986
MIT OpenCourseWare
11 HN recommender · 2012–2024
12 comments from Hacker News
Did you mean "unreasonable effectiveness"? :P I just watched that talk the other day, and boy is it insightful. Julia has cracked a fairly magical combination of features. I fully expect it to replace Python over the next 10 years. Direct link to "Unreasonable Effectiveness": ▶ this video
Julia's model is based around multimethods, which enables pretty crazy levels of interoperability (imagine being able to use scipy and tensorflow together, with tensorflow's autograd just magically working on most of scipy's functions). More about it here ▶ this video
Indeed, Julia's abstract type system with multiple dispatch is its killer feature. It enables generic programming in a beautiful and concise fashion. Here [1] Stefan Karpinski gives some explanations of why multiple dispatch is so effective. [1] ▶ this video
I like to watch talks by programming language designers. Some that readily come to mind are Rich Hickey, Joe Armstrong (RIP), and Stefan Karpinski. Some of my favorites are: - Simple Made Easy (Hickey): link - The Mess We're In (Armstrong): link - The Unreasonable Effectiveness of Multiple Dispatch (Karpinski): ▶ this video
The core problem with class-based object orientation is that methods go inside of the type instead of being added externally. That means everyone has to agree on what methods can be called on a class or they have to subtype it, which sounds harmless, but is actually a big problem when what you really wanted to do was just define a new method for an existing type. My best attempt at explaining: ▶ this video There's also the issue that one sometimes needs to specialize generic operations in generic algorithms on something other than the receiver—sometimes even on more than one of the arguments. Single dispatch forces you to use something slow and awkward like double dispatch in cases like this. And that's assuming the person who wrote the generic code anticipates the need for specialization! If they don't allow for it, then you're just stuck. With multiple dispatch, you can just define the method you need the specialization for and you're done.
What? I used to write python, and to me, MD is first and foremost a conceptual improvement. Makes writing code so much sweeter, more expressive and sensical. It also heavily improves composability. It's LESS performant if not done carefully. Certainly FastAI, Matt rocklin etc didn't reimplement a subset in python just to get slower code See ▶ this video
"The Unreasonable Effectiveness of X" is a reference to the well-known 'the unreasonable effectiveness of mathematics in the natural sciences'. It's turned into some sort of meme. Maybe you've seen 'the unreasonable effectiveness of recurrent neural networks' before. What you were referring to is a talk by a core developer at JuliaCon 2019 titled 'The unreasonable effectiveness of multiple dispatch' [1], which has less of a fanboy-vibe imho. Edit: Oh. I didn't notice the arstechnica article had this exact title. That's a bit cheap... [1] ▶ this video
You might also enjoy Stefan Karpinski’s talk at JuliaCon 2019 about how multiple dispatch helps make the language more expressive (than OOP, for Eg). The unreasonable effectiveness of multiple dispatch ▶ this video It seems like such an elegant idea, I’m somewhat surprised no one seems to have run with it earlier.
It's hard to say limited benefit when the entire Julia ecosystem evolved to so heavily rely on it, to allow for each package to work on it's own level of abstraction: For example, the Julia's standard library implements all of the basic math operators on the CPU, and libraries like Flux then define it's own methods to implement the higher level operators used in ML (such as convolutional layers and activation functions). And then someone writes those same basic math operators but instead of running on CPU they run on GPU, and for that they use a new type (CUArray). The original library knows nothing about CUArrays, it will call the same basic operators as always, but since they have a different type (received from the user) they'll dispatch to the GPU version. This kind of interaction can grow indefinitely, for example if you use a complex number type/library it will change the basic operators to deal with both real and imaginary parts, and if you use the GPU types within it, then it will do complex math in the GPU (and ML on complex math on GPU..., without any of the libraries being aware of the other). You can see a more detailed explanation on: ▶ this video
I remember the pitch for Julia early on being matlab-like syntax, C-like performance. When I've heard Julia mentioned more recently, the main feature that gets highlighted is multiple-dispatch. ▶ this video I think it seems pretty interesting.
Julia adds some pretty amazing stuff with multiple dispatch and run-time compilation. What this means is that you can glue code together in ways impossible for other languages. One example is a system that I built using three libraries. One was a C library from Postgres for geolocation, another was Uber's H3 library (also C) and a third was a Julia native library for geodesy. From Julia, I was able to extend the API of the H3 library and the Postgres library so that all three libraries would inter-operate transparently. This extension could be done without any mods to the packages I was important. Slightly similar, if you have a magic whizbang way of looking at your data as a strange form of matrix, you can simply implement a few optimized primitive matrix operations and the standard linear algebra libraries will now use your data structure. Normal languages can't really do that. More on that second case and the implications in the following video: ▶ this video
Yes. Its a side effect of multiple dispatch being the core paradigm of the language. See Stefan Karpinski's talk about it: ▶ this video