Fireship · @fireship

Scala in 100 Seconds

Uploaded July 30, 2024 · Length 3:28

Scala in 100 Seconds

Summary

This video teaches how to get started with Scala, a high-level statically typed programming language that combines object-oriented and functional programming paradigms.

  • scala programming language
  • functional programming
  • object-oriented programming
  • java virtual machine
  • scala tutorial

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    Scola a highlevel statically typed

  2. 0:02

    programming language famous for fusing

  3. 0:05

    objectoriented and functional

  4. 0:06

    programming paradigms together in a

  5. 0:08

    clean concise syntax it was designed in

  6. 0:10

    Switzerland by computer scientist Martin

  7. 0:12

    ODI and first released in ' 04 the name

  8. 0:15

    Scola means scalable language and it's

  9. 0:17

    lived up to that name by powering the

  10. 0:19

    large scale analytics engine Apache

  11. 0:21

    spark the large scale social media

  12. 0:22

    platforms of X and Linkedin and

  13. 0:24

    large-scale genomics projects like atom

  14. 0:27

    it's one of many jvm languages that

  15. 0:29

    compile to code to run on the Java

  16. 0:31

    virtual machine it can interupt with

  17. 0:33

    Java and use Java libraries but what it

  18. 0:35

    doesn't have is Java's boilerplate no

  19. 0:37

    static void main string args just to say

  20. 0:39

    hello world but most importantly it gets

  21. 0:42

    functional by making no distinction

  22. 0:44

    between statements and expressions

  23. 0:46

    everything is a value that means every

  24. 0:48

    if statement or for Loop can be assigned

  25. 0:50

    to a variable when combined with type

  26. 0:51

    inference the end result is concise

  27. 0:54

    expressive and safe code and it provides

  28. 0:56

    features like higher order functions

  29. 0:58

    null safety pattern matching and

  30. 1:00

    algebraic data types that dramatically

  31. 1:02

    reduce the amount of pain you'll suffer

  32. 1:03

    as a Java developer to get started

  33. 1:05

    you'll first want to install the jvm and

  34. 1:07

    then the skulla compiler from there

  35. 1:09

    we'll create an SBT file which is

  36. 1:10

    scola's build tool and includes metadata

  37. 1:12

    about the application and then we'll

  38. 1:14

    write the actual code in a DOT Scola

  39. 1:16

    file just like in Java we can create a

  40. 1:18

    class and then inside that class Define

  41. 1:20

    a main function we can also Define a

  42. 1:21

    trait to apply a type interface to this

  43. 1:24

    class or by changing the class keyword

  44. 1:26

    to object we automatically create a

  45. 1:28

    Singleton it looks like typical o P but

  46. 1:30

    here's where things get weird any

  47. 1:32

    variable declared with vow is immutable

  48. 1:34

    and most data structures in the standard

  49. 1:35

    Library like list are also immutable

  50. 1:37

    although it is possible to make values

  51. 1:39

    mutable with VAR and notice how the type

  52. 1:41

    is automatically inferred as an integer

  53. 1:43

    although it could be made explicit now

  54. 1:45

    everything is a value so if we have an

  55. 1:47

    if statement like this we can assign it

  56. 1:48

    to a variable like that that's cool but

  57. 1:51

    if you're a Java developer you've likely

  58. 1:52

    been tortured by null pointer exceptions

  59. 1:54

    this bad code example is trying to cast

  60. 1:56

    null as an integer which could lead to

  61. 1:58

    runtime errors but in skola you can use