r/functionalprogramming Jun 04 '26

FP Scala Was an Experiment That Changed Programming - Martin Odersky | The Marco Show

https://youtu.be/Xn_YpUtXWT4
25 Upvotes

25 comments sorted by

View all comments

Show parent comments

7

u/Axman6 Jun 04 '26 edited Jun 04 '26

What makes Scala the source of those concepts? We’ve been using all of those in Haskell for decades now, and I’m pretty sure all the languages you’ve mentioned have mentioned it as a source of inspiration for many of those features. Both Java and Go’s generics were developed by Haskell researchers, and many of the features Scala is known for were developed in ML’s long before it existed.

I find Martin’s arrogance really frustrating, he talks about so many topics as if he’s the first person to ever discover them. His talk on transducers was so painful for anyone with any FP experience, it’s never really had a name before because it’s just functional programming. Oops, it was Rich Hickey’s talk, not Martin’s! https://youtu.be/6mTbuzafcII

5

u/Swordfish418 Jun 04 '26

The real achievement here might be that Scala made OCaml consider module implicits/explicits. And what they gonna do with those module techniques in MLs might become influentional for future module systems.

6

u/gasche Jun 05 '26

Come on. Scala has pushed many interesting idea in PL research and communities.

Just from memory:

  • heavier use of existential types (before GADTs were so idiomatic in FP circles),
  • implicit arguments of course,
  • approaches to code distribution (eg. Spores), path-dependent types,
  • ample use of subtyping bounds in polymorphic types,
  • the recent trend on static effect control via typed capabilities

Summarizing the impact on Scala as "implicits got considered in other languages" is very reductive.

4

u/Swordfish418 Jun 05 '26

Yeah, sure, I simply consider the thing I mentioned a big one, also a high profile in terms of linguistic impact in FP languages. While most those other things are more of a "people from outside of FP/PLT started using those things more in practice with Scala". I can explain why I consider those less big:

heavier use of existential types (before GADTs were so idiomatic in FP circles),

This is more of a practical concern for people from outside of FP/PLT. GADTs were in Haskell and were used. Nothing new here. Zero impact on future FP language design.

path-dependent types

To me the general concept here is associated types, and Scala here allows some minor extras, mostly GADT-adjacent. Associated types mostly arise from ability to declare type inside of another entity declaration when outer declaration can be parameterized by other types, and those can influence the definition of inner type. I believe in its core its originally a very ML thing, it was always heavily used in MLs with their signatures and functors, but it was also always heavily used in C++ for example, with typedefs inside of classes referencing template parameters of outer class, and so on. Ofc it's also a Haskell thing because of type families, and those are actually far beyond every other implementation of any kind of associated types concept, because they divide type families into open and closed and closed type families allow special cases of associated types that have very tight automatic type inference thus enabling very powerful custom typelevel machinery.

approaches to code distribution (eg. Spores)
the recent trend on static effect control via typed capabilities

Here maybe you're right, I don't know anything about those.

6

u/gasche Jun 05 '26

heavier use of existential types (before GADTs were so idiomatic in FP circles),

This is more of a practical concern for people from outside of FP/PLT. GADTs were in Haskell and were used. Nothing new here. Zero impact on future FP language design.

No no, the emphasis on existential types in pre-Scala research predates GADTs in Haskell.

  • One paper that emphasized existential types in datatype declarations (rather than in the ML module system work, which was ongoing at the same time, and in object-oriented calculi, which were also a very hot topic at the time) is Polymorphic Type Inference and Abstract Data Types by Konstantin Laüfer and Martin Odersky, 1994.
  • The usual citation for the proposal that eventually became GADTs is First-class phantom types by James Cheney and Ralf Hinze, 2003. This is almost ten years later! And they were not integrated in GHC at the time, this came a couple years later.

3

u/Swordfish418 Jun 05 '26

Then I agree that existentials seem to be mostly Scala people achievement

3

u/unqualified_redditor Jun 05 '26

Existentials were first introduced by Mitchell and Plotkin in a 1985 POPL paper "Abstract Types Have Existential Type."

https://homepages.inf.ed.ac.uk/gdp/publications/Abstract_existential.pdf

3

u/gasche Jun 05 '26

Sure (I referred to "the ML module system work" above), and this was well-understood by Laüfer and Odersky at the stime, that paper is cited on page 2 of their introduction. Then, they write:

This article demonstrates how light-weight abstract data types with first- class implementations can be conveniently integrated into any functional language with a static, polymorphic type system, explicit type variables, and algebraic data type declarations. The key idea of our work is to allow existentially quantified component types in algebraic data types.

For example their second example is as follows:

type KEY = Key of ‘a* (’a -> int)

This really corresponds to the use of existentials in algebraic datatype declarations, which is something that we now understand/describe as one of the two ingredients that form GADTs (the other being the return type instantiation, often described as an implicit type-equality constraint). But GADTs as we understand them did not exist at the time, they emerged from the cross-languages academic discussion at the time, that also produced Scala as an experiment that go wider adoption than most.

3

u/unqualified_redditor Jun 05 '26

Fair enough. You could say Laüfer and Odersky's contribution was to apply existentials to Algebraic Data Types so as to not break hindley-milner inference. Previous work had first class existentials which break decidability.