SlideShare a Scribd company logo
1 of 13
Download to read offline
Scala: a Cross-Platform Language
How to build applications that span in different platform
Gianluca Aguzzi gianluca.aguzzi@unibo.it
Dipartimento di Informatica – Scienza e Ingegneria (DISI)
Alma Mater Studiorum – Università di Bologna
Talk @ Paradigmi di Progettazione e Sviluppo
23/05/2022
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 1 / 12
Introduction
Contents
1 Introduction
2 Project Examples
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 2 / 12
Introduction
Cross-Platform Applications
Definition
A cross-platform software consists of an application designed to work in several
computing platform
Also referred to as platform agnostic, platform-independent & multi-platform
software
Java, per sè, could be considered as a multi-platform language (motto: write once,
run everywhere)
Modern perspective: the same language span over several runtime & VMs (e.g.
javascript, native platform, JVM, ...)
A multi-platform application could be polyglot
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 3 / 12
Introduction
Frameworks & Languages for Cross-Platform Development
Frameworks (UI oriented)
Flutter ®: an open-source framework by Google for multi-platform native apps
(starts for Android, iOS and Windows app, now support Linux, MacOS too)
Motto: Build app for any screen
Pretty recent (2017)
Xamarin ®: Extension of .NET framework (tools & libraries) for supporting apps
development
React Native: React Native brings React’s declarative UI framework to iOS and
Android
Motto: Learn once, write anywhere
Languages (Multi-platform)
Kotlin: supports several target runtime thanks to Kotlin multiplatform projects ®
Introduced with Kotlin 1.2 (alpha), in 1.4 becomes experimental (Still in alpha )
Support JS, JVM & Native platform (iOS, LLVM, Android, ...)
Scala (focus of today): targets different platforms using compiler & sbt plugins ®:
Scala.js ®: stable version to compile Scala in JS (born in 2014!!)
Scala native ®: alpha version to support native applications
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 4 / 12
Introduction
Scala Cross-Platform
Benefits
Shared code base: the application logic is shared among several targets avoiding
code duplication & error propagation
Full-stack oriented: using programming language that supports several targets
enable the possibility of enhancing the entire stack of an application (backend &
client) with the same language.
Access to libraries & SDK: multi-platform language could exploit libraries of a
specific platform that is not intended to be used in that language (e.g. Tensorflow
from Scala!!)
Use cases
Cross-platform library (e.g. Cats ®, Monix ®)
Web applications development (Scala.js)
Robotics & embeded systems (native)
Shared code for android & iOS app
NB! the use case "target code to scala code" is typically not considered
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 5 / 12
Introduction
How Scala Native & Scala.Js work 1
Compiler takes plain Scala code
Using a compiler plugin produces an intermediate representation (IR) that contain
platform-dependent aspects
Using IR the compiler processes optimization, linking, and dependency management.
1
Sébastien Jean R Doeraene. “Cross-Platform Language Design”. en. In: (2018). doi:
10.5075/EPFL-THESIS-8733. url: http://infoscience.epfl.ch/record/256862
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 6 / 12
Introduction
Caveats
In pure cross Scala projects, you can’t use the JVM ecosystem (e.g. Thread?)...
... unless you build ad-hoc facades ®
Several reimplemented APIs already exist ®
Javascript & native libraries can be used only in the corresponding runtime (in JVM
you still cannot use JS libraries)
For using native & JS libraries, you have to build ad-hoc facade (a là TypeScript
with typings) . . .
For Scala.js an ScalablyTyped ® aims deriving Scala typing starting from TypeScript
project
Application bundle size could be large since the code should include part runtime &
standard library
Scala.js bundle could easily reach ∼ 1 Mb for the output file.
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 7 / 12
Introduction
Scala.js & Scala native configuration: SBT is your friend! ®
Scalac does not natively produce JS & Native .class
You have to enable plugins via SBT configuration
project/plugins.sbt
addSbtPlugin(
"org.scala-js" % "sbt-scalajs" % "1.10.0"
)
// for native
addSbtPlugin(
"org.scala-native" % "sbt-scala-native" % "0.4.4"
)
build.sbt
enablePlugins(ScalaJSPlugin) // or ScalaNativePlugin
scalaVersion := "3.1.2"
// for JS
scalaJSUseMainModuleInitializer := true
... still single platform
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 8 / 12
Introduction
Multi Platform Setup ®
Another SBT plugin to configure multiple platform projects: sbt-crossproject ®
Enforce a project structure (configurable by different flavour)
CrossType.Pure: pure cross-platform project (e.g. libraries), all code is placed in /src
CrossType.Full: project with platform-specific code (e.g. UI)
shared: pure multi-platform code (e.g. data structure, interfaces, ...)
js and jvm and native: contain application platform-specific code (e.g. library usage,
GUI, ...)
project/plugins.sbt
val crossOrg = "org.portable-scala"
val crossNative = "sbt-scala-native-crossproject"
val crossJs = "sbt-scalajs-crossproject"
addSbtPlugin(crossOrg % crossJs % "1.1.0")
addSbtPlugin(crossOrg % crossNative % "1.1.0")
addSbtPlugin(
"org.scala-js" % "sbt-scalajs" % "1.10.0"
)
addSbtPlugin(
"org.scala-native" % "sbt-scala-native" % "0.4.4"
)
build.sbt
crossProject(JSPlatform, NativePlatform, JVMPlatform)
.crossType(CrossType.Full) // or CrossType.Pure
// common settings, use %%% for cross library
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % "3.2.12"
)
)
.jsSettings()
.nativeSettings()
.jvmSettings() // standard "scala" world
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 9 / 12
Project Examples
Contents
1 Introduction
2 Project Examples
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 10 / 12
Project Examples
Examples
Library Facade: Neataptic ®
You want to use a library that does not exist in the JVM ecosystem
You can use it unsafely (not recommended) or by creating a safe facade
Cross-target Application: Winnig Four ®
You have an application logic written in pure scala (born for JVM)
Then you want to share it in different platforms (e.g. Web, Android, ...)
1 Convert the project to a full cross-project
2 Maintain the core logic in the shared part
3 Create ad-hoc GUIs (or any specific platform code)
Full-Stack application: Todo Service ®
An application with a backend (JVM) and frontend (JS) part classic
Client-Server application
You have to maintain a shared part with data, services & interfaces, . . .
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 11 / 12
Scala: a Cross-Platform Language
How to build applications that span in different platform
Gianluca Aguzzi gianluca.aguzzi@unibo.it
Dipartimento di Informatica – Scienza e Ingegneria (DISI)
Alma Mater Studiorum – Università di Bologna
Talk @ Paradigmi di Progettazione e Sviluppo
23/05/2022
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 12 / 12
References
References I
[1] Sébastien Jean R Doeraene. “Cross-Platform Language Design”. en. In: (2018). doi:
10.5075/EPFL-THESIS-8733. url:
http://infoscience.epfl.ch/record/256862.
[2] Kotlin Multiplatform | Kotlin.
https://kotlinlang.org/docs/multiplatform.html. (Accessed on
05/22/2022).
[3] React Native · Learn once, write anywhere. https://reactnative.dev/. (Accessed
on 05/22/2022).
[4] Scala Native — Scala Native 0.4.5-SNAPSHOT documentation.
https://scala-native.readthedocs.io/en/latest/. (Accessed on
05/22/2022).
[5] Scala.js. https://www.scala-js.org/. (Accessed on 05/22/2022).
[6] Showcase - Flutter apps in production. https://flutter.dev/showcase.
(Accessed on 05/22/2022).
Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022

More Related Content

Similar to Scala: a Cross-Platform Language

Glympse API Cross Compiling
Glympse API Cross CompilingGlympse API Cross Compiling
Glympse API Cross CompilingEgor Pushkin
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to javaKalai Selvi
 
Using OSGi technology in Eclipse - BJ Hargrave, IBM, for Jeff McAffer, IBM
Using OSGi technology in Eclipse - BJ Hargrave, IBM, for Jeff McAffer, IBMUsing OSGi technology in Eclipse - BJ Hargrave, IBM, for Jeff McAffer, IBM
Using OSGi technology in Eclipse - BJ Hargrave, IBM, for Jeff McAffer, IBMmfrancis
 
Minko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko3D
 
SOFIA Poster (Abstract) - ADK VLHCC 2010. INDRA/ESI
SOFIA Poster (Abstract) - ADK VLHCC 2010. INDRA/ESISOFIA Poster (Abstract) - ADK VLHCC 2010. INDRA/ESI
SOFIA Poster (Abstract) - ADK VLHCC 2010. INDRA/ESISofia Eu
 
Three's Company - Writing for the Desktop, Browser, and Phone
Three's Company - Writing for the Desktop, Browser, and PhoneThree's Company - Writing for the Desktop, Browser, and Phone
Three's Company - Writing for the Desktop, Browser, and PhoneSarah Dutkiewicz
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word documentSIVAJISADHANA
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word documentSIVAJISADHANA
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word documentSIVAJISADHANA
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unitgowher172236
 
Lessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its EcosystemLessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its EcosystemPetr Hošek
 
Vb.net basics 1(vb,net--3 year)
Vb.net basics 1(vb,net--3 year)Vb.net basics 1(vb,net--3 year)
Vb.net basics 1(vb,net--3 year)Ankit Gupta
 
Realizing the promise of portable data processing with Apache Beam
Realizing the promise of portable data processing with Apache BeamRealizing the promise of portable data processing with Apache Beam
Realizing the promise of portable data processing with Apache BeamDataWorks Summit
 
Eclipsist2009 Rich Client Roundup
Eclipsist2009 Rich Client RoundupEclipsist2009 Rich Client Roundup
Eclipsist2009 Rich Client RoundupMurat Yener
 
Intoduction to java
Intoduction to javaIntoduction to java
Intoduction to javajalinder123
 

Similar to Scala: a Cross-Platform Language (20)

Glympse API Cross Compiling
Glympse API Cross CompilingGlympse API Cross Compiling
Glympse API Cross Compiling
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
 
Using OSGi technology in Eclipse - BJ Hargrave, IBM, for Jeff McAffer, IBM
Using OSGi technology in Eclipse - BJ Hargrave, IBM, for Jeff McAffer, IBMUsing OSGi technology in Eclipse - BJ Hargrave, IBM, for Jeff McAffer, IBM
Using OSGi technology in Eclipse - BJ Hargrave, IBM, for Jeff McAffer, IBM
 
Java for C++ programers
Java for C++ programersJava for C++ programers
Java for C++ programers
 
Minko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSL
 
SOFIA Poster (Abstract) - ADK VLHCC 2010. INDRA/ESI
SOFIA Poster (Abstract) - ADK VLHCC 2010. INDRA/ESISOFIA Poster (Abstract) - ADK VLHCC 2010. INDRA/ESI
SOFIA Poster (Abstract) - ADK VLHCC 2010. INDRA/ESI
 
Three's Company - Writing for the Desktop, Browser, and Phone
Three's Company - Writing for the Desktop, Browser, and PhoneThree's Company - Writing for the Desktop, Browser, and Phone
Three's Company - Writing for the Desktop, Browser, and Phone
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
 
Lessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its EcosystemLessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its Ecosystem
 
JAVA First Day
JAVA First DayJAVA First Day
JAVA First Day
 
Vb.net basics 1(vb,net--3 year)
Vb.net basics 1(vb,net--3 year)Vb.net basics 1(vb,net--3 year)
Vb.net basics 1(vb,net--3 year)
 
Webhouse
WebhouseWebhouse
Webhouse
 
Realizing the promise of portable data processing with Apache Beam
Realizing the promise of portable data processing with Apache BeamRealizing the promise of portable data processing with Apache Beam
Realizing the promise of portable data processing with Apache Beam
 
Analysis
AnalysisAnalysis
Analysis
 
Eclipsist2009 Rich Client Roundup
Eclipsist2009 Rich Client RoundupEclipsist2009 Rich Client Roundup
Eclipsist2009 Rich Client Roundup
 
Intoduction to java
Intoduction to javaIntoduction to java
Intoduction to java
 

More from Gianluca Aguzzi

Scala(e) to the large. Concurrent programming in Scala and relevant Frameworks
Scala(e) to the large. Concurrent programming in Scala and relevant FrameworksScala(e) to the large. Concurrent programming in Scala and relevant Frameworks
Scala(e) to the large. Concurrent programming in Scala and relevant FrameworksGianluca Aguzzi
 
Towards Reinforcement Learning-based Aggregate Computing
Towards Reinforcement Learning-based Aggregate ComputingTowards Reinforcement Learning-based Aggregate Computing
Towards Reinforcement Learning-based Aggregate ComputingGianluca Aguzzi
 
On Collective Reinforcement Learning
On Collective Reinforcement LearningOn Collective Reinforcement Learning
On Collective Reinforcement LearningGianluca Aguzzi
 
ScaFi-Web, A Web-Based application for Field-based Coordination
ScaFi-Web, A Web-Based application for Field-based CoordinationScaFi-Web, A Web-Based application for Field-based Coordination
ScaFi-Web, A Web-Based application for Field-based CoordinationGianluca Aguzzi
 
eCAS 2021: Towards Pulverised Architectures for Collective Adaptive Systems t...
eCAS 2021: Towards Pulverised Architectures for Collective Adaptive Systems t...eCAS 2021: Towards Pulverised Architectures for Collective Adaptive Systems t...
eCAS 2021: Towards Pulverised Architectures for Collective Adaptive Systems t...Gianluca Aguzzi
 
Doctoral Symposium ACSOS 2021: Research directions for Aggregate Computing wi...
Doctoral Symposium ACSOS 2021: Research directions for Aggregate Computing wi...Doctoral Symposium ACSOS 2021: Research directions for Aggregate Computing wi...
Doctoral Symposium ACSOS 2021: Research directions for Aggregate Computing wi...Gianluca Aguzzi
 

More from Gianluca Aguzzi (7)

Scala(e) to the large. Concurrent programming in Scala and relevant Frameworks
Scala(e) to the large. Concurrent programming in Scala and relevant FrameworksScala(e) to the large. Concurrent programming in Scala and relevant Frameworks
Scala(e) to the large. Concurrent programming in Scala and relevant Frameworks
 
Towards Reinforcement Learning-based Aggregate Computing
Towards Reinforcement Learning-based Aggregate ComputingTowards Reinforcement Learning-based Aggregate Computing
Towards Reinforcement Learning-based Aggregate Computing
 
On Collective Reinforcement Learning
On Collective Reinforcement LearningOn Collective Reinforcement Learning
On Collective Reinforcement Learning
 
ScaFi-Web, A Web-Based application for Field-based Coordination
ScaFi-Web, A Web-Based application for Field-based CoordinationScaFi-Web, A Web-Based application for Field-based Coordination
ScaFi-Web, A Web-Based application for Field-based Coordination
 
MVC meets Monad
MVC meets MonadMVC meets Monad
MVC meets Monad
 
eCAS 2021: Towards Pulverised Architectures for Collective Adaptive Systems t...
eCAS 2021: Towards Pulverised Architectures for Collective Adaptive Systems t...eCAS 2021: Towards Pulverised Architectures for Collective Adaptive Systems t...
eCAS 2021: Towards Pulverised Architectures for Collective Adaptive Systems t...
 
Doctoral Symposium ACSOS 2021: Research directions for Aggregate Computing wi...
Doctoral Symposium ACSOS 2021: Research directions for Aggregate Computing wi...Doctoral Symposium ACSOS 2021: Research directions for Aggregate Computing wi...
Doctoral Symposium ACSOS 2021: Research directions for Aggregate Computing wi...
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

Scala: a Cross-Platform Language

  • 1. Scala: a Cross-Platform Language How to build applications that span in different platform Gianluca Aguzzi gianluca.aguzzi@unibo.it Dipartimento di Informatica – Scienza e Ingegneria (DISI) Alma Mater Studiorum – Università di Bologna Talk @ Paradigmi di Progettazione e Sviluppo 23/05/2022 Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 1 / 12
  • 2. Introduction Contents 1 Introduction 2 Project Examples Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 2 / 12
  • 3. Introduction Cross-Platform Applications Definition A cross-platform software consists of an application designed to work in several computing platform Also referred to as platform agnostic, platform-independent & multi-platform software Java, per sè, could be considered as a multi-platform language (motto: write once, run everywhere) Modern perspective: the same language span over several runtime & VMs (e.g. javascript, native platform, JVM, ...) A multi-platform application could be polyglot Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 3 / 12
  • 4. Introduction Frameworks & Languages for Cross-Platform Development Frameworks (UI oriented) Flutter ®: an open-source framework by Google for multi-platform native apps (starts for Android, iOS and Windows app, now support Linux, MacOS too) Motto: Build app for any screen Pretty recent (2017) Xamarin ®: Extension of .NET framework (tools & libraries) for supporting apps development React Native: React Native brings React’s declarative UI framework to iOS and Android Motto: Learn once, write anywhere Languages (Multi-platform) Kotlin: supports several target runtime thanks to Kotlin multiplatform projects ® Introduced with Kotlin 1.2 (alpha), in 1.4 becomes experimental (Still in alpha ) Support JS, JVM & Native platform (iOS, LLVM, Android, ...) Scala (focus of today): targets different platforms using compiler & sbt plugins ®: Scala.js ®: stable version to compile Scala in JS (born in 2014!!) Scala native ®: alpha version to support native applications Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 4 / 12
  • 5. Introduction Scala Cross-Platform Benefits Shared code base: the application logic is shared among several targets avoiding code duplication & error propagation Full-stack oriented: using programming language that supports several targets enable the possibility of enhancing the entire stack of an application (backend & client) with the same language. Access to libraries & SDK: multi-platform language could exploit libraries of a specific platform that is not intended to be used in that language (e.g. Tensorflow from Scala!!) Use cases Cross-platform library (e.g. Cats ®, Monix ®) Web applications development (Scala.js) Robotics & embeded systems (native) Shared code for android & iOS app NB! the use case "target code to scala code" is typically not considered Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 5 / 12
  • 6. Introduction How Scala Native & Scala.Js work 1 Compiler takes plain Scala code Using a compiler plugin produces an intermediate representation (IR) that contain platform-dependent aspects Using IR the compiler processes optimization, linking, and dependency management. 1 Sébastien Jean R Doeraene. “Cross-Platform Language Design”. en. In: (2018). doi: 10.5075/EPFL-THESIS-8733. url: http://infoscience.epfl.ch/record/256862 Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 6 / 12
  • 7. Introduction Caveats In pure cross Scala projects, you can’t use the JVM ecosystem (e.g. Thread?)... ... unless you build ad-hoc facades ® Several reimplemented APIs already exist ® Javascript & native libraries can be used only in the corresponding runtime (in JVM you still cannot use JS libraries) For using native & JS libraries, you have to build ad-hoc facade (a là TypeScript with typings) . . . For Scala.js an ScalablyTyped ® aims deriving Scala typing starting from TypeScript project Application bundle size could be large since the code should include part runtime & standard library Scala.js bundle could easily reach ∼ 1 Mb for the output file. Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 7 / 12
  • 8. Introduction Scala.js & Scala native configuration: SBT is your friend! ® Scalac does not natively produce JS & Native .class You have to enable plugins via SBT configuration project/plugins.sbt addSbtPlugin( "org.scala-js" % "sbt-scalajs" % "1.10.0" ) // for native addSbtPlugin( "org.scala-native" % "sbt-scala-native" % "0.4.4" ) build.sbt enablePlugins(ScalaJSPlugin) // or ScalaNativePlugin scalaVersion := "3.1.2" // for JS scalaJSUseMainModuleInitializer := true ... still single platform Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 8 / 12
  • 9. Introduction Multi Platform Setup ® Another SBT plugin to configure multiple platform projects: sbt-crossproject ® Enforce a project structure (configurable by different flavour) CrossType.Pure: pure cross-platform project (e.g. libraries), all code is placed in /src CrossType.Full: project with platform-specific code (e.g. UI) shared: pure multi-platform code (e.g. data structure, interfaces, ...) js and jvm and native: contain application platform-specific code (e.g. library usage, GUI, ...) project/plugins.sbt val crossOrg = "org.portable-scala" val crossNative = "sbt-scala-native-crossproject" val crossJs = "sbt-scalajs-crossproject" addSbtPlugin(crossOrg % crossJs % "1.1.0") addSbtPlugin(crossOrg % crossNative % "1.1.0") addSbtPlugin( "org.scala-js" % "sbt-scalajs" % "1.10.0" ) addSbtPlugin( "org.scala-native" % "sbt-scala-native" % "0.4.4" ) build.sbt crossProject(JSPlatform, NativePlatform, JVMPlatform) .crossType(CrossType.Full) // or CrossType.Pure // common settings, use %%% for cross library .settings( libraryDependencies ++= Seq( "org.scalatest" %%% "scalatest" % "3.2.12" ) ) .jsSettings() .nativeSettings() .jvmSettings() // standard "scala" world Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 9 / 12
  • 10. Project Examples Contents 1 Introduction 2 Project Examples Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 10 / 12
  • 11. Project Examples Examples Library Facade: Neataptic ® You want to use a library that does not exist in the JVM ecosystem You can use it unsafely (not recommended) or by creating a safe facade Cross-target Application: Winnig Four ® You have an application logic written in pure scala (born for JVM) Then you want to share it in different platforms (e.g. Web, Android, ...) 1 Convert the project to a full cross-project 2 Maintain the core logic in the shared part 3 Create ad-hoc GUIs (or any specific platform code) Full-Stack application: Todo Service ® An application with a backend (JVM) and frontend (JS) part classic Client-Server application You have to maintain a shared part with data, services & interfaces, . . . Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 11 / 12
  • 12. Scala: a Cross-Platform Language How to build applications that span in different platform Gianluca Aguzzi gianluca.aguzzi@unibo.it Dipartimento di Informatica – Scienza e Ingegneria (DISI) Alma Mater Studiorum – Università di Bologna Talk @ Paradigmi di Progettazione e Sviluppo 23/05/2022 Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022 12 / 12
  • 13. References References I [1] Sébastien Jean R Doeraene. “Cross-Platform Language Design”. en. In: (2018). doi: 10.5075/EPFL-THESIS-8733. url: http://infoscience.epfl.ch/record/256862. [2] Kotlin Multiplatform | Kotlin. https://kotlinlang.org/docs/multiplatform.html. (Accessed on 05/22/2022). [3] React Native · Learn once, write anywhere. https://reactnative.dev/. (Accessed on 05/22/2022). [4] Scala Native — Scala Native 0.4.5-SNAPSHOT documentation. https://scala-native.readthedocs.io/en/latest/. (Accessed on 05/22/2022). [5] Scala.js. https://www.scala-js.org/. (Accessed on 05/22/2022). [6] Showcase - Flutter apps in production. https://flutter.dev/showcase. (Accessed on 05/22/2022). Aguzzi (DISI, Univ. Bologna) Scala: a Cross-Platform Language 23/05/2022