SlideShare une entreprise Scribd logo
1  sur  54
Hello world
object   HelloWorld   { def  main ( args :   Array [ String ])   { println ( "Hello world!" ) } } public class  HelloWorld   { public static  void   main ( String []  args )   { System . out . println ( "Hello world" ); } }
Малък мащаб
scala>   var  peaks = Map(  |   "Musala" -> 2925,  |   "Rozhen" -> 1750  |  ) peaks:  scala.collection.immutable.Map[java.lang.String,Int] = Map(Musala -> 2925, Rozhen -> 1750) scala>   peaks += "Botev" -> 2376 scala>   println(peaks) Map(Musala -> 2925, Rozhen -> 1750, Botev -> 2376)
На високо ниво
Java public   boolean   hasUpperCase ( String text )   { boolean  hasUpperCase  =   false ; for   ( int  i  =   0;  i  <  text . length ();  i ++) { if   ( Character . isUpperCase ( text . charAt ( i )))   { hasUpperCase  =   true ; break ; } } return  hasUpperCase ; }
Scala def  hasUpperCase ( text :   String )  = text . exists ( _ . isUpperCase )
Експресивен
Java public  BigInteger  ????? ( BigInteger x )   { if   ( x  ==  BigInteger . ZERO )   { return  BigInteger . ONE ; } return  x . multiply ( ?????( x . subtract ( BigInteger . ONE ))); }
Java public  BigInteger  factorial ( BigInteger x )   { if   ( x  ==  BigInteger . ZERO )   { return  BigInteger . ONE ; } return  x . multiply ( factorial ( x . subtract ( BigInteger . ONE ))); }
def  factorial ( x :   BigInt )   = if   ( x  ==   0)   1   else  x  *  factorial ( x  -   1) Scala
Java public   class   Person   { private  String name ; private   int  age ; public   Person ( String name ,   int  age )   { this . name   =  name ; this . age   =  age ; } public  String  getName ()   { return  name ; } public   int   getAge ()   { return  age ; } public   void   setName ( String name )   { this . name   =  name ; } public   void   setAge ( int  age )   { this . age   =  age ; } }
class   Person ( var  name :   String ,  var  age :   int ) Scala
Turtles all the way down http://en.wikipedia.org/wiki/Turtles_all_the_way_down
1   +   2 1.+(2) 1  to  8  // => Range.Inclusive(1, 8) 1.to(8)
Прагматичен
def  users  = < users > < user role = &quot;customer&quot; > < name >{  user . name  }</ name > < password >{  user . password  }</ password > < email >{  user . email  }</ email > </ user > <user role= &quot;boss&quot; > < name >{  boss . name  }</ name > < password >{  boss . password  }</ password > < email >{  boss . email  }</ email > </ user > </ users > users  &quot;user&quot;
DSLs Growing a language http://video.google.com/videoplay?docid=-8860158196198824415
Scala specs object   HelloSpec   extends   Specification   { &quot;'hello world' has 11 characters&quot;  in  { &quot;hello world&quot;   size must_==  11 } &quot;'hello world' matches 'h.* w.*'&quot;  in  { &quot;hello world&quot;  must be matching ( &quot;h.* w.*&quot; ) } }
object   Basic   extends   Baysick   { def  main ( args : Array [ String ])   =   { 10   PRINT   &quot;Welcome to Baysick Lunar Lander v0.9&quot; 20   LET   ( 'dist  :=   100) 30   LET   ( 'v  :=   1) 40   LET   ( 'fuel  :=   1000) 50   LET   ( 'mass  :=   1000) 60   PRINT   &quot;You are drifting towards the moon.&quot; 70   PRINT   &quot;You must decide how much fuel to burn.&quot; 80   PRINT   &quot;To accelerate enter a positive number&quot; 90   PRINT   &quot;To decelerate a negative&quot; 100   PRINT   &quot;Distance &quot;   %  'dist  %   &quot;km, &quot;   %   &quot;Velocity &quot;   %  'v  %   &quot;km/s, &quot;   %   &quot;Fuel &quot;   %  'fuel 110   INPUT  'burn 120   IF   ABS ( 'burn )   <=  'fuel  THEN   150 130   PRINT   &quot;You don't have that much fuel&quot; 140   GOTO   100 150   LET   ( 'v  :=  'v  +  'burn  *   10   /   ( 'fuel  +  'mass )) 160   LET   ( 'fuel  :=  'fuel  -   ABS ( 'burn )) 170   LET   ( 'dist  :=  'dist  –  'v ) 180   IF  'dist  >   0   THEN   100 190   PRINT   &quot;You have hit the surface&quot; 200   IF  'v  <   3   THEN   240 210   PRINT   &quot;Hit surface too fast (&quot;   %  'v  %   &quot;)km/s&quot; 220   PRINT   &quot;You Crashed!&quot; 230   GOTO   250 240   PRINT   &quot;Well done&quot; 250   END RUN } } http://www.scala-lang.org/node/1403
val  worldSaver =   actor   { loop   { react   { case   SaveTheWorld ( when )   =>   saveTheWorldAfter ( when ) case   BeBad   =>   // Ignore it - we are good! } } } worldSaver  !   SaveTheWorld ( new   Date )
Ф(у,н,к,ц,и,о,н,а,л,е,н) език
Защо cat File | grep println | wc
Функции ( x :   Int ,  y :   Int )   =>   if   ( x  >  y )  x  else  y val  max  =   ( x :   Int ,  y :   Int )   =>   if   ( x  >  y )  x  else  y max (1,   4)   // 4
val  numbers  =   Array (1,   2,   3,   -1) numbers . map (( n )   =>  n  *   2)   // Array(2, 4, 6, -2) numbers . map ( _   *   2) int [] doubled =  new   int [arr. length ]; for  ( int  i = 0; i < arr. length ; i++) { doubled[i] = arr[i] * 2; }
public   boolean   hasUpperCase ( String text )   { boolean  hasUpperCase  =   false ; for   ( int  i  =   0;  i  <  text . length ();  i ++) { if   ( Character . isUpperCase ( text . charAt ( i )))   { hasUpperCase  =   true ; break ; } } return  hasUpperCase ; } def  hasUpperCase ( text :   String )  = text . exists ( _ . isUpperCase )
Pattern matching
arg  match   { case   &quot;-h&quot;   |   &quot;-help&quot;   => println ( &quot;Params: -help|-verbose&quot; ) case   &quot;-v&quot;   |   &quot;-verbose&quot;   => verbose  =   true }
val  list  =   1   ::   2   ::   3   ::   Nil list  match   { case   Nil   =>   // Empty list case  head  ::  tail  =>   // head = 1, tail = List(2, 3) }
val  tuple  =   (1,   &quot;asd&quot; ) val   ( one ,  asd )   =  tuple
case   class   Person ( firstName :   String , lastName :   String ) val  johnDoe  =   Person ( &quot;John&quot; ,   &quot;Doe&quot; ) val   Person ( john ,  doe )   =  johnDoe
QuickSort
Първи дубъл def  qsort ( items :   List [ Int ]) :   List [ Int ]   =   { if   ( items . length  <=   1)   return  items var  left :   List [ Int ]   =   Nil var  middle :   List [ Int ]   =   Nil var  right :   List [ Int ]   =   Nil val  pivot  =  items . head for   ( item  <-  items )   { if   ( item  <  pivot )   { left  =  item  ::  left }   else   if   ( item  >  pivot )   { right  =  item  ::  right }   else   { middle  =  item  ::  middle } } qsort ( left )   :::  middle  :::  qsort ( right ) }
Редно(2)  дубъл def  qsort ( items :   List [ Int ])   =   { items  match   { case   Nil   =>   Nil case  xs  =>   { val  pivot  =  xs . head qsort ( xs . filter ( _   <  pivot ))   ::: xs . filter ( _   ==  pivot )   ::: qsort ( xs . filter ( _   >  pivot )) } } }
Traits Multiple inheritance
 
trait   Printer   { def  print ( doc :   Document )   =   new   Sheet ( doc ) } trait   Scanner   { def  scan ( sheet :   Sheet )   =   new   Document ( sheet ) } trait   Copier   extends   Printer   with   Scanner   { def  copy ( sheet :   Sheet )   =   print ( scan ( sheet )) }
trait   Phone   { def  dial ( number :   Int )   // Abstract } trait   AnalogPhone   extends   Phone   { def  dial ( number :   Int )   { /* rotate */ } } trait   DigitalPhone   extends   Phone   { def  dial ( number :   Int )   {   /* send 0101101 */   } }
trait   Fax   { this:   Phone   => def  fax ( number :   Int )   { dial ( number )  /* from phone */ /* send fax */ } }
class   DigitalFax   extends   Fax   with   DigitalPhone val  analogFax  =   new   Fax   with   AnalogPhone
class   CoffeeMachine   { def  makeCoffee ()   =   &quot;a nice cup of coffee&quot; } val  allInOne  =   new   CoffeeMachine with   Fax with   DigitalPhone with   Copier   /*  with Printer with Scanner */
Dependency injection
trait   Fax   { this:   Phone   => def  fax ( number :   Int )   { dial ( number )  /* from phone */ /* send fax */ } } val  analogFax  =   new   Fax   with   Analog class   DigitalFax   extends   Fax   with   DigitalPhone
Duck typing
class   File   { def  close ()   {  println ( &quot;closed the file&quot; )   } } class   Socket   { def  close ()   {  println ( &quot;socket unpluged&quot; )   } } object   Duck   { def  main ( args :   Array [ String ])   { closeIt ( new   File ) closeIt ( new   Socket ) } def  closeIt ( x :   )   { x . close () } }
class   File   { def  close ()   {  println ( &quot;closed the file&quot; )   } } class   Socket   { def  close ()   {  println ( &quot;socket unpluged&quot; )   } } object   Duck   { def  main ( args :   Array [ String ])   { closeIt ( new   File ) closeIt ( new   Socket ) } def  closeIt ( x :   {   def  close ()   } )   { x . close () } }
Съвместимост с Java
MD5 import   java.security.MessageDigest def  md5 ( x :   String ) :   String   =   { val  md  =   MessageDigest  getInstance  &quot;MD5&quot; md update x . getBytes val  md5  =  md digest BigInt (1,  md5 )  toString  16 }
Актьори
Actors demo
Инструменти
http://programming-scala.labs.oreilly.com/index.html Книги
scala-lang.org ibm.com/developerworks/views/java/libraryview.jsp?search_by=scala+neward  Ресурси
emil.vladev [at] gmail.com bolddream.com

Contenu connexe

Tendances

Transaction is a monad
Transaction is a  monadTransaction is a  monad
Transaction is a monadJarek Ratajski
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner codeMite Mitreski
 
Google Guava - Core libraries for Java & Android
Google Guava - Core libraries for Java & AndroidGoogle Guava - Core libraries for Java & Android
Google Guava - Core libraries for Java & AndroidJordi Gerona
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBtdc-globalcode
 
Hello Swift 3/5 - Function
Hello Swift 3/5 - FunctionHello Swift 3/5 - Function
Hello Swift 3/5 - FunctionCody Yun
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Lin Yo-An
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...tdc-globalcode
 
Kotlin : Advanced Tricks - Ubiratan Soares
Kotlin : Advanced Tricks - Ubiratan SoaresKotlin : Advanced Tricks - Ubiratan Soares
Kotlin : Advanced Tricks - Ubiratan SoaresiMasters
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.Icalia Labs
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collectionsMyeongin Woo
 
Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기진성 오
 

Tendances (20)

Transaction is a monad
Transaction is a  monadTransaction is a  monad
Transaction is a monad
 
Pure kotlin
Pure kotlinPure kotlin
Pure kotlin
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner code
 
Don't do this
Don't do thisDon't do this
Don't do this
 
Google Guava - Core libraries for Java & Android
Google Guava - Core libraries for Java & AndroidGoogle Guava - Core libraries for Java & Android
Google Guava - Core libraries for Java & Android
 
Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015
 
はじめてのGroovy
はじめてのGroovyはじめてのGroovy
はじめてのGroovy
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 
Hello Swift 3/5 - Function
Hello Swift 3/5 - FunctionHello Swift 3/5 - Function
Hello Swift 3/5 - Function
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
 
TRunner
TRunnerTRunner
TRunner
 
Kotlin : Advanced Tricks - Ubiratan Soares
Kotlin : Advanced Tricks - Ubiratan SoaresKotlin : Advanced Tricks - Ubiratan Soares
Kotlin : Advanced Tricks - Ubiratan Soares
 
Short Introduction To "perl -d"
Short Introduction To "perl -d"Short Introduction To "perl -d"
Short Introduction To "perl -d"
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.
 
Developing iOS apps with Swift
Developing iOS apps with SwiftDeveloping iOS apps with Swift
Developing iOS apps with Swift
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collections
 
Pdr ppt
Pdr pptPdr ppt
Pdr ppt
 
Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기
 

Similaire à Scala 2 + 2 > 4

Scala 3camp 2011
Scala   3camp 2011Scala   3camp 2011
Scala 3camp 2011Scalac
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009David Pollak
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Jonas Bonér
 
Pragmatic Real-World Scala
Pragmatic Real-World ScalaPragmatic Real-World Scala
Pragmatic Real-World Scalaparag978978
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersTikal Knowledge
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecLoïc Descotte
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meetMario Fusco
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Languageintelliyole
 
Rewriting Java In Scala
Rewriting Java In ScalaRewriting Java In Scala
Rewriting Java In ScalaSkills Matter
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fuclimatewarrior
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象勇浩 赖
 
F# Presentation
F# PresentationF# Presentation
F# Presentationmrkurt
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Raffi Krikorian
 

Similaire à Scala 2 + 2 > 4 (20)

SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Scala 3camp 2011
Scala   3camp 2011Scala   3camp 2011
Scala 3camp 2011
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009
 
Oscon 2010 Specs talk
Oscon 2010 Specs talkOscon 2010 Specs talk
Oscon 2010 Specs talk
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
Pragmatic Real-World Scala
Pragmatic Real-World ScalaPragmatic Real-World Scala
Pragmatic Real-World Scala
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java Programmers
 
Groovy
GroovyGroovy
Groovy
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
 
Fantom and Tales
Fantom and TalesFantom and Tales
Fantom and Tales
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
 
Rewriting Java In Scala
Rewriting Java In ScalaRewriting Java In Scala
Rewriting Java In Scala
 
Scala en
Scala enScala en
Scala en
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
 
F# Presentation
F# PresentationF# Presentation
F# Presentation
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
 

Dernier

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Dernier (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Scala 2 + 2 > 4

  • 2. object HelloWorld { def main ( args : Array [ String ]) { println ( &quot;Hello world!&quot; ) } } public class HelloWorld { public static void main ( String [] args ) { System . out . println ( &quot;Hello world&quot; ); } }
  • 4. scala> var peaks = Map( | &quot;Musala&quot; -> 2925, | &quot;Rozhen&quot; -> 1750 | ) peaks: scala.collection.immutable.Map[java.lang.String,Int] = Map(Musala -> 2925, Rozhen -> 1750) scala> peaks += &quot;Botev&quot; -> 2376 scala> println(peaks) Map(Musala -> 2925, Rozhen -> 1750, Botev -> 2376)
  • 6. Java public boolean hasUpperCase ( String text ) { boolean hasUpperCase = false ; for ( int i = 0; i < text . length (); i ++) { if ( Character . isUpperCase ( text . charAt ( i ))) { hasUpperCase = true ; break ; } } return hasUpperCase ; }
  • 7. Scala def hasUpperCase ( text : String ) = text . exists ( _ . isUpperCase )
  • 9. Java public BigInteger ????? ( BigInteger x ) { if ( x == BigInteger . ZERO ) { return BigInteger . ONE ; } return x . multiply ( ?????( x . subtract ( BigInteger . ONE ))); }
  • 10. Java public BigInteger factorial ( BigInteger x ) { if ( x == BigInteger . ZERO ) { return BigInteger . ONE ; } return x . multiply ( factorial ( x . subtract ( BigInteger . ONE ))); }
  • 11. def factorial ( x : BigInt ) = if ( x == 0) 1 else x * factorial ( x - 1) Scala
  • 12. Java public class Person { private String name ; private int age ; public Person ( String name , int age ) { this . name = name ; this . age = age ; } public String getName () { return name ; } public int getAge () { return age ; } public void setName ( String name ) { this . name = name ; } public void setAge ( int age ) { this . age = age ; } }
  • 13. class Person ( var name : String , var age : int ) Scala
  • 14. Turtles all the way down http://en.wikipedia.org/wiki/Turtles_all_the_way_down
  • 15. 1 + 2 1.+(2) 1 to 8 // => Range.Inclusive(1, 8) 1.to(8)
  • 17. def users = < users > < user role = &quot;customer&quot; > < name >{ user . name }</ name > < password >{ user . password }</ password > < email >{ user . email }</ email > </ user > <user role= &quot;boss&quot; > < name >{ boss . name }</ name > < password >{ boss . password }</ password > < email >{ boss . email }</ email > </ user > </ users > users &quot;user&quot;
  • 18. DSLs Growing a language http://video.google.com/videoplay?docid=-8860158196198824415
  • 19. Scala specs object HelloSpec extends Specification { &quot;'hello world' has 11 characters&quot; in { &quot;hello world&quot; size must_== 11 } &quot;'hello world' matches 'h.* w.*'&quot; in { &quot;hello world&quot; must be matching ( &quot;h.* w.*&quot; ) } }
  • 20. object Basic extends Baysick { def main ( args : Array [ String ]) = { 10 PRINT &quot;Welcome to Baysick Lunar Lander v0.9&quot; 20 LET ( 'dist := 100) 30 LET ( 'v := 1) 40 LET ( 'fuel := 1000) 50 LET ( 'mass := 1000) 60 PRINT &quot;You are drifting towards the moon.&quot; 70 PRINT &quot;You must decide how much fuel to burn.&quot; 80 PRINT &quot;To accelerate enter a positive number&quot; 90 PRINT &quot;To decelerate a negative&quot; 100 PRINT &quot;Distance &quot; % 'dist % &quot;km, &quot; % &quot;Velocity &quot; % 'v % &quot;km/s, &quot; % &quot;Fuel &quot; % 'fuel 110 INPUT 'burn 120 IF ABS ( 'burn ) <= 'fuel THEN 150 130 PRINT &quot;You don't have that much fuel&quot; 140 GOTO 100 150 LET ( 'v := 'v + 'burn * 10 / ( 'fuel + 'mass )) 160 LET ( 'fuel := 'fuel - ABS ( 'burn )) 170 LET ( 'dist := 'dist – 'v ) 180 IF 'dist > 0 THEN 100 190 PRINT &quot;You have hit the surface&quot; 200 IF 'v < 3 THEN 240 210 PRINT &quot;Hit surface too fast (&quot; % 'v % &quot;)km/s&quot; 220 PRINT &quot;You Crashed!&quot; 230 GOTO 250 240 PRINT &quot;Well done&quot; 250 END RUN } } http://www.scala-lang.org/node/1403
  • 21. val worldSaver = actor { loop { react { case SaveTheWorld ( when ) => saveTheWorldAfter ( when ) case BeBad => // Ignore it - we are good! } } } worldSaver ! SaveTheWorld ( new Date )
  • 23. Защо cat File | grep println | wc
  • 24. Функции ( x : Int , y : Int ) => if ( x > y ) x else y val max = ( x : Int , y : Int ) => if ( x > y ) x else y max (1, 4) // 4
  • 25. val numbers = Array (1, 2, 3, -1) numbers . map (( n ) => n * 2) // Array(2, 4, 6, -2) numbers . map ( _ * 2) int [] doubled = new int [arr. length ]; for ( int i = 0; i < arr. length ; i++) { doubled[i] = arr[i] * 2; }
  • 26. public boolean hasUpperCase ( String text ) { boolean hasUpperCase = false ; for ( int i = 0; i < text . length (); i ++) { if ( Character . isUpperCase ( text . charAt ( i ))) { hasUpperCase = true ; break ; } } return hasUpperCase ; } def hasUpperCase ( text : String ) = text . exists ( _ . isUpperCase )
  • 28. arg match { case &quot;-h&quot; | &quot;-help&quot; => println ( &quot;Params: -help|-verbose&quot; ) case &quot;-v&quot; | &quot;-verbose&quot; => verbose = true }
  • 29. val list = 1 :: 2 :: 3 :: Nil list match { case Nil => // Empty list case head :: tail => // head = 1, tail = List(2, 3) }
  • 30. val tuple = (1, &quot;asd&quot; ) val ( one , asd ) = tuple
  • 31. case class Person ( firstName : String , lastName : String ) val johnDoe = Person ( &quot;John&quot; , &quot;Doe&quot; ) val Person ( john , doe ) = johnDoe
  • 33. Първи дубъл def qsort ( items : List [ Int ]) : List [ Int ] = { if ( items . length <= 1) return items var left : List [ Int ] = Nil var middle : List [ Int ] = Nil var right : List [ Int ] = Nil val pivot = items . head for ( item <- items ) { if ( item < pivot ) { left = item :: left } else if ( item > pivot ) { right = item :: right } else { middle = item :: middle } } qsort ( left ) ::: middle ::: qsort ( right ) }
  • 34. Редно(2) дубъл def qsort ( items : List [ Int ]) = { items match { case Nil => Nil case xs => { val pivot = xs . head qsort ( xs . filter ( _ < pivot )) ::: xs . filter ( _ == pivot ) ::: qsort ( xs . filter ( _ > pivot )) } } }
  • 36.  
  • 37. trait Printer { def print ( doc : Document ) = new Sheet ( doc ) } trait Scanner { def scan ( sheet : Sheet ) = new Document ( sheet ) } trait Copier extends Printer with Scanner { def copy ( sheet : Sheet ) = print ( scan ( sheet )) }
  • 38. trait Phone { def dial ( number : Int ) // Abstract } trait AnalogPhone extends Phone { def dial ( number : Int ) { /* rotate */ } } trait DigitalPhone extends Phone { def dial ( number : Int ) { /* send 0101101 */ } }
  • 39. trait Fax { this: Phone => def fax ( number : Int ) { dial ( number ) /* from phone */ /* send fax */ } }
  • 40. class DigitalFax extends Fax with DigitalPhone val analogFax = new Fax with AnalogPhone
  • 41. class CoffeeMachine { def makeCoffee () = &quot;a nice cup of coffee&quot; } val allInOne = new CoffeeMachine with Fax with DigitalPhone with Copier /* with Printer with Scanner */
  • 43. trait Fax { this: Phone => def fax ( number : Int ) { dial ( number ) /* from phone */ /* send fax */ } } val analogFax = new Fax with Analog class DigitalFax extends Fax with DigitalPhone
  • 45. class File { def close () { println ( &quot;closed the file&quot; ) } } class Socket { def close () { println ( &quot;socket unpluged&quot; ) } } object Duck { def main ( args : Array [ String ]) { closeIt ( new File ) closeIt ( new Socket ) } def closeIt ( x : ) { x . close () } }
  • 46. class File { def close () { println ( &quot;closed the file&quot; ) } } class Socket { def close () { println ( &quot;socket unpluged&quot; ) } } object Duck { def main ( args : Array [ String ]) { closeIt ( new File ) closeIt ( new Socket ) } def closeIt ( x : { def close () } ) { x . close () } }
  • 48. MD5 import java.security.MessageDigest def md5 ( x : String ) : String = { val md = MessageDigest getInstance &quot;MD5&quot; md update x . getBytes val md5 = md digest BigInt (1, md5 ) toString 16 }
  • 54. emil.vladev [at] gmail.com bolddream.com