Fireship · @fireship

Ruby in 100 Seconds

Uploaded January 31, 2022 · Length 2:37

Ruby in 100 Seconds

Summary

ruby basics explained in 100 seconds, including syntax, object-oriented features, and development ecosystem.

  • ruby programming language
  • ruby basics
  • ruby syntax
  • ruby development

Transcript preview

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

  1. 0:00

    [Music]

  2. 0:00

    ruby a dynamic interpreted scripting

  3. 0:02

    language made famous for taking

  4. 0:04

    simplicity and code readability to the

  5. 0:06

    extreme it was first conceived by

  6. 0:07

    yukihiro matsumoto aka mats in 1993 as

  7. 0:11

    an easy-to-use scripting language like

  8. 0:13

    python but with genuine object-oriented

  9. 0:15

    features like smalltalk it exploded in

  10. 0:17

    popularity after david hanemeyer hansen

  11. 0:19

    aka dhh created rails in 2005 a model

  12. 0:23

    view controller framework at the time it

  13. 0:25

    was a game changer for startups because

  14. 0:27

    it reduced the complexity required to

  15. 0:29

    build a full stack web application and

  16. 0:30

    has been used to build unicorns like

  17. 0:32

    twitter shopify github and airbnb just

  18. 0:34

    to name a few ruby is often called a

  19. 0:36

    programmer's best friend thanks to its

  20. 0:38

    minimal syntax that relies on plain

  21. 0:40

    english words and the use of blocks to

  22. 0:42

    write concise functional code at the

  23. 0:44

    same time it's a true object-oriented

  24. 0:46

    language where everything is an object

  25. 0:48

    and every object can be modified giving

  26. 0:50

    developers the flexibility to extend or

  27. 0:52

    modify the behavior of the underlying

  28. 0:54

    language the developer ecosystem is

  29. 0:56

    large and mature code is shared between

  30. 0:58

    developers with the rubygems package

  31. 1:00

    manager where a program is organized

  32. 1:01

    into a self-contained format called a

  33. 1:03

    gem to get started install ruby then

  34. 1:05

    create a file ending in rb to declare a

  35. 1:08

    local variable give it a name followed

  36. 1:10

    by a value there's no variable keyword

  37. 1:12

    but you can define constants in all caps

  38. 1:14

    or global variables with a dollar sign

  39. 1:16

    every value is an instance of an object

  40. 1:18

    which means we can call methods directly

  41. 1:19

    on a string like so and parentheses are

  42. 1:21

    usually optional ruby is dynamically

  43. 1:23

    typed which means there's no type

  44. 1:25

    annotations however modern tools like

  45. 1:27

    rbs can add a type system on top of it

  46. 1:29

    kind of like how typescript does for

  47. 1:30

    javascript now to print a value to the

  48. 1:32

    standard output use the puts method we

  49. 1:34

    can define our own custom methods using

  50. 1:36

    the def keyword which end with the end

  51. 1:38

    keyword every method will always return

  52. 1:40

    exactly one object no return keyword is

  53. 1:42

    necessary or if you don't want a named

  54. 1:44

    method you might create a block with a

  55. 1:46

    do keyword which works like an anonymous

  56. 1:48

    function blocks can also take arguments

  57. 1:50

    found in between the pipe characters now

  58. 1:52

    use the class keyword to create

  59. 1:53

    blueprints for your own custom objects

  60. 1:55

    an interesting point is that ruby

  61. 1:57

    supports duct typing which means that if

  62. 1:59

    it walks like a duck and quacks like a