Fireship · @fireship

Kotlin in 100 Seconds

Uploaded November 5, 2021 · Length 2:22

Kotlin in 100 Seconds

Summary

kotlin basics: statically typed language with concise syntax and features like type inference and null safety.

  • kotlin language
  • kotlin syntax
  • kotlin features
  • java alternative
  • android development

Transcript preview

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

  1. 0:00

    kotlin a statically typed multi-paradigm

  2. 0:02

    language designed quite simply as a

  3. 0:04

    better alternative to java like java it

  4. 0:07

    compiles to bytecode that runs on the

  5. 0:09

    java virtual machine but kotlin provides

  6. 0:11

    a more concise syntax and language

  7. 0:13

    features loved by modern developers like

  8. 0:15

    type inference functional patterns null

  9. 0:18

    safety and more it was announced in 2011

  10. 0:20

    by jetbrains with the first stable

  11. 0:22

    release coming in 2016. it's named after

  12. 0:25

    kotlin island in russia and it just got

  13. 0:26

    a mascot in october 2021 but it still

  14. 0:29

    doesn't have a name yet one of its key

  15. 0:31

    features is that it can interop with

  16. 0:32

    existing java code which means

  17. 0:34

    developers can gradually adopt it

  18. 0:36

    without throwing all of their code in

  19. 0:37

    the garbage in addition to jvm kotlin

  20. 0:39

    can also compile to native code and

  21. 0:42

    javascript opening the door to

  22. 0:43

    multi-platform apps it's been most

  23. 0:45

    influential in the android development

  24. 0:47

    community and as of 2019 google named it

  25. 0:49

    the preferred language for android

  26. 0:51

    development over java one of its killer

  27. 0:53

    features is co-routines which provides a

  28. 0:55

    simplified way to write asynchronous

  29. 0:57

    non-blocking code a common requirement

  30. 0:59

    for mobile developers to get started

  31. 1:01

    create a file ending in.kt most kotlin

  32. 1:04

    developers use something like intellij

  33. 1:06

    idea which is an ide brought to you by

  34. 1:08

    the same company that invented the

  35. 1:10

    language inside the file use the fun

  36. 1:12

    keyword to define a main function this

  37. 1:14

    is where your code will start executing

  38. 1:16

    and that syntax is a lot more fun to

  39. 1:17

    write than public static void main

  40. 1:19

    string args declare a variable with the

  41. 1:21

    var keyword assign a value and its type

  42. 1:24

    will be inferred automatically or you

  43. 1:25

    can add a colon after the variable name

  44. 1:27

    with an explicit type a variable can't

  45. 1:29

    be null unless you explicitly allow it

  46. 1:31

    with a question mark on the type now use

  47. 1:33

    printline to log the variable to the

  48. 1:35

    standard output notice how semicolons

  49. 1:37

    are optional which means that line

  50. 1:39

    breaks are significant kotlin supports

  51. 1:40

    familiar object-oriented patterns but

  52. 1:42

    can do special functional things that

  53. 1:44

    java cannot like modify the behavior of

  54. 1:46

    a class without inheritance using

  55. 1:48

    extension functions functions are first

  56. 1:50

    class objects which means they can be

  57. 1:52

    stored as variables passed as arguments

  58. 1:54

    or used anonymously with lambdas kotlin

  59. 1:56

    also reduces boilerplate with things

  60. 1:58

    like data classes so you don't have to