Upgrade to Pro — share decks privately, control downloads, hide ads and more …

State of Python support in Scala tooling

State of Python support in Scala tooling

Alexandre Archambault

November 04, 2022
Tweet

More Decks by Alexandre Archambault

Other Decks in Programming

Transcript

  1. PARIS 2022 Who am I? Alex Archambault • Doing Scala

    professionally since 2013 • Involved in Open Source Scala since 2014 • Author of coursier, Almond, now Scala CLI (with VirtusLab) • Also contributor of Ammonite, shapeless, …
  2. PARIS 2022 Why? What should be the future of Scala?

    • Python-like “general purpose programming language” ◦ What about direct interaction with Python from Scala?
  3. PARIS 2022 How? ScalaPy • Embed a Python interpreter in

    the JVM process (via libpython) • Provides a high-level Scala API for it • Handles JVM vs Python objects lifecycle • Allows to write typed wrappers for Python libs • Supports both JVM and Scala Native • See Shadaj Laddad talks on YouTube
  4. PARIS 2022 How? ScalaPy requirements • JVM: load libpython via

    JNA • Scala Native: linking with libpython • both: libpython around at runtime Relies on Kien Dang’s scalapy/python-native-libs
  5. PARIS 2022 Goal Just access ScalaPy’s py when you enable

    Python support --python OR //> using python py.Dynamic.global.list(1, 2)
  6. PARIS 2022 What we have: Scala CLI • run •

    package • repl • publish
  7. PARIS 2022 What we have: Ammonite • Jedi-based completion ◦

    all Kien Dang’s work (GSOC 2021) ◦ not merged upstream :|
  8. PARIS 2022 What we miss • IDE ◦ completions for

    scripts • Python packaging ◦ Python breaks reproducibility for now 😬 • What about Python to JVM? • py4j
  9. PARIS 2022 [Slide title] // For code, we recommend a

    monoscript font (eg. Fira Code) @tailrec def fixedPoint[A](f: A => A)(x0: A, limit: Int = 100): Option[A] = if (limit == 0) None else { val x = f(x0) if (x == x0) Some(x0) else fixedPoint(f)(x, limit - 1) }