Type classes 101 - classification beyond inheritanceAlexey Raga
Inheritance and interfaces implementation are often used in languages like Java in order to express "Is-a" and "Can-do" capabilities. In Scala we can do better by separating these concerns using the concept of type classes.
Второе выступление в рамках спецкурса "Немейнстримовые технологии разработки", читаемого в НГУ. http://bit.ly/mainstreamless
Аудио дорожка работает, но нужно иметь некоторое терпение, так как грузится она не моментально.
Выступление в рамках спецкурса "Немейнстримовые технологии разработки", читаемого в НГУ. http://bit.ly/mainstreamless
Аудио дорожка работает, но нужно иметь некоторое терпение, так как грузится она не моментально.
Type classes 101 - classification beyond inheritanceAlexey Raga
Inheritance and interfaces implementation are often used in languages like Java in order to express "Is-a" and "Can-do" capabilities. In Scala we can do better by separating these concerns using the concept of type classes.
Второе выступление в рамках спецкурса "Немейнстримовые технологии разработки", читаемого в НГУ. http://bit.ly/mainstreamless
Аудио дорожка работает, но нужно иметь некоторое терпение, так как грузится она не моментально.
Выступление в рамках спецкурса "Немейнстримовые технологии разработки", читаемого в НГУ. http://bit.ly/mainstreamless
Аудио дорожка работает, но нужно иметь некоторое терпение, так как грузится она не моментально.
My talk at Bangalore Java Users Group. It was meant developers who want to get them started on Scala. This talk objectives was to get started on creating a project in Scala, write some code using collections and test it using ScalaTest.
Talk is about simple data structures like queue and Tree and their possible implementation in Scala. It also talks about binary search trees and their traversals.
Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e
Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases.
A talk given at the Underscore meetup on 19 August, 2014.
Ten-page Brief Overview of Swift for Scala Developersihji
This is a ten-page brief overview document about Apple's brand new Swift programming language. This document is written in a Scala developer's view, so many advanced Swift features which do not have proper counterparts in Scala were baldly omitted. However, if you want to get a feeling that how Swift looks like, this is a perfect starter.
Traits in Scala are similar to interfaces, but much more powerful.➢A trait encapsulates method and field definitions, which can then bereused by mixing them into classes.
Some parts of our applications don't need to be asynchronous or interact with the outside world: it's enough that they are stateful, possibly with the ability to handle failure, context, and logging. Although you can use ZIO 2 or monad transformers for this task, both come with drawbacks. In this presentation, Jorge Vásquez will introduce you to ZPure, a data type from ZIO Prelude, which lets you scale back on the power of ZIO 2, but with the same high-performance, type-inference, and ergonomics you expect from ZIO 2 libraries.
Exploring type level programming in ScalaJorge Vásquez
In this introduction to type-level programming in Scala, we are going to discuss how we can leverage the full power of the type system to verify domain properties of an application at compile-time, instead of doing runtime verifications at the value-level
My talk at Bangalore Java Users Group. It was meant developers who want to get them started on Scala. This talk objectives was to get started on creating a project in Scala, write some code using collections and test it using ScalaTest.
Talk is about simple data structures like queue and Tree and their possible implementation in Scala. It also talks about binary search trees and their traversals.
Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e
Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases.
A talk given at the Underscore meetup on 19 August, 2014.
Ten-page Brief Overview of Swift for Scala Developersihji
This is a ten-page brief overview document about Apple's brand new Swift programming language. This document is written in a Scala developer's view, so many advanced Swift features which do not have proper counterparts in Scala were baldly omitted. However, if you want to get a feeling that how Swift looks like, this is a perfect starter.
Traits in Scala are similar to interfaces, but much more powerful.➢A trait encapsulates method and field definitions, which can then bereused by mixing them into classes.
Some parts of our applications don't need to be asynchronous or interact with the outside world: it's enough that they are stateful, possibly with the ability to handle failure, context, and logging. Although you can use ZIO 2 or monad transformers for this task, both come with drawbacks. In this presentation, Jorge Vásquez will introduce you to ZPure, a data type from ZIO Prelude, which lets you scale back on the power of ZIO 2, but with the same high-performance, type-inference, and ergonomics you expect from ZIO 2 libraries.
Exploring type level programming in ScalaJorge Vásquez
In this introduction to type-level programming in Scala, we are going to discuss how we can leverage the full power of the type system to verify domain properties of an application at compile-time, instead of doing runtime verifications at the value-level
Both Haskell and Scala are very expressive functional programming languages which are undergoing active development.
We will look at fundamental concepts and goals which inspired their design. We will examine similarities and differences between various features of these languages using code examples. We will also attempt to briefly assess their practicality in software engineering context.
Principles of functional progrmming in scalaehsoon
a short outline on necessity of functional programming and principles of functional programming in Scala.
In the article some keyword are used but not explained (to keep the article short and simple), the interested reader can look them up in internet.
This presentation takes you on a functional programming journey, it starts from basic Scala programming language design concepts and leads to a concept of Monads, how some of them designed in Scala and what is the purpose of them
In this presentation, You will get to know about Function Literal,Higher Order Function,Partial Function,Partial Applied Function,Nested Function,Closures.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
In questo evento online gratuito, organizzato dalla Community Italiana di UiPath, potrai esplorare le nuove funzionalità di Autopilot, il tool che integra l'Intelligenza Artificiale nei processi di sviluppo e utilizzo delle Automazioni.
📕 Vedremo insieme alcuni esempi dell'utilizzo di Autopilot in diversi tool della Suite UiPath:
Autopilot per Studio Web
Autopilot per Studio
Autopilot per Apps
Clipboard AI
GenAI applicata alla Document Understanding
👨🏫👨💻 Speakers:
Stefano Negro, UiPath MVPx3, RPA Tech Lead @ BSP Consultant
Flavio Martinelli, UiPath MVP 2023, Technical Account Manager @UiPath
Andrei Tasca, RPA Solutions Team Lead @NTT Data
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
3. apropos Scala
• «Scala is a pure-bred object-oriented language. Conceptually,
every value is an object and every operation is a method-call. The
language supports advanced component architectures through
classes and traits.»
• «Scala is also a full-blown functional language. It has everything
you would expect, including first-class functions, a library with
efficient immutable data structures, and a general preference of
immutability over mutation.»
4. • A sane approach to the JVM
• Flexibility
• Interoperability
• Excellent community
• Better documentation (mostly)
Why Scala?
5. • Static types
• Rich type system
• Functions are first-class citizens
• Stress on immutability
• Case classes (traits, objects, …)
• Pattern matching
• Rich collections (List, HashMap, Seq, Vector)
• Operator overloading
• Interoperability with Java libraries
• REPL and worksheets (Eclipse, IntelliJ)
Why I like Scala so much?
7. Static types
• Compile time checking
• Your IDE will be much more helpful
• Encourages encapsulation
• Limits your ‘ability’ to write code before thinking
• Inferred types greatly reduce boilerplate
• … no more “‘NoneType’ object has no attribute…”
8. Rich type system
• Monads [Option, Try, Either, …]
«A monad is a container type together with map and flatMap methods defined on it.»
• Functions [Function1, Function2, …]
• Generic types [+T, -T]
• Higher kinded types
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
• Structural types
def setElementText(element : {def setText(text : String)}, text : String)
10. Functions as first-class citizens
• Higher-order functions (i.e. sum in terms of fold)
• Anonymous functions
(x: Int, y: Int) => x + y
• Easily transform collections with map
11. Stress on immutability
«[…] there can never be surprises in logic.»
– L. Wittgenstein
Hopefully, there should never be surprises in code.
12. Stress on immutability
object LongestIncreasingSubsequence {
def apply(sequence: Seq[Int]): Seq[Int] = {
val validSubsequences = iterateAndDropHead(Seq(sequence), sequence)
validSubsequences
.map(findIncreasingSubsequence)
.sortBy(_.length)(Ordering[Int].reverse)
.head
}
@tailrec
def iterateAndDropHead(folded: Seq[Seq[Int]], remaining: Seq[Int]): Seq[Seq[Int]] = {
remaining match {
case head :: Nil => folded
case head :: tail => iterateAndDropHead(folded :+ tail, tail)
}
}
def findIncreasingSubsequence(sequence: Seq[Int]): Seq[Int] = {
sequence.foldLeft(Seq(sequence.head)) {
(acc, el) => if(acc.last < el) acc :+ el else acc
}
}
}
13. Case classes
case class Person(firstName: String, lastName: String)
val randomGuy = Person("Gabriele", "Alese")
randomGuy match {
case Person("Gabriele", _) => println("Hello Gabriele!")
case Person("Vincent", _) => println("Hello, Vincent!")
case _ => println("I've never seen you before")
}
14. Case classes
• Free accessors (and mutators, if you must)
• Free equals() and hashCode()
• Free toString()
• Free copy()
• No need to use new
• Free apply and unapply methods
on the companion object (see pattern matching)
15. Pattern matching
sealed abstract class Expression
case class X() extends Expression
case class Const(value : Int) extends Expression
case class Add(left : Expression, right : Expression) extends Expression
case class Mult(left : Expression, right : Expression) extends Expression
case class Neg(expr : Expression) extends Expression
def eval(expression : Expression, xValue : Int) : Int = expression match {
case X() => xValue
case Const(cst) => cst
case Add(left, right) => eval(left, xValue) + eval(right, xValue)
case Mult(left, right) => eval(left, xValue) * eval(right, xValue)
case Neg(expr) => - eval(expr, xValue)
}
18. Rich collections
def dropWhile[A](l: List[A])(f: A => Boolean): List[A] =
l match {
case Cons(head, tail) if f(head) => dropWhile(tail)(f)
case _ => l
}
def foldRight[A, B](list: List[A], initial: B)(f: (A, B) => B): B = {
list match {
case Nil => initial
case Cons(head, tail) => f(head, foldRight(tail, initial)(f))
}
}
def foldLeft[A, B](as: List[A], initial: B)(f: (B, A) => B): B = {
as match {
case Nil => initial
case Cons(head, tail) => foldLeft(tail, f(initial, head))(f)
}
}
def map[A, B](list: List[A])(f: A => B): List[B] = {
foldRight(list, Nil: List[B])((a, b) => Cons(f(a), b))
}
def filter[A](list: List[A])(f: A => Boolean): List[A] = {
foldRight(list, Nil: List[A])((a, b) => if (f(a)) Cons(a, b) else b)
}
def flatMap[A, B](list: List[A])(f: A => List[B]): List[B] = {
concat(map(list)(f))
}
}
19. Operator overloading
package it.alese.scacchirossi.scacchirossi
import it.alese.scacchirossi.scacchirossi.board.{Column, Row}
case class Position(column: Column, row: Row) {
val x: Int = column.toInt
val y: Int = row.toInt
def to(toPosition: Position): List[Position] = {
Move(this, toPosition).intermediatePositions
}
def +(x: Int, y: Int) = {
val col = if (this.x + x != 0) Column(this.x + x) else this.column
val row = if (this.y + y != 0) Row(this.y + y) else this.row
new Position(col, row)
}
…
}
object Position {
def apply(position: String): Position = {
require(position.length == 2, "Illegal coordinate string")
new Position(Column(position(0)), Row(position(1).asDigit))
}
…
}
package it.alese.scacchirossi.scacchirossi
class PositionTest extends WordSpec with Matchers {
"A position" should {
…
"return a new position if summed to an offset" in {
Position("A1") + (1,1) shouldEqual Position("B2")
Position("A1") + (0,1) shouldEqual Position("A2")
}
"return a range of contiguous vertical positions" in {
Position("A1") to Position("A4")
shouldEqual
List(Position("A1"), Position("A2"), Position("A3"), Position("A4"))
}
}
21. Interoperability with Java libraries
package it.alese.emailchecker
import java.io.{InputStreamReader, BufferedReader, PrintWriter}
import java.net.Socket
case class TelnetSession(socket: Socket, input: PrintWriter, output: BufferedReader) {
def allowsConnections: Boolean = {
Reply(output.readLine).code match {
case "220" => true
case _ => false
}
}
def send(command: String): String = {
input.println(command)
output.readLine
}
def close(): Unit = {
send("quit")
socket.close()
}
}
object TelnetSession {
def apply(host: String): TelnetSession = {
val socket = new Socket(host, 25)
new TelnetSession(
socket,
new PrintWriter(socket.getOutputStream, true),
new BufferedReader(
new InputStreamReader(socket.getInputStream)
)
)
}
}
22. Interoperability with Java libraries
• If you can’t find a Scala library for that, chances are
that you’ll find a Java equivalent
(Good luck with the documentation!)
• Appealing for Java programmers
(or young professionals fresh out of “university Java”)
• Stronger community
(IMHO: many Scala enthusiasts are Java seniors)