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

From Embedded to IaC: Exploring Scala’s Role Ac...

From Embedded to IaC: Exploring Scala’s Role Across Modern Applications

What makes Scala a suitable programming language across diverse application domains?

During this talk, we'll share the lessons we learned while using Scala in several production-ready systems: embedded and cloud-based applications, serverless computing and infrastructure as code (IaC).

For each case study, we'll highlight the key technical aspects to consider when choosing a language. For instance, we'll see how we addressed the challenges of resource-constrained embedded systems.

In cloud applications, we'll examine how Scala interacts with complex infrastructures. In the serverless space, we’ll discuss how native compilation helped us mitigate cold-start issues.

Finally, we’ll evaluate whether Scala can keep up with more specialized tools and languages in the realm of IaC. During our talk, we'll focus on how Scala impacts deployment efficiency and developer productivity.

Matteo Di Pirro

December 06, 2024
Tweet

More Decks by Matteo Di Pirro

Other Decks in Programming

Transcript

  1. ABOUT ME From Embedded to IaC FOR FUNCTIONAL SCALA 2024

    • Software engineer at Kynetics, Inc • DevOps + application software • Been writing Scala code for ~ 5 years
  2. SCALA IN THE INDUSTRY From Embedded to IaC FOR FUNCTIONAL

    SCALA 2024 • 30th position in the TIOBE index (Nov 2024) • 22nd position in the PYPL index (Nov 2024) • Not ranked in top-10 GitHub programming languages
  3. SCALA IN THE INDUSTRY From Embedded to IaC FOR FUNCTIONAL

    SCALA 2024 • 30th position in the TIOBE index (Nov 2024) • 22nd position in the PYPL index (Nov 2024) • Not ranked in top-10 GitHub programming languages And yet Scala stands out as the language the fewest programmers want to migrate from (*) (*) According to hps://www.jetbrains.com/lp/devecosystem-2023/languages/
  4. EMBEDDED SYSTEMS From Embedded to IaC FOR FUNCTIONAL SCALA 2024

    • Tight power/baery • Real-time constraints • Might not have Internet connection all the time • Hardware interaction • Native code invocation
  5. Native Code from Scala From Embedded to IaC FOR FUNCTIONAL

    SCALA 2024 • Java Native Interface ◦ Portability ◦ Project Complexity ◦ Distribution • Scala Native ◦ AOT Compiler + runtime ◦ Library compatibility ◦ Interoperability with C/C++ ◦ Production ready?? • Memory management
  6. CLOUD APPLICATIONS From Embedded to IaC FOR FUNCTIONAL SCALA 2024

    • Concurrency maers (a lot)! • Interaction with infrastructural dependencies ◦ Databases ◦ Other applications ◦ Cache/File system • Deployment ◦ Resiliency ◦ Scalability • Low memory footprint less important than in embedded systems
  7. From Embedded to IaC FOR FUNCTIONAL SCALA 2024 Scala in

    Cloud Applications • Wide availability of concurrency libraries • Integration of Java libraries ◦ With Scala wrappers • Reactive programming • Streaming reduces memory footprint ◦ Also requires careful design • “Easy” deployment through K8S and Docker ◦ Stateless vs Stateful • JIT as a Service
  8. SERVERLESS APPLICATIONS From Embedded to IaC FOR FUNCTIONAL SCALA 2024

    • Simplified deployment code (on paper!) • Stateless computing ◦ No need for infrastructure interaction • Batch processing • Pay per use ◦ Code needs to be spun up fast! • Cold start problem
  9. Cold Start From Embedded to IaC FOR FUNCTIONAL SCALA 2024

    Set-up time required to get a serverless application’s environment up and running when it is invoked for the first time within a defined period. Java 21 Java 21 GraalVM Rust Avg Cold Start 346.93 ms 115.40 ms 46.69 ms Avg Memory 93 MB 30.89 MB 16 MB Avg Duration 86.79 ms 14.94 ms 3.63 ms Source: hps://maxday.github.io/lambda-perf/, Docker image runtime, 128MB memory
  10. Scala in Serverless Applications From Embedded to IaC FOR FUNCTIONAL

    SCALA 2024 • Scala Native ◦ Very low memory footprint ◦ Production ready?? ◦ Library compatibility • GraalVM Native Image ◦ AOT instead of JIT ◦ Reduces start-up time… ◦ … But increases the run time!! ◦ Mature & Production-ready ◦ Slow compilation
  11. IaC From Embedded to IaC FOR FUNCTIONAL SCALA 2024 •

    IaC ≠ applicative code • Tests • Conciseness and readability • Apps and infrastructure usually hosted in dierent repos ◦ How to automate deployment?
  12. Scala for IaC From Embedded to IaC FOR FUNCTIONAL SCALA

    2024 • Using Java-based SDKs is a nightmare ◦ Verbosity ◦ Poor readability • Some idiomatic SDKs exist ◦ Besom for Pulumi ◦ Nothing for AWS CDK (Java supported) ◦ Nothing for Terraform CDK (Java supported) • Single team for app and platform • Build system
  13. The only way to learn a new programming language is

    by writing programs in it. Dennis Ritchie Matteo Di Pirro [email protected]