John Carmack: Best programming setup and IDE | Lex Fridman Podcast Clips - YouTube

Channel: Lex Clips

[2]
what about your setup how many screens
[6]
what kind of keyboard is there something
[7]
interesting what kind of i ide
[10]
emacs vim or something modern
[13]
uh linux what operating system laptop or
[16]
any any interesting thing that brings
[18]
you joy so i kind of migrated cultures
[21]
where early on through all of game dev
[23]
there was sort of one culture there
[25]
which was really quite distinct from the
[26]
more uh the silicon valley venture you
[29]
know culture for things it's they're
[31]
different groups and they have pretty
[33]
different mores and the way they think
[34]
about things where
[36]
and i still do think a lot of the big
[38]
companies can learn uh can learn things
[40]
from the hardcore game development side
[42]
of things where it still boggles my mind
[45]
how
[45]
i am how hostile to debuggers and ides
[49]
that so much of the the kind of big
[51]
money get billions of dollars silicon
[54]
valley venture-backed funds are well
[56]
that's interesting sorry so you're
[57]
saying like
[59]
like uh big companies that google and
[60]
meta are hostile to they are not big on
[63]
debuggers and ides like so much of it is
[65]
like emacs bim for things and we just
[68]
assume that debuggers don't work most of
[71]
the time i for the systems and a lot of
[73]
this comes from a sort of linux bias on
[76]
a lot of things where i did come up
[78]
through the the personal computers and
[80]
then the dos and then
[82]
windows and
[83]
and it was borland tools and then visual
[86]
studio and
[88]
do you appreciate the buggers
[90]
very much so i mean a debugger is how
[92]
you get a view into a system that's too
[94]
complicated to understand i mean anybody
[96]
that thinks just read the code and think
[98]
about it that's an insane statement in
[100]
the you can't even read all the code on
[102]
a big system you have to do experiments
[104]
on the system and doing that by adding
[108]
log statements recompiling and
[109]
re-running it uh is an incredibly
[111]
inefficient way of doing it i mean yes
[113]
you can always get things done even if
[115]
you're working with stone knives and you
[117]
know and bear skins that's that is the
[119]
mark of a good programmer is that given
[121]
any tools you will figure out a way to
[123]
get it done
[124]
but
[125]
it's amazing what you can do with
[127]
sometimes much much better tools where
[129]
instead of just going through this
[131]
iterative compile run debug cycle and
[134]
you have the
[135]
you have the old lisp direction of like
[137]
you've got a reply and you're working
[138]
interactively and doing amazing things
[140]
there but in many cases a debugger has a
[142]
very powerful user interface that can
[145]
stop examine all the different things in
[146]
your program set all these different
[148]
break points and of course you can do
[149]
that with gdb or whatever there but
[153]
this is one of the user interface
[154]
fundamental principles where when
[156]
something is complicated to do you won't
[159]
use it very often there's people that
[161]
will break out gdb when they're at their
[163]
wit's end and they just have beat their
[165]
head against a problem for so long but
[167]
for somebody that kind of grew up in
[169]
game dev it's like they were running
[170]
into the debugger anyways before they
[172]
even knew there was a problem and you
[174]
would just stop and see you know what
[176]
was happening and sometimes you could
[177]
fix things even before you you know
[180]
even before you did one compile cycle
[182]
you could be in the debugger and you
[184]
would say well i'm just going to change
[185]
this right here and yep that did the job
[187]
and fix it and go on and for people
[189]
don't know gdb is a sort of popular i
[192]
guess linux debugger
[194]
uh
[195]
primarily for c plus
[196]
they they handle most of the languages
[198]
but it's you know it's based on c as the
[200]
the original kind of unix heritage but
[202]
and it's kind of like command line it's
[204]
not user friendly it's not it doesn't
[205]
allow for clean visualizations and
[207]
you're you're exactly right just so
[209]
you're using this kind of debugger
[211]
usually when you're what's end and
[213]
there's a problem that you can't figure
[215]
out why by just looking at the codes
[216]
they have to find it that's how i guess
[219]
normal programmers use it but you're
[221]
saying there should be tools that kind
[222]
of
[223]
visualize and help you as part of the
[225]
programming process
[227]
just a normal programming process to to
[230]
understand the code deeper yeah when i'm
[232]
working on like my cc plus plus code i'm
[235]
always running it from the debugger you
[237]
know just i type in the code i i run it
[240]
many times the first thing i do after
[241]
writing code is set a breakpoint and
[243]
step through the function now other
[245]
people say it's like oh i do that in my
[247]
head well your head is a faulty
[249]
interpreter of all those things there
[251]
and i've written brand new code i want
[253]
to step in there and i'm going to single
[254]
step through that examine lots of things
[256]
and see if it's actually doing what i
[258]
expected it to
[260]
it is a kind of
[262]
companion the debugger like you're
[265]
you're now coding in an interactive way
[266]
with another
[268]
being
[269]
a debugger is a kind of dumb being but
[271]
it's a reliable being
[273]
that is an interesting question of what
[274]
role does ai play in that kind of
[277]
with codex and these kind of
[280]
ability to generate code might be you
[282]
might start having tools that
[285]
understand the code in interesting deep
[287]
ways that can work with you because
[289]
there's a whole spectrum there from
[291]
static code analyzers and various kind
[294]
of dynamic tools they're up to ai that
[296]
can conceivably grok these programs that
[298]
no literally no human can understand
[301]
they're they're too big too intertwined
[302]
and too interconnected but it's not
[304]
beyond the possibility of understanding
[307]
it's just beyond what we can hold in our
[309]
heads as kind of mutable state while
[311]
we're working on things
[312]
and
[313]
and i'm a big proponent again of things
[315]
like static analyzers and some of that
[317]
stuff where
[319]
you'll find some people that don't like
[321]
being scolded by a program for how
[323]
they've written something where it's
[325]
like oh i know better and sometimes you
[327]
do but that was something that
[329]
i was it was very
[331]
very valuable for me when uh and not too
[334]
many people get an opportunity like this
[335]
to have this is almost one of those
[336]
spiritual experiences as a programmer an
[339]
awakening to
[340]
i am theod software code bases were a
[342]
couple million lines of code and at one
[345]
point i had used a few of the different
[347]
analysis tools but i made a point to
[350]
really go through and scrub the code
[352]
base using every tool that i could find
[355]
and it was eye-opening where we had a
[356]
reputation for having some of the the
[358]
most robust strongest code you know
[360]
where there were some you know great
[362]
things that i remember hearing from
[364]
microsoft telling us about crashes on
[366]
xbox and we had this tiny number that
[368]
they said were were probably literally
[370]
hardware errors and then you have other
[372]
significant titles that just have
[374]
millions of faults that are getting
[375]
recorded all the time so i was proud of
[377]
our code on a lot of levels but when i
[380]
took this code analysis squeegee through
[383]
everything
[384]
it was
[385]
it was shocking how many errors there
[388]
were in there things that you can say
[389]
okay this was this was a copy paste not
[392]
changing something right here lots of
[394]
things that were you know the most the
[396]
most common problem was something in a
[398]
printf format string that was the wrong
[400]
data type that could cause crashes there
[402]
and you know you really want the
[404]
warnings for things like that then the
[405]
next most common was missing a check for
[407]
null that could actually happen that
[409]
could blow things up and those are
[411]
obviously like top cc plus plus things
[413]
everybody has those problems but the
[415]
long tail of all of the different little
[418]
things that could go wrong there and we
[419]
had good programmers and my own codes
[422]
that i'd be looking at it's like oh i
[423]
wrote that code that's definitely wrong
[425]
we've been using this for a year and
[428]
it's this submarine you know this mine
[431]
sitting there waiting for us to step on
[433]
and
[434]
it was humbling it was uh and i reached
[437]
the conclusion that
[439]
anything that can be syntactically
[440]
allowed in your language
[442]
if i'm
[444]
it's gonna show up eventually in a large
[445]
enough code base i you're not gonna good
[448]
intentions aren't going to keep it from
[450]
happening you need automated tools and
[452]
guardrails for things and those start
[454]
with things like static types and or
[456]
even type hints in the more dynamic
[458]
languages but
[459]
the people that rebel against that that
[462]
basically say uh that slows me down
[465]
doing that there's something to that i
[466]
get that i've written you know i've
[468]
cobbled things together in a notebook i
[470]
i'm like wow this is great that it just
[472]
happened but yeah that's kind of sketchy
[474]
but it's working fine i don't care it
[476]
does come back to that that value
[478]
analysis where sometimes it's right to
[480]
not care
[481]
but when you do care if it's going to be
[484]
something that's going to live for years
[485]
and it's going to have other people
[487]
working on it i and it's going to be
[489]
deployed to millions of people
[491]
then you want to use all of these tools
[493]
you want to be told it's like no you've
[494]
screwed up here here and here and that
[496]
does require kind of an ego check about
[499]
things where you have to
[502]
to be open to the fact that everything
[503]
that you're doing is just littered with
[505]
flaws it's not that oh you occasionally
[507]
have a bad day it's just whatever stream
[510]
of code you output there is going to be
[511]
a statistical regularity of things that
[513]
you just make mistakes on
[516]
and i
[517]
and i do think there's the whole
[518]
argument about test driven design and
[521]
unit testing versus kind of analysis and
[523]
different things
[525]
i am more in favor of the analysis and
[527]
the stuff that just like you can't run
[529]
your program until you fix this rather
[531]
than you can run it and hopefully a unit
[533]
test will catch it in some way yeah in
[535]
my private code i have asserts
[538]
everywhere yeah uh
[540]
just there's something
[542]
pleasant to me pleasurable to me about
[544]
sort of the dictatorial rule of like
[547]
this should be true at this point
[550]
in too many times
[552]
i've
[553]
made mistakes
[555]
that shouldn't have been made
[557]
and i would assume
[559]
i wouldn't be the kind of person that
[560]
would make that mistake but i keep
[561]
making that mistake therefore and the
[563]
cert really catches me
[565]
uh really helps all the time so my co i
[568]
would say like 10 to 20 percent of my
[570]
private code just for personal use is
[572]
probably a certain and they're active
[574]
comments that's one of those things that
[575]
in theory they don't they don't make any
[578]
difference to the program and if it was
[579]
all operating the way you expected it
[581]
would be then i they will never fire but
[585]
even if you have it right and you wrote
[587]
the code right initially then
[589]
circumstances change the world outside
[591]
your program changes and in fact that's
[594]
that's one of the things where i'm kind
[596]
of fond in a lot of cases of static
[598]
array size declarations where i went
[600]
through this period where it's like okay
[602]
now we have general collection classes
[603]
we should just make everything variable
[605]
i because i had this history of in the
[608]
early days you get doom which had some
[611]
fixed limits on it then everybody
[612]
started making crazier and crazier
[614]
things and they kept bumping up the
[615]
different limits this many lines this
[617]
many sectors
[618]
uh and it seemed like a good idea well
[621]
we should just make this completely
[622]
generic it can go kind of go up to
[624]
whatever
[625]
and
[626]
there's cases where that's the right
[628]
thing to do
[629]
but it also the other aspect of the
[631]
world changing around you is it's good
[634]
to be informed when the world has
[635]
changed more than you thought it would
[637]
and if you've got a continuously growing
[639]
collection you're never going to find
[641]
out you might have this quadratic
[642]
slowdown on something where you thought
[645]
oh i'm only ever going to have a handful
[647]
of these but something changes and
[648]
there's a new design style and all of a
[650]
sudden you've got 10 000 of them
[652]
so i kind of like in many cases
[655]
picking a number some you know nice
[657]
round power of two number and setting it
[660]
up in there and having an assert saying
[661]
it's like hey you hit the you hit this
[663]
limit you should probably think are the
[665]
choices that you've made around all of
[667]
this still relevant if somebody's using
[670]
10 times more than you thought they
[672]
would yeah this code was originally
[673]
written with this kind of world view
[676]
with this kind of set of constraints you
[678]
were you were thinking of the world in
[680]
this way
[681]
if something breaks that means you got
[683]
to rethink the initial stuff and that's
[685]
it's nice for it to afford for it to do
[688]
that is there any stuff like uh keyboard
[690]
or
[692]
monitor i'm fairly pedestrian on a lot
[695]
of that where i i did move to triple
[697]
monitors like in the last several years
[699]
ago i had been dual monitor for a very
[701]
long time and i am and it was one of
[704]
those things where
[705]
probably years later than i should have
[707]
i'm just like well the video cards now
[709]
generally have three output ports i
[710]
should just put the third monitor up
[712]
there that's been a that's been a pure
[713]
win i've been very happy with that
[716]
but no i don't have fancy keyboard or
[718]
mouse or anything really the key things
[721]
is an ide that has uh helpful debuggers
[724]
has helpful tools
[726]
so it's not the emacs vim route and then
[728]
diet coke yeah so i did spend you know i
[731]
spent uh one of my week-long retreats
[733]
where i'm like okay i'm gonna make
[734]
myself use uh there's actually classic
[737]
vi which i know people will say you
[738]
should never have done that you should
[739]
have just used vim directly but you know
[742]
i gave it the good try it's like okay
[744]
i'm being in kind of classic unix
[746]
developer mode here and i worked for
[749]
a week on it i used anki to like teach
[752]
myself the the different little key
[754]
combinations for things like that and in
[756]
the end it was just like all right this
[758]
was kind of like my civil war
[759]
reenactment phase you know it's like i'm
[761]
going out there doing it like they used
[763]
to in the old days and it was kind of
[765]
fun in that regard so many people right
[766]
now
[768]
screaming as they're listening to this
[770]
so again the out is that this was not
[772]
modern vim but still i yes i was very
[775]
happy to get back to my visual studio at
[778]
the end yeah i'm actually i struggle
[780]
with this a lot because
[782]
so use a kinesis keyboard and um
[785]
i use emacs primarily
[788]
and i i feel like i can
[790]
exactly as you said i can understand the
[792]
code i can navigate the code there's a
[793]
lot of stuff you could build within
[795]
emacs with using lisp you can customize
[798]
a lot of things for yourself to help you
[800]
introspect the code like to help you
[802]
understand the code and visualize
[804]
different aspects of the goal you can
[805]
even run debuggers but it's it's work
[808]
and the world moves past you and the
[811]
better and better ideas are constantly
[812]
being built and that that puts a
[816]
kind of
[817]
i need to take the same kind of retreat
[819]
as you're talking about but now i'm
[821]
still fighting the civil war i need to
[823]
kind of move into the 21st century and
[825]
it does seem like the world is or a
[827]
large chunk of the world is moving
[829]
towards visual studio code which is kind
[831]
of interesting to me against the
[832]
javascript ecosystem on the one hand and
[836]
ids are one of those things that you
[837]
want to be infinitely fast you want them
[840]
to just kind of immediately respond
[843]
and like i mean heck i've got there's
[844]
someone i know i'm an old-school game
[846]
dev guy that still uses visual studio
[848]
six and on a modern computer everything
[852]
is just absolutely instant on something
[854]
like that because it was made to work on
[856]
a computer that's
[857]
ten thousand or a hundred thousand times
[859]
slower so just everything happens
[861]
immediately and all the modern systems
[864]
just feel
[865]
you know they feel so crafty when it's
[867]
like oh why is this refreshing the
[868]
screen and moving around and updating
[870]
over here and something blinks down
[872]
there and you should update this and
[874]
there's
[875]
you know there there are things that
[877]
we've lost with that incredible
[878]
flexibility but
[880]
uh lots of people get tons of value from
[882]
it and i am super happy that that seems
[885]
to be winning over even a lot of the old
[886]
vim and emacs people that they're kind
[888]
of like hey visual studio codes maybe
[890]
you know not so bad i am that may be the
[893]
final peacekeeping solution where
[895]
everybody is reasonably happy with i
[898]
with something like that
[919]
you