Fireship · @fireship

how to never write bug

Uploaded October 18, 2022 · Length 7:20

how to never write bug

Summary

7 universal debugging tips for programmers to avoid and fix bugs in their code, including reading documentation, understanding error messages, and using logging and debuggers.

  • debugging tips for programmers
  • how to avoid bugs in code
  • logging in programming
  • using debuggers in vs code
  • static code analysis with typescript
  • test driven development
  • regression testing

Transcript preview

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

  1. 0:00

    the key to becoming an efficient

  2. 0:01

    programmer is to never write any bugs

  3. 0:04

    unfortunately that's virtually

  4. 0:05

    impossible when your code doesn't work

  5. 0:07

    as expected 99 of the time it's your own

  6. 0:10

    code to blame you cannot blame all me

  7. 0:12

    however about 0.99 of the time it's the

  8. 0:15

    pulse of somebody else on your team and

  9. 0:17

    you can get pissed off at them

  10. 0:18

    accordingly

  11. 0:20

    but the other.0099 of the time it's a

  12. 0:24

    bug in some shady Library you downloaded

  13. 0:26

    from npm which means you'll have to open

  14. 0:27

    up an issue on its GitHub repo or fix it

  15. 0:30

    yourself and open a pull request or just

  16. 0:32

    build your own new library from scratch

  17. 0:33

    however the other point zero zero zero

  18. 0:36

    zero nine nine percent of the time it's

  19. 0:37

    the programming language or compiler

  20. 0:39

    itself to blame in which case you'll

  21. 0:41

    need to get in touch with some people

  22. 0:42

    much smarter than yourself who determine

  23. 0:44

    it's not a bug with a compiler but it's

  24. 0:45

    an edge case that happens

  25. 0:48

    .00099 of the time and the actual

  26. 0:50

    Hardware is to blame like one transistor

  27. 0:52

    was placed just a few nanometers to the

  28. 0:54

    left and that's why your website doesn't

  29. 0:55

    look quite right on a Blackberry but the

  30. 0:57

    hardware people say it's not their fault

  31. 0:58

    it's actually just an edge case that

  32. 1:00

    happens point zero zero zero zero zero

  33. 1:02

    zero one percent of the time where your

  34. 1:04

    code is just not compatible with the

  35. 1:05

    laws of quantum superposition due to a

  36. 1:07

    defect in the simulation in which we

  37. 1:09

    live in other words it's God's will that

  38. 1:11

    thou code shall not work luckily bugs

  39. 1:13

    like this are pretty rare and in today's

  40. 1:15

    video we'll look at seven universal

  41. 1:16

    debugging tips that every developer

  42. 1:18

    should be familiar with the first tip is

  43. 1:20

    to read that may seem stupidly obvious

  44. 1:22

    but programmers want to get things done

  45. 1:24

    quickly and tend to be overconfident in

  46. 1:26

    their understanding of what the hell the

  47. 1:27

    computer is actually doing what will

  48. 1:29

    often happen is you'll guess what a

  49. 1:31

    method or function is doing based on its

  50. 1:33

    name but remember there are only two

  51. 1:35

    hard problems in computer science naming

  52. 1:37

    things and coming up with new original

  53. 1:39

    jokes for YouTube tutorials like there

  54. 1:41

    might be a function called get random

  55. 1:43

    number you automatically think it's

  56. 1:44

    always going to return a different

  57. 1:45

    number but when you call it it returns

  58. 1:47

    three every time it's not a bug because

  59. 1:49

    had you read the documentation you know

  60. 1:51

    that 3 is a random number that was

  61. 1:52

    chosen by the developer in advance who

  62. 1:54

    guaranteed that it was 100 random when

  63. 1:56

    he chose it with the roll of a die

  64. 1:57

    reading documentation in advance is

  65. 1:59

    important but developers also tend to