SlideShare a Scribd company logo
Scala- Elegant and Exotic! Part 1




                    By VulcanMinds
Scala – Elegant & Exotic!


• Scala’s elegant and exotic aspects
  – Concise and flexible syntax
  – Do more with less boilerplate
  – Pre-built libs that are programmer friendly
  – Real-world data parsing with native XML
    support
The Almighty “Hello Scala”

                    Java                                                  Scala
     class HelloJava {                                                  (In REPL)
     Public static void main(String[] s)
     {                                              Object HelloScala extends Application {
       System.out.println(“Hello Java!”) ;            Console.println(“Hello Scala!”)
     }                                              }

     }                                              scala> HelloScala
     # javac HelloJava                              Hello Scala!
     # java HelloJava                               scala>_
     Hello Java
     #_



Java : create a class , write the entry point - main method , access the console output
stream through System class and use the println to print the string.
Scala: extend the pre-defined ‘Application’ object and use the pre-defined ‘Console’
object to print to console.
Of Party/Guests/Children Lists/Tuples/Maps
>val guests= List(("Manish", 30),("Andy" , 25),("Donald", 50),("Rita", 10),("Bob", 12),("Tiara", 5),("Chris", 67))

> val children = guests.flatMap(aGuest => if(aGuest._2 < 18) Some(aGuest._1) else None)
children: List[java.lang.String] = List(Rita, Bob, Tiara)

>val adults = guests.flatMap(aGuest => if(aGuest._2 >= 18) Some(aGuest._1) else None)
adults: List[java.lang.String] = List(Manish, Andy, Donald, Chris)




 Now try to do this in Java… how many lines of code and checks for equality and null?
Scala Exotic OOAP or weird?
  You thought …your concepts about classes, functions inheritance
                      were immutable huh?

    scala> abstract class exotic extends (Int=> String)
    defined class exotic
    scala> class concrete extends exotic {
       | def apply(in:Int) = {Console.println("Ok did the implementation");"Ok got it"}
       |}
    defined class concrete

    scala> val exoticStuff = new concrete
    exoticStuff: concrete = <function1>

    scala> val result = exoticStuff(1000)
    Ok did the implementation
    result: java.lang.String = Ok got it

 Some scala sanity: The exotic class extended an abstract function that took in an integer
and returned a string and the concrete class defined the function! So function seems == a
                                     class how come?
Giving Some[Any] Option or None…. after Marriage!


  scala> class Me(name:String,married:Boolean) {
     | def canWatchMovie = {
     | if (!married) {Console.println("you can anytime! dear"); Some(true)} else {
              Console.println(“wife:How dare you without me"); None} }
     |}
  defined class Me

  scala> new Me("manish",true).canWatchMovie
  wife:How dare you without me
  res41: Option[Boolean] = None

  scala> new Me("manish",false).canWatchMovie
  you can anytime! dear
  res42: Option[Boolean] = Some(true)



Some scala sanity: Option is a ‘boxed’ class that can hold *Some*Any++ or ‘None’ objects. So
      None looks like a ‘void’ for Java old timers like me… but wait… what is a Unit?

More Related Content

What's hot (20)

JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
Leonardo De Moura Rocha Lima
 
Introduction to meta-programming in scala
Introduction to meta-programming in scalaIntroduction to meta-programming in scala
Introduction to meta-programming in scala
Alessandro Marrella
 
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
Leonardo De Moura Rocha Lima
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JS
Knoldus Inc.
 
Scala.js for large and complex frontend apps
Scala.js for large and complex frontend appsScala.js for large and complex frontend apps
Scala.js for large and complex frontend apps
Otto Chrons
 
ElasticMQ: a fully asynchronous, Akka-based SQS server
ElasticMQ: a fully asynchronous, Akka-based SQS serverElasticMQ: a fully asynchronous, Akka-based SQS server
ElasticMQ: a fully asynchronous, Akka-based SQS server
Adam Warski
 
Akka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignAkka and the Zen of Reactive System Design
Akka and the Zen of Reactive System Design
Lightbend
 
Collections.compare(JDK, Eclipse, Guava, Apache...);
Collections.compare(JDK, Eclipse, Guava, Apache...);Collections.compare(JDK, Eclipse, Guava, Apache...);
Collections.compare(JDK, Eclipse, Guava, Apache...);
Leonardo De Moura Rocha Lima
 
Scala Abide: A lint tool for Scala
Scala Abide: A lint tool for ScalaScala Abide: A lint tool for Scala
Scala Abide: A lint tool for Scala
Iulian Dragos
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
Skills Matter
 
Scala Macros
Scala MacrosScala Macros
Scala Macros
Adam Warski
 
Coding with style: The Scalastyle style checker
Coding with style: The Scalastyle style checkerCoding with style: The Scalastyle style checker
Coding with style: The Scalastyle style checker
Matthew Farwell
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
tod esking
 
SQL Provider
SQL ProviderSQL Provider
SQL Provider
Ross McKinlay
 
Actor Model Akka Framework
Actor Model Akka FrameworkActor Model Akka Framework
Actor Model Akka Framework
Harinath Krishnamoorthy
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
Viplav Jain
 
Java 101 Intro to Java Programming - Exercises
Java 101   Intro to Java Programming - ExercisesJava 101   Intro to Java Programming - Exercises
Java 101 Intro to Java Programming - Exercises
agorolabs
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
WO Community
 
Coscup
CoscupCoscup
Coscup
宇宣 賴
 
Android course session 5 (Threads & socket)
Android course session 5 (Threads & socket)Android course session 5 (Threads & socket)
Android course session 5 (Threads & socket)
Keroles M.Yakoub
 
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
Leonardo De Moura Rocha Lima
 
Introduction to meta-programming in scala
Introduction to meta-programming in scalaIntroduction to meta-programming in scala
Introduction to meta-programming in scala
Alessandro Marrella
 
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
Leonardo De Moura Rocha Lima
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JS
Knoldus Inc.
 
Scala.js for large and complex frontend apps
Scala.js for large and complex frontend appsScala.js for large and complex frontend apps
Scala.js for large and complex frontend apps
Otto Chrons
 
ElasticMQ: a fully asynchronous, Akka-based SQS server
ElasticMQ: a fully asynchronous, Akka-based SQS serverElasticMQ: a fully asynchronous, Akka-based SQS server
ElasticMQ: a fully asynchronous, Akka-based SQS server
Adam Warski
 
Akka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignAkka and the Zen of Reactive System Design
Akka and the Zen of Reactive System Design
Lightbend
 
Collections.compare(JDK, Eclipse, Guava, Apache...);
Collections.compare(JDK, Eclipse, Guava, Apache...);Collections.compare(JDK, Eclipse, Guava, Apache...);
Collections.compare(JDK, Eclipse, Guava, Apache...);
Leonardo De Moura Rocha Lima
 
Scala Abide: A lint tool for Scala
Scala Abide: A lint tool for ScalaScala Abide: A lint tool for Scala
Scala Abide: A lint tool for Scala
Iulian Dragos
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
Skills Matter
 
Coding with style: The Scalastyle style checker
Coding with style: The Scalastyle style checkerCoding with style: The Scalastyle style checker
Coding with style: The Scalastyle style checker
Matthew Farwell
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
tod esking
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
Viplav Jain
 
Java 101 Intro to Java Programming - Exercises
Java 101   Intro to Java Programming - ExercisesJava 101   Intro to Java Programming - Exercises
Java 101 Intro to Java Programming - Exercises
agorolabs
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
WO Community
 
Android course session 5 (Threads & socket)
Android course session 5 (Threads & socket)Android course session 5 (Threads & socket)
Android course session 5 (Threads & socket)
Keroles M.Yakoub
 

Viewers also liked (16)

Scala case of case classes
Scala   case of case classesScala   case of case classes
Scala case of case classes
VulcanMinds
 
Mongo DB in Health Care Part 1
Mongo DB in Health Care Part 1Mongo DB in Health Care Part 1
Mongo DB in Health Care Part 1
VulcanMinds
 
Desarrollo del Proyecto de Aula
Desarrollo del Proyecto de AulaDesarrollo del Proyecto de Aula
Desarrollo del Proyecto de Aula
Lorena Criollo
 
Desarrollo del proyecton de aula
Desarrollo del proyecton de aulaDesarrollo del proyecton de aula
Desarrollo del proyecton de aula
Chillagana
 
Ikea
IkeaIkea
Ikea
Sarenawati Jaafar
 
92624748
9262474892624748
92624748
Sarenawati Jaafar
 
Eindpresentatie Freek Kusters
Eindpresentatie Freek KustersEindpresentatie Freek Kusters
Eindpresentatie Freek Kusters
freekkusters
 
Munching the mongo
Munching the mongoMunching the mongo
Munching the mongo
VulcanMinds
 
Data choreography in mongo
Data choreography in mongoData choreography in mongo
Data choreography in mongo
VulcanMinds
 
Proyecto de aula q
Proyecto de aula qProyecto de aula q
Proyecto de aula q
Lorena Criollo
 
Tupple ware in scala
Tupple ware in scalaTupple ware in scala
Tupple ware in scala
VulcanMinds
 
Dig up the gold in your godowns
Dig up the gold in your godownsDig up the gold in your godowns
Dig up the gold in your godowns
VulcanMinds
 
Multicast - Embrace the challenge?
Multicast - Embrace the challenge?Multicast - Embrace the challenge?
Multicast - Embrace the challenge?
Paul Catchpole
 
Designing a play framework application
Designing a play framework applicationDesigning a play framework application
Designing a play framework application
VulcanMinds
 
Scala xml power play part 1
Scala   xml power play part 1Scala   xml power play part 1
Scala xml power play part 1
VulcanMinds
 
C13 Oriflame Republica Dominicana
C13 Oriflame Republica DominicanaC13 Oriflame Republica Dominicana
C13 Oriflame Republica Dominicana
www.joselynperez.com
 
Scala case of case classes
Scala   case of case classesScala   case of case classes
Scala case of case classes
VulcanMinds
 
Mongo DB in Health Care Part 1
Mongo DB in Health Care Part 1Mongo DB in Health Care Part 1
Mongo DB in Health Care Part 1
VulcanMinds
 
Desarrollo del Proyecto de Aula
Desarrollo del Proyecto de AulaDesarrollo del Proyecto de Aula
Desarrollo del Proyecto de Aula
Lorena Criollo
 
Desarrollo del proyecton de aula
Desarrollo del proyecton de aulaDesarrollo del proyecton de aula
Desarrollo del proyecton de aula
Chillagana
 
Eindpresentatie Freek Kusters
Eindpresentatie Freek KustersEindpresentatie Freek Kusters
Eindpresentatie Freek Kusters
freekkusters
 
Munching the mongo
Munching the mongoMunching the mongo
Munching the mongo
VulcanMinds
 
Data choreography in mongo
Data choreography in mongoData choreography in mongo
Data choreography in mongo
VulcanMinds
 
Tupple ware in scala
Tupple ware in scalaTupple ware in scala
Tupple ware in scala
VulcanMinds
 
Dig up the gold in your godowns
Dig up the gold in your godownsDig up the gold in your godowns
Dig up the gold in your godowns
VulcanMinds
 
Multicast - Embrace the challenge?
Multicast - Embrace the challenge?Multicast - Embrace the challenge?
Multicast - Embrace the challenge?
Paul Catchpole
 
Designing a play framework application
Designing a play framework applicationDesigning a play framework application
Designing a play framework application
VulcanMinds
 
Scala xml power play part 1
Scala   xml power play part 1Scala   xml power play part 1
Scala xml power play part 1
VulcanMinds
 

Similar to Scala elegant and exotic part 1 (20)

Scala In The Wild
Scala In The WildScala In The Wild
Scala In The Wild
djspiewak
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
Isaias Barroso
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
Mario Camou Riveroll
 
Intro to scala
Intro to scalaIntro to scala
Intro to scala
Joe Zulli
 
How Scala promotes TDD
How Scala promotes TDDHow Scala promotes TDD
How Scala promotes TDD
Shai Yallin
 
Getting Started With Scala
Getting Started With ScalaGetting Started With Scala
Getting Started With Scala
Meetu Maltiar
 
Introduction to Scala : Clueda
Introduction to Scala : CluedaIntroduction to Scala : Clueda
Introduction to Scala : Clueda
Andreas Neumann
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
Derek Chen-Becker
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scala
shinolajla
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
Eric Pederson
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
Marakana Inc.
 
Scala
ScalaScala
Scala
Andreas Enbohm
 
Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
Venkateswaran Kandasamy
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Language
league
 
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
Scala on Android
Scala on AndroidScala on Android
Scala on Android
Jakub Kahovec
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Manish Pandit
 
Scala intro for Java devs 20150324
Scala intro for Java devs 20150324Scala intro for Java devs 20150324
Scala intro for Java devs 20150324
Erik Schmiegelow
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
PrasannaKumar Sathyanarayanan
 
Devoxx
DevoxxDevoxx
Devoxx
Martin Odersky
 
Scala In The Wild
Scala In The WildScala In The Wild
Scala In The Wild
djspiewak
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
Isaias Barroso
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
Mario Camou Riveroll
 
Intro to scala
Intro to scalaIntro to scala
Intro to scala
Joe Zulli
 
How Scala promotes TDD
How Scala promotes TDDHow Scala promotes TDD
How Scala promotes TDD
Shai Yallin
 
Getting Started With Scala
Getting Started With ScalaGetting Started With Scala
Getting Started With Scala
Meetu Maltiar
 
Introduction to Scala : Clueda
Introduction to Scala : CluedaIntroduction to Scala : Clueda
Introduction to Scala : Clueda
Andreas Neumann
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
Derek Chen-Becker
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scala
shinolajla
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
Eric Pederson
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
Marakana Inc.
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Language
league
 
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Manish Pandit
 
Scala intro for Java devs 20150324
Scala intro for Java devs 20150324Scala intro for Java devs 20150324
Scala intro for Java devs 20150324
Erik Schmiegelow
 

Recently uploaded (20)

Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 

Scala elegant and exotic part 1

  • 1. Scala- Elegant and Exotic! Part 1 By VulcanMinds
  • 2. Scala – Elegant & Exotic! • Scala’s elegant and exotic aspects – Concise and flexible syntax – Do more with less boilerplate – Pre-built libs that are programmer friendly – Real-world data parsing with native XML support
  • 3. The Almighty “Hello Scala” Java Scala class HelloJava { (In REPL) Public static void main(String[] s) { Object HelloScala extends Application { System.out.println(“Hello Java!”) ; Console.println(“Hello Scala!”) } } } scala> HelloScala # javac HelloJava Hello Scala! # java HelloJava scala>_ Hello Java #_ Java : create a class , write the entry point - main method , access the console output stream through System class and use the println to print the string. Scala: extend the pre-defined ‘Application’ object and use the pre-defined ‘Console’ object to print to console.
  • 4. Of Party/Guests/Children Lists/Tuples/Maps >val guests= List(("Manish", 30),("Andy" , 25),("Donald", 50),("Rita", 10),("Bob", 12),("Tiara", 5),("Chris", 67)) > val children = guests.flatMap(aGuest => if(aGuest._2 < 18) Some(aGuest._1) else None) children: List[java.lang.String] = List(Rita, Bob, Tiara) >val adults = guests.flatMap(aGuest => if(aGuest._2 >= 18) Some(aGuest._1) else None) adults: List[java.lang.String] = List(Manish, Andy, Donald, Chris) Now try to do this in Java… how many lines of code and checks for equality and null?
  • 5. Scala Exotic OOAP or weird? You thought …your concepts about classes, functions inheritance were immutable huh? scala> abstract class exotic extends (Int=> String) defined class exotic scala> class concrete extends exotic { | def apply(in:Int) = {Console.println("Ok did the implementation");"Ok got it"} |} defined class concrete scala> val exoticStuff = new concrete exoticStuff: concrete = <function1> scala> val result = exoticStuff(1000) Ok did the implementation result: java.lang.String = Ok got it Some scala sanity: The exotic class extended an abstract function that took in an integer and returned a string and the concrete class defined the function! So function seems == a class how come?
  • 6. Giving Some[Any] Option or None…. after Marriage! scala> class Me(name:String,married:Boolean) { | def canWatchMovie = { | if (!married) {Console.println("you can anytime! dear"); Some(true)} else { Console.println(“wife:How dare you without me"); None} } |} defined class Me scala> new Me("manish",true).canWatchMovie wife:How dare you without me res41: Option[Boolean] = None scala> new Me("manish",false).canWatchMovie you can anytime! dear res42: Option[Boolean] = Some(true) Some scala sanity: Option is a ‘boxed’ class that can hold *Some*Any++ or ‘None’ objects. So None looks like a ‘void’ for Java old timers like me… but wait… what is a Unit?