- Scala originated from Martin Odersky's work on functional programming languages like OCaml in the 1980s and 1990s. It was designed to combine object-oriented and functional programming in a practical way.
- Key aspects of Scala include being statically typed while also being flexible, its unified object and module system, and treating libraries as primary over language features.
- Scala has grown into an large ecosystem centered around the JVM and also targets JavaScript via Scala.js. Tooling continues to improve with faster compilers and new IDE support.
- Future work includes establishing TASTY as a portable intermediate representation, connecting Scala to formal foundations through the DOT calculus, and exploring new type
This was a short introduction to Scala programming language.
me and my colleague lectured these slides in Programming Language Design and Implementation course in K.N. Toosi University of Technology.
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLabCloudxLab
Scala is a modern multi-paradigm programming language that integrates features of object-oriented and functional programming. It is statically typed, has a lightweight syntax, and compiles to Java bytecode so it can use Java libraries. Scala source code is compiled to Java bytecode using the Scala compiler and runs on the Java Virtual Machine. Common data structures in Scala include collections like lists, arrays, sets and maps. Scala supports higher-order functions, immutable data, pattern matching and case classes. Build tools like SBT are used to manage Scala projects.
Scala - The Simple Parts, SFScala presentationMartin Odersky
These are the slides of the talk I gave on May 22, 2014 to the San Francisco Scala user group. Similar talks were given before at GOTO Chicago, keynote, at Gilt Groupe and Hunter College in New York, at JAX Mainz and at FlatMap Oslo.
The document summarizes Martin Odersky's talk at Scala Days 2016 about the road ahead for Scala. The key points are:
1. Scala is maturing with improvements to tools like IDEs and build tools in 2015, while 2016 sees increased activity with the Scala Center, Scala 2.12 release, and rethinking Scala libraries.
2. The Scala Center was formed to undertake projects benefiting the Scala community with support from various companies.
3. Scala 2.12 focuses on optimizing for Java 8 and includes many new features. Future releases will focus on improving Scala libraries and modularization.
4. The DOT calculus provides a formal
This document provides an agenda and overview for a Spark workshop covering Spark basics and streaming. The agenda includes sections on Scala, Spark, Spark SQL, and Spark Streaming. It discusses Scala concepts like vals, vars, defs, classes, objects, and pattern matching. It also covers Spark RDDs, transformations, actions, sources, and the spark-shell. Finally, it briefly introduces Spark concepts like broadcast variables, accumulators, and spark-submit.
Scala is a modern programming language created by Martin Odersky that provides static typing and supports both object-oriented and functional programming paradigms. It compiles to Java bytecode and runs on the Java Virtual Machine (JVM), allowing it to interoperate with Java. Many consider Scala to be a better alternative to Java due to its concise and expressive syntax. Scala sees widespread use in production systems and has growing job opportunities for developers with Scala skills.
The document discusses Scala, a programming language designed to be scalable. It can be used for both small and large programs. Scala combines object-oriented and functional programming. It interoperates seamlessly with Java but allows developers to add new constructs like actors through libraries. The Scala community is growing, with industrial adoption starting at companies like Twitter.
A presentation at Twitter's official developer conference, Chirp, about why we use the Scala programming language and how we build services in it. Provides a tour of a number of libraries and tools, both developed at Twitter and otherwise.
This document provides an overview of a 30-minute Scala tutorial covering Scala's core features like case classes, pattern matching, implicit classes, higher-order functions, and the Option monad. Scala is designed for concise syntax compared to Java, supports both object-oriented and functional programming, and is statically typed on the JVM. The tutorial demonstrates Scala concepts like implicit classes extending functionality, pattern matching for control flow, and using the Option monad to avoid null checks when chaining method calls.
Weaving Dataflows with Silk - ScalaMatsuri 2014, TokyoTaro L. Saito
Silk is a framework for building dataflows in Scala. In Silk users write data processing code with collection operators (e.g., map, filter, reduce, join, etc.). Silk uses Scala Macros to construct a DAG of dataflows, nodes of which are annotated with variable names in the program. By using these variable names as markers in the DAG, Silk can support interruption and resume of dataflows and querying the intermediate data. By separating dataflow descriptions from its computation, Silk enables us to switch executors, called weavers, for in-memory or cluster computing without modifying the code. In this talk, we will show how Silk helps you run data-processing pipelines as you write the code.
Spark schema for free with David SzakallasDatabricks
DataFrames are essential for high-performance code, but sadly lag behind in development experience in Scala. When we started migrating our existing Spark application from RDDs to DataFrames at Whitepages, we had to scratch our heads real hard to come up with a good solution. DataFrames come at a loss of compile-time type safety and there is limited support for encoding JVM types.
We wanted more descriptive types without the overhead of Dataset operations. The data binding API should be extendable. Schema for input files should be generated from classes when we don’t want inference. UDFs should be more type-safe. Spark does not provide these natively, but with the help of shapeless and type-level programming we found a solution to nearly all of our wishes. We migrated the RDD code without any of the following: changing our domain entities, writing schema description or breaking binary compatibility with our existing formats. Instead we derived schema, data binding and UDFs, and tried to sacrifice the least amount of type safety while still enjoying the performance of DataFrames.
There are many programming languages that can be used on the JVM (Java, Scala, Groovy, Kotlin, ...). In this session, we'll outline the main differences between them and discuss advantages and disadvantages for each.
Scala, Akka, and Play: An Introduction on HerokuHavoc Pennington
The document introduces Scala, Akka, and Play and discusses how they can be used together on Heroku. Scala is presented as a practical alternative to Java that allows incremental migration while providing functional programming capabilities. Akka implements the actor model to provide highly scalable and fault-tolerant architectures. Play is introduced as a popular web framework that uses convention over configuration. The document argues that using these technologies together enables developer-friendly, horizontally scalable applications with a pragmatic adoption path. It provides overviews and examples of each technology.
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介scalaconfjp
SparkSQL is a Spark component that allows SQL queries to be executed on Spark. It uses Catalyst, which provides an execution planning framework for relational operations like SQL parsing, logical optimization, and physical planning. Catalyst defines logical and physical operators, expressions, data types and provides rule-based optimizations to transform query plans. The SQL core in SparkSQL builds SchemaRDDs to represent queries and allows reading/writing to Parquet and JSON formats.
An Introduction to Higher Order Functions in Spark SQL with Herman van HovellDatabricks
Nested data types offer Apache Spark users powerful ways to manipulate structured data. In particular, they allow you to put complex objects like arrays, maps and structures inside of columns. This can help you model your data in a more natural way.
While this feature is certainly useful, it can quite bit cumbersome to manipulate data inside of complex objects because SQL (and Spark) do not have primitives for working with such data. In addition, it is time-consuming, non-performant, and non-trivial. During this talk we will discuss some of the commonly used techniques for working with complex objects, and we will introduce new ones based on Higher-order functions. Higher-order functions will be part of Spark 2.4 and are a simple and performant extension to SQL that allow a user to manipulate complex data such as arrays.
This document discusses the key building blocks that enable Scala to be a modular and growable language. It outlines seven simple parts of the Scala language itself that can be combined in flexible ways, including expressions, scopes, patterns, recursion, function values, collections, and vars. It also lists seven features of Scala's type system that support modular programming, such as static typing, objects, classes, traits, abstract types, parameterized types, and implicit parameters. The document argues that this combination of simple language parts and powerful type features allows Scala programs and libraries to be composed modularly and to grow in complexity in a manageable way.
Spark - The Ultimate Scala Collections by Martin OderskySpark Summit
Spark is a domain-specific language for working with collections that is implemented in Scala and runs on a cluster. While similar to Scala collections, Spark differs in that it is lazy and supports additional functionality for paired data. Scala can learn from Spark by adding views to make laziness clearer, caching for persistence, and pairwise operations. Types are important for Spark as they prevent logic errors and help with programming complex functional operations across a cluster.
This document provides an introduction and overview of the Scala programming language. It begins with a brief history of Scala's creation at EPFL by Martin Odersky in 2001. It then discusses some of the key reasons for using Scala, including its ability to scale with demands through a combination of object-oriented and functional programming concepts. The document outlines some of Scala's main features, such as its static typing, interoperability with Java, and support for modularity. It also provides examples of Scala's data types, operations, control structures, functions, and pattern matching capabilities. Overall, the summary provides a high-level introduction to Scala's origins, design philosophy, and programming paradigms.
Scala Next focused on the continued adoption and development of Scala. Key points included:
- Scala adoption has grown significantly in areas like web platforms, trading platforms, and financial modeling. The number of Scala jobs tripled in the last year.
- Recent Scala versions like 2.8 and 2.9 included improvements to collections, implicits, and tooling support.
- Scala 2.10 will focus on new reflection capabilities, reification, string interpolation, and continued IDE improvements.
- The Play Framework 2.0 will provide a Scala-centric web framework built on top of Akka and the Typesafe Stack.
Martin Odersky discusses the past, present, and future of Scala over the past 5 years and next 5 years. Key points include:
- Scala has grown significantly in usage and community over the past 6 years since its first release.
- Scala 2.8 will include improvements like new collections, package objects, named/default parameters, and better tool support.
- Over the next 5 years, Scala will focus on improving concurrency and parallelism through better abstractions, analyses, and static typing support.
Martin Odersky outlines the growth and adoption of Scala over the past 6 years and discusses Scala's future direction over the next 5 years. Key points include:
- Scala has grown from its first classroom use in 2003 to filling a full day of talks at JavaOne in 2009 and developing a large user community.
- Scala 2.8 will include new collections, package objects, named/default parameters, and improved tool support.
- Over the next 5 years, Scala will focus on concurrency and parallelism features at all levels from primitives to tools.
- Other areas of focus include extended libraries, performance improvements, and standardized compiler plugin architecture.
Scala 2.8 will include improvements to collections, package objects, named and default parameters, and faster generics through specialization. Over the next 5 years, focus will be on concurrency and parallelism at all levels. Better tools like an improved REPL and IDE integration are also planned. The essence of Scala is concentrating on powerful abstractions to reduce boilerplate and allow powerful libraries.
This document summarizes Martin Odersky's talk about the past, present, and future of the Scala programming language over the next 5 years. It discusses Scala's growth in popularity and adoption from 2003-2009. It also outlines new features in the 2.8 version including improved collections, package objects, named parameters, and improved tooling. Finally, it discusses focus areas for the next 5 years including improved concurrency, parallelism, static typing, and language abstractions to support reliable concurrent programming.
This document discusses the key building blocks that enable Scala to be a modular and growable language. It outlines seven simple parts of the Scala language itself that can be combined in flexible ways, including expressions, scopes, patterns, recursion, functions, collections, and variables. It also discusses seven library features like static types, objects, classes, traits, abstract types, type parameters, and implicit parameters that support modular programming. The document argues that this combination of simple language parts and library features allows Scala applications and libraries to smoothly grow from small to large systems.
Martin Odersky founded Scala in 2001 at EPFL to create a language that solves functional programming problems while maintaining object-oriented capabilities. Scala runs on the Java Virtual Machine and compiles to Java bytecode, allowing it to use Java libraries. Scala improves on Java by adding functional programming concepts like immutable data structures, pattern matching, and lambda expressions. Everything in Scala is an object, but it remains a strictly typed language.
This document provides an overview of the Scala programming language. Some key points:
- Scala combines object-oriented and functional programming which allows it to be used for both small scripts and large systems. It runs on the Java Virtual Machine.
- Scala supports immutable and mutable data. Functions are first-class values that can be passed as arguments or returned from other functions.
- Scala code is more concise than Java by omitting semicolons and not requiring explicit data types. Variables start with 'var' and values start with 'val'.
- Scala is compatible with Java but provides additional features like richer type systems and built-in functional programming constructs.
This document provides an introduction to Scala by covering basic topics like packages, imports, classes, traits, control structures, and functions. It demonstrates Scala code for defining classes with fields, methods, and constructors. It shows how to use case classes, traits for composition, and for-comprehensions for iterating over collections. The document aims to highlight Scala's hybrid object-oriented and functional approach through code examples.
An Introduction to Scala - Blending OO and Functional ParadigmsMiles Sabin
Scala is a programming language that blends object-oriented and functional programming. It is designed to be compatible with Java and runs on the JVM. Scala has features like functions as first-class values, pattern matching, and immutable data structures. It aims to improve on Java syntax and provides tools like case classes and for comprehensions. Scala sees growing adoption in companies like Twitter and LinkedIn and future releases will continue to explore new type systems and features.
Refactoring to Scala DSLs and LiftOff 2009 RecapDave Orme
The document summarizes a presentation given on refactoring code to domain-specific languages (DSLs) in Scala. It provides an example of refactoring shell command execution code in Java into a DSL in Scala using techniques like implicit conversions and infix notation. The presentation argues that by applying Scala idioms carefully, code can be naturally refactored into a DSL tailored to the problem domain, providing a simple way to migrate code from Java to Scala.
Scala is a programming language that combines object-oriented and functional programming. It runs on the Java Virtual Machine and is designed to grow with user demands through libraries. Play 2.0 is a web application framework written in Scala that allows for rapid development through its Model-View-Controller architecture and local development server. Cloud Foundry is an open Platform as a Service that allows developers to easily deploy and scale applications, including those written in Scala and Play 2.0.
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...Jose Quesada (hiring)
The machine learning libraries in Apache Spark are an impressive piece of software engineering, and are maturing rapidly. What advantages does Spark.ml offer over scikit-learn? At Data Science Retreat we've taken a real-world dataset and worked through the stages of building a predictive model -- exploration, data cleaning, feature engineering, and model fitting; which would you use in production?
The machine learning libraries in Apache Spark are an impressive piece of software engineering, and are maturing rapidly. What advantages does Spark.ml offer over scikit-learn?
At Data Science Retreat we've taken a real-world dataset and worked through the stages of building a predictive model -- exploration, data cleaning, feature engineering, and model fitting -- in several different frameworks. We'll show what it's like to work with native Spark.ml, and compare it to scikit-learn along several dimensions: ease of use, productivity, feature set, and performance.
In some ways Spark.ml is still rather immature, but it also conveys new superpowers to those who know how to use it.
The document provides an overview of the Scala programming language. It discusses what Scala is, its definition, and opinions on Scala from notable figures like the creator of Java. It also covers Scala's scalability, data types, functional aspects, object-oriented aspects, and comparison to Java. Key points are that Scala is a multi-paradigm language that integrates functional and object-oriented programming, runs on the JVM, and is more concise and expressive than Java.
This document outlines the roadmap for Scala 3 and the Dotty compiler. It discusses the goals of improving type safety, ergonomics and performance while simplifying the language. Key points include incorporating learnings from Haskell for purity without sacrificing simplicity. The roadmap aims for a 2020 release of Scala 3 with stabilization in 2019. It emphasizes the importance of community contributions and getting early feedback on Dotty releases.
Scala provides a more concise and functional alternative to Java while maintaining interoperability with existing Java code and libraries. Key features of Scala include its support for immutable data structures, implicit conversions, pattern matching, and traits that allow for both object-oriented and functional programming. Scala code is more concise and reduces noise compared to Java by removing unnecessary keywords and boilerplate code.
- The speaker discusses trends towards better support for asynchronous programming in various languages like Kotlin, Java, and others.
- This makes a direct style of programming using things like delimited continuations more attractive. It will influence libraries and frameworks.
- The talk presents work on building foundations for direct style reactive programming in Scala based on things like boundaries/breaks, suspensions, and asynchronous sources like futures and channels.
- This approach provides simpler composition than monads and avoids problems of current futures implementations. It opens up new techniques for concurrency and asynchronous programming.
This document discusses implicit function types as a way to abstract over context in programming. It proposes implicit function types as a lighter-weight alternative to type classes and the reader monad for passing implicit context parameters. Implicit function types allow context to be provided implicitly based on the expected type rather than requiring it to be passed explicitly. The document outlines the typing rules and translation to the lambda calculus for implicit function types and provides examples of their use in a conference management system and the builder pattern.
This document summarizes Martin Odersky's talk on implicits in Scala. The key points are:
1. Implicits allow certain values or functions to be passed implicitly rather than explicitly as parameters. This can avoid tedious repetition when many parameters rarely change.
2. Implicits are commonly used to establish context, inject dependencies, implement type classes, and prove theorems by modeling types as theorems and programs as proofs.
3. Future changes to implicits in Scala 3 include allowing multiple implicit parameter lists, implicit by-name parameters, and implicit function types which avoid wrapping implicits in monads.
- Implicit function types are a powerful way to abstract over contexts by defining types that inject implicit values into a scope. This can fundamentally change the code we write by removing boilerplate around passing implicit parameters and configurations.
- Implicit parameters are a core Scala feature that allow removing repetition through parameterization while enabling use cases like proving theorems, establishing context, and implementing type classes. Their scope may be expanded through implicit function types.
- Future Scala versions aim to tighten rules for implicit conversions while introducing features like lazy implicits, multiple implicit parameter lists, and coherence to improve the discoverability and reasoning around implicits.
This document summarizes Martin Odersky's talk on DOT and dotty. DOT is intended to be a minimal foundational calculus for Scala that can model type parameterization, modules, and objects/classes. DOT includes dependent types to model modules as objects with type members. The DOT type system includes function types, method declarations, type declarations, and intersections. DOT's soundness proof was challenging due to programmer-definable subtyping. Dotty is the new Scala compiler prototype built on DOT, supporting new features like union and intersection types while dropping some old features. Implicit function types in dotty allow abstracting over implicit contexts without boilerplate.
The document discusses four approaches to implementing higher-kinded types in the Dotty compiler: the simple encoding, projection encoding, refinement encoding, and direct representation. It describes each approach and its limitations. The simple encoding provides a modest way to support basic higher-kinded concepts but has difficulty explaining legality. The projection and refinement encodings had problems and were ultimately less successful than initially hoped. A direct representation of higher-kinded types through special type forms was needed for robust support. While compiler hacking validated ideas, a better theoretical foundation relating higher-kinded types to the DOT calculus may have avoided some experiments.
The document discusses a new compiler architecture for the Dotty Scala Compiler (dsc) that takes inspiration from functional databases. The architecture treats all values as time-varying functions indexed by compilation phase. This allows the compiler to answer questions about program elements by looking up their meaning at a specific point in time. The core data types include time-indexed abstract syntax trees, types, references to declarations, and denotations, which capture the meaning of references. Caching is used to efficiently store and retrieve values across phases.
What is OCR Technology and How to Extract Text from Any Image for FreeTwisterTools
Discover the fascinating world of Optical Character Recognition (OCR) technology with our comprehensive presentation. Learn how OCR converts various types of documents, such as scanned paper documents, PDFs, or images captured by a digital camera, into editable and searchable data. Dive into the history, modern applications, and future trends of OCR technology. Get step-by-step instructions on how to extract text from any image online for free using a simple tool, along with best practices for OCR image preparation. Ideal for professionals, students, and tech enthusiasts looking to harness the power of OCR.
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsEstuary Flow
Unlock the full potential of your data by effortlessly migrating from PostgreSQL to Snowflake, the leading cloud data warehouse. This comprehensive guide presents an easy-to-follow 8-step process using Estuary Flow, an open-source data operations platform designed to simplify data pipelines.
Discover how to seamlessly transfer your PostgreSQL data to Snowflake, leveraging Estuary Flow's intuitive interface and powerful real-time replication capabilities. Harness the power of both platforms to create a robust data ecosystem that drives business intelligence, analytics, and data-driven decision-making.
Key Takeaways:
1. Effortless Migration: Learn how to migrate your PostgreSQL data to Snowflake in 8 simple steps, even with limited technical expertise.
2. Real-Time Insights: Achieve near-instantaneous data syncing for up-to-the-minute analytics and reporting.
3. Cost-Effective Solution: Lower your total cost of ownership (TCO) with Estuary Flow's efficient and scalable architecture.
4. Seamless Integration: Combine the strengths of PostgreSQL's transactional power with Snowflake's cloud-native scalability and data warehousing features.
Don't miss out on this opportunity to unlock the full potential of your data. Read & Download this comprehensive guide now and embark on a seamless data journey from PostgreSQL to Snowflake with Estuary Flow!
Try it Free: https://dashboard.estuary.dev/register
A Comparative Analysis of Functional and Non-Functional Testing.pdfkalichargn70th171
A robust software testing strategy encompassing functional and non-functional testing is fundamental for development teams. These twin pillars are essential for ensuring the success of your applications. But why are they so critical?
Functional testing rigorously examines the application's processes against predefined requirements, ensuring they align seamlessly. Conversely, non-functional testing evaluates performance and reliability under load, enhancing the end-user experience.
React Native vs Flutter - SSTech SystemSSTech System
Your project needs and long-term objectives will ultimately choose which of React Native and Flutter to use. For applications using JavaScript and current web technologies in particular, React Native is a mature and trustworthy choice. For projects that value performance and customizability across many platforms, Flutter, on the other hand, provides outstanding performance and a unified UI development experience.
Attendance Tracking From Paper To DigitalTask Tracker
If you are having trouble deciding which time tracker tool is best for you, try "Task Tracker" app. It has numerous features, including the ability to check daily attendance sheet, and other that make team management easier.
Ansys Mechanical enables you to solve complex structural engineering problems and make better, faster design decisions. With the finite element analysis (FEA) solvers available in the suite, you can customize and automate solutions for your structural mechanics problems and parameterize them to analyze multiple design scenarios. Ansys Mechanical is a dynamic tool that has a complete range of analysis tools.
A captivating AI chatbot PowerPoint presentation is made with a striking backdrop in order to attract a wider audience. Select this template featuring several AI chatbot visuals to boost audience engagement and spontaneity. With the aid of this multi-colored template, you may make a compelling presentation and get extra bonuses. To easily elucidate your ideas, choose a typeface with vibrant colors. You can include your data regarding utilizing the chatbot methodology to the remaining half of the template.
An MVP (Minimum Viable Product) mobile application is a streamlined version of a mobile app that includes only the core features necessary to address the primary needs of its users. The purpose of an MVP is to validate the app concept with minimal resources, gather user feedback, and identify any areas for improvement before investing in a full-scale development. This approach allows businesses to quickly launch their app, test its market viability, and make data-driven decisions for future enhancements, ensuring a higher likelihood of success and user satisfaction.
introduction of Ansys software and basic and advance knowledge of modelling s...sachin chaurasia
Ansys Mechanical enables you to solve complex structural engineering problems and make better, faster design decisions. With the finite element analysis (FEA) solvers available in the suite, you can customize and automate solutions for your structural mechanics problems and parameterize them to analyze multiple design scenarios. Ansys Mechanical is a dynamic tool that has a complete range of analysis tools.
In this talk, we will explore strategies to optimize the success rate of storing and retaining new information. We will discuss scientifically proven ideal learning intervals and content structures. Additionally, we will examine how to create an environment that improves our focus while you remain in the “flow”. Lastly we will also address the influence of AI on learning capabilities.
In the dynamic field of software development, this knowledge will empower you to accelerate your learning curve and support others in their learning journeys.
3. “Scala” is going nowhere
“Scala is a gateway drug to Haskell”
Recognizing this fact,
we should phase out the name “Scala”
Idea and Design: Sandro Stucky
5. Where It Came From
1980s Modula-2, Oberon
1990-95 Functional Programming: calculus, Haskell, SMLλ
1995-98 Pizza
1998-99 GJ, javac
2000-02 Functional Nets, Funnel
5
6. Motivation for Scala
• Grew out of Funnel
• Wanted to show that we can do a practical combination of OOP and
FP.
• What got dropped:
• Concurrency was relegated to libraries
• No tight connection between language and core calculus
(fragments were studied in the Obj paper and others.)ν
• What got added:
• Native object and class model, Java interop, XML literals.
6
7. Why <XML>?
I wanted Scala to have a hipster syntax.
•Everybody uses [..] for arrays, so we use (..)
•Everybody uses <..> for types, so we use [..]
•But now we needed to find another use of <..>
8. What Makes Scala Scala?
Scala is
•functional
•object-oriented / modular
•statically typed
•strict
• Closest predecessor: OCaml.
• Differences: OCaml separates object and module
system, Scala unifies them
• OCaml uses Hindley/Milner, Scala subtyping + local
type inference.
9. 1st
Invariant: A Scalable Language
• Instead of providing lots of features in the language, have the right
abstractions so that they can
be provided in libraries.
• This has worked quite well so far.
• It implicitly trusts programmers and library designers to “do the right
thing”, or at least the community to sort things out.
9
10. • Scala’s core is its type system.
• Most of the advanced types concepts are about flexibility, less so
about safety.
2nd
Invariant: It’s about the Types
10
Flexibility / Ease of Use
Safety
Scala
Trend in Type-systems
Goals of PL design
where we’d like it to move
13. New Environment: Scala.JS
Feb 5, 2015:
Scala.JS 0.6 released
No longer experimental!
Fast
Great interop with Javascript
libraries
14. Why does Scala.JS work so well?
• Because of @srjd, and the great people who contribute.
• But also: It plays to the strengths of Scala
• Libraries instead of primitives
• Flexible type system
• Geared for interoperating with a host language.
15. Tool Improvements
• Much faster incremental compiler, available in sbt and IDEs
• New IDEs
• Eclipse IDE 4.0
• IntelliJ 14.0
• Ensime: make the Scala compiler available to help editing
21. Emergence of a platform
• Core libraries
• Specifications:
• Futures
• Reactive Streams
• Spores
• Common vocabulary
Beginnings of a reactive platform, analogous to Java EE
23. What Are Classfiles Good For?
• Portability across hardware
• Portability across OS/s
• Interoperability across versions
• Place for
- optimizations,
- analysis,
- instrumentation
So what is the analogue of the JDK for Scala?
24. Picture so far:
Scala Source
Classfiles + Scala Signatures
Native code
Scala piggybacks on the JDK
scalac
JDK JIT
25. Challenges for Scala
• Binary compatibility
• scalac has way more transformations to do than javac.
• Compilation schemes change
• Many implementation techniques are non-local, require co-
compilation of library and client. (e.g. trait composition).
• Having to pick a platform
• Previously: platform is “The JDK.”
• In the future: Which JDK? 7, 8, 9, 10? And what about JS?
27. • TASTY: Serialized Typed Abstract Syntax Trees
• E.g., here’s a TAST for x + 2
The Core
Apply
Select
Ident “+”
“x”
::
Literal Nil
2
Int
(Int)Int
Int(2)
Int
28. Serialized TASTY File Format
28
A reference format for
analysis + transformation
of Scala code
high-level
complete
detailed.
29. def plus2(x: Int) = x + 2 becomes
Overall: TASTY trees take up ~25% of classfile size
Example:
29
x + 2
30. What We Can Do With It
Applications:
• instrumentation
• optimization
• code analysis
• refactoring
Publish once, run everywhere.
Automated remapping to solve binary compatibility issues.
32. Connect the Dots
DOT: A calculus for
Papers in FOOL ‘12, OOPSLA ’14.
Work on developing a fully expressive machine-verified version
is still onoping.
dotc: A compiler for a cleaned up version of Scala.
lampepfl/dotty on Github
32
36. expands toexpands toexpands toexpands to
Type Parameters as Syntactic Sugar
class List[T] { ... }
class List {
type List$T
private type T = List$T
}
37. expands toexpands toexpands toexpands to
General Higher-Kinded Types
through Typed Lambdas
type Two[T] = (T, T)
type Two = Lambda {
type hk$Arg
type Apply = (hk$arg, hk$arg)
}
38. expands toexpands toexpands toexpands to
General Higher-Kinded Types
through Typed Lambdas
Two[String]
Two {
type hk$Arg = String
} # Apply
39. New Concepts
Type unions (T&U) and intersections (T|U)
•replace compound types (T with U)
•Eliminate potential of blow-up in least upper bound / greatest lower bound
operations
•Make the type system cleaner and more regular (e.g. intersection, union
are commutative).
•But pose new challenges for compilation. E.g.
class A { def x = 1 }
class B { def x = 2 }
val ab: A | B = ???
ab.x // which x gets called?
40. Status
Compiler close to completion
Should have an alpha release by ScalaDays Amsterdam
Plan to use TASTY for
merging dotc and scalac.
42. 1. Implicits that compose
We already have implicit lambdas
implicit x => t implicit transaction => body
What about if we also allow implicit function types?
implicit Transaction => Result
Then we can abstract over implicits:
type Transactional[R] = implicit Transaction => R
Types like these compose, e.g.
type TransactionalIO[R] = Transactional[IO[R]]
43. expands toexpands toexpands toexpands to
New Rule:
If the expected type of an expression E is an implicit
function, E is automatically expanded to an implicit closure.
def f: Transactional[R] = body
def f: Transactional[R] =
implicit _: Transaction[R] => body
44. 2. Better Treatment of effects
So far, purity in Scala is by convention, not by coercion.
In that sense, Scala is not a pure functional language.
We’d like to explore “scalarly” ways to express effects of functions.
Effects can be quite varied, e.g.
- Mutation
- IO
- Exceptions
- Null-dereferencing, ...
Two essential properties:
- they are additive,
- they propagate along the call-graph.
45. `
“Though Shalt Use Monads for Effects”
Monads are cool
But for Scala I hope we find something even better.
•Monads don’t commute.
•Require monad transformers for composition.
•I tried to wrap my head around it, but then it exploded.
46. use thisuse thisuse thisuse this
Idea: Use implicits to model effects as
capabilities
def f: R throws Exc = ...
def f(implicit t: CanThrow[Exc]): R = ...
instead of thisinstead of thisinstead of thisinstead of this
type throws[R, Exc] =
implicit CanThrow[Exc] => R
or add thisor add thisor add thisor add this
to get back to this!to get back to this!to get back to this!to get back to this!
47. In Summary
Scala
-established functional programming in the mainstream,
-showed that a fusion with object-oriented programming is possible and
useful,
-promoted the adoption of strong static typing,
-has lots of enthusiastic users, conference attendees included.
Despite it being 10 years out it has few close competitors.
47
48. Our Aims
• Make the platform more powerful
• Make the language simplier
• Work on foundations to get to the essence of Scala.
Let’s continue to work together to achieve this.
Thank You!