Fireship · @fireship
how to never write bug
Uploaded October 18, 2022 · Length 7:20
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.
- 0:00
the key to becoming an efficient
- 0:01
programmer is to never write any bugs
- 0:04
unfortunately that's virtually
- 0:05
impossible when your code doesn't work
- 0:07
as expected 99 of the time it's your own
- 0:10
code to blame you cannot blame all me
- 0:12
however about 0.99 of the time it's the
- 0:15
pulse of somebody else on your team and
- 0:17
you can get pissed off at them
- 0:18
accordingly
- 0:20
but the other.0099 of the time it's a
- 0:24
bug in some shady Library you downloaded
- 0:26
from npm which means you'll have to open
- 0:27
up an issue on its GitHub repo or fix it
- 0:30
yourself and open a pull request or just
- 0:32
build your own new library from scratch
- 0:33
however the other point zero zero zero
- 0:36
zero nine nine percent of the time it's
- 0:37
the programming language or compiler
- 0:39
itself to blame in which case you'll
- 0:41
need to get in touch with some people
- 0:42
much smarter than yourself who determine
- 0:44
it's not a bug with a compiler but it's
- 0:45
an edge case that happens
- 0:48
.00099 of the time and the actual
- 0:50
Hardware is to blame like one transistor
- 0:52
was placed just a few nanometers to the
- 0:54
left and that's why your website doesn't
- 0:55
look quite right on a Blackberry but the
- 0:57
hardware people say it's not their fault
- 0:58
it's actually just an edge case that
- 1:00
happens point zero zero zero zero zero
- 1:02
zero one percent of the time where your
- 1:04
code is just not compatible with the
- 1:05
laws of quantum superposition due to a
- 1:07
defect in the simulation in which we
- 1:09
live in other words it's God's will that
- 1:11
thou code shall not work luckily bugs
- 1:13
like this are pretty rare and in today's
- 1:15
video we'll look at seven universal
- 1:16
debugging tips that every developer
- 1:18
should be familiar with the first tip is
- 1:20
to read that may seem stupidly obvious
- 1:22
but programmers want to get things done
- 1:24
quickly and tend to be overconfident in
- 1:26
their understanding of what the hell the
- 1:27
computer is actually doing what will
- 1:29
often happen is you'll guess what a
- 1:31
method or function is doing based on its
- 1:33
name but remember there are only two
- 1:35
hard problems in computer science naming
- 1:37
things and coming up with new original
- 1:39
jokes for YouTube tutorials like there
- 1:41
might be a function called get random
- 1:43
number you automatically think it's
- 1:44
always going to return a different
- 1:45
number but when you call it it returns
- 1:47
three every time it's not a bug because
- 1:49
had you read the documentation you know
- 1:51
that 3 is a random number that was
- 1:52
chosen by the developer in advance who
- 1:54
guaranteed that it was 100 random when
- 1:56
he chose it with the roll of a die
- 1:57
reading documentation in advance is
- 1:59
important but developers also tend to


