sjwiesman commented on a change in pull request #508: URL: https://github.com/apache/flink-web/pull/508#discussion_r810273744
########## File path: _posts/2022-02-22-scala-free.md ########## @@ -0,0 +1,77 @@ +--- +layout: post +title: "Scala Free in One Fifteen" +date: 2022-02-22 00:00:00 +authors: +- sjwiesman: + name: "Seth Wiesman" + twitter: "sjwiesman" +excerpt: Apache Flink's runtime is now Scala free, allowing users to leverage any Scala version in their user code - including Scala 3! +--- + +Flink 1.15 is right around the corner, and among the many improvements is a Scala free classpath. +Users can now leverage the Java API from any Scala version, including Scala 3! + +<figure style="margin-left:auto;margin-right:auto;display:block;padding-top: 20px;padding-bottom:20px;width:75%;"> + <img src="{{ site.baseurl }}/img/blog/2022-02-22-scala-free/flink-scala-3.jpeg"> + <figcaption style="padding-top: 10px;text-align:center"><b>Fig.1</b> Flink 1.15 Scala 3 Example</figcaption> +</figure> + +This blog will discuss what has historically made supporting multiple Scala versions so complex, how we achieved this milestone, and the future of Scala in Apache Flink. + +{% toc %} + +## The Classpath and Scala + +If you have worked with a JVM-based application, you have probably heard the term classpath. +The classpath defines where the JVM will search for a given classfile when it needs to be loaded. +There may only be one instance of a classfile on each classpath, forcing any dependency Flink exposes onto users. +That is why the Flink community works hard to keep our classpath "clean" - or free of unnecessary dependencies. +We achieve this through a combination of [shaded dependencies](https://github.com/apache/flink-shaded), [child first class loading](https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/debugging/debugging_classloading/#inverted-class-loading-and-classloader-resolution-order), and a [plugins abstraction](https://nightlies.apache.org/flink/flink-docs-stable/docs/deployment/filesystems/plugins/) for optional components. + +The Apache Flink runtime is primarily written in Java but contains critical components that forced Scala on the default classpath. +And because Scala does not maintain binary compatibility across minor releases, this historically required cross-building components for all versions of Scala. +But due to many reasons - [breaking changes in the compiler](https://github.com/scala/scala/releases/tag/v2.12.8), [a new standard library](https://www.scala-lang.org/news/2.13.0), and [a reworked macro system](https://docs.scala-lang.org/scala3/guides/macros/macros.html) - this was easier said than done. + +## Hiding Scala + +As mentioned above, Flink uses Scala in a few key components; Mesos integration, the serialization stack, RPC, and the table planner. +Instead of removing these dependencies or finding ways to cross-build them, the community hid Scala. +It still exists in the codebase but no longer leaks into the user code classloader. + +In 1.14, we took our first steps in hiding Scala from our users. +In 1.14, we took our first steps in hiding Scala from our users. We dropped the support for Apache Mesos, partially implemented in Scala, which Kubernetes very much eclipsed in terms of adoption. Review comment: ```suggestion We dropped the support for Apache Mesos, partially implemented in Scala, which Kubernetes very much eclipsed in terms of adoption. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org