Um, I alsohelpedrunOklahomaCityin a PalmCitymechanicalkeyboardusergroup.
Soifyou'reinterested, hewouldsetmeup, andwecan I canshowyouwhereallthatstuffthat's prettypretty, prettydorky.
But I have, umSomyplanwiththistalkisbasically I'm gonnagivesomeHi, I'm reallylikehighlevelconceptsonsomestuff.
Andifitiscompleteandutternonsense, asmostofitwillbeinitially I willcirclebacktoprettymucheverybulletpoint I haveandkindofexplainmoreindepthwhatthosethingsare.
Butifyouhavequestionsbeforethat, ifyouhavequestionsafterthat, justkindofwaveatme, getmyintention, I'm behappytoanswerasmanyquestionsas I can.
It's generallyusedtomakeWebserversanddevelopertools, sofirstthingrightoffthebatistalkingabout V eight.
Um, ifyouhaven't writtenbefore, you'veprobablynotreallyheardmuchabout V.
A IstheJavascriptengineinsideofchromethatisusedtoexecuteexecutetheJavascriptyouhaveonyourwebsite.
Soifyoueverhavebuilt a websitewithdramascript, otherusingjustplainJavaScriptusingangularreactJsanythinglikethat, Uh, whenyourunthatapplicationinsideof a Webbrowser, thepartthatactuallyexecutethedramascriptis V eight.
Um, ifyouguyshaveeverprogrammedanything, I'vesureyou'veseenthisbefore, butthisisjust, umwhoonheredoesn't haveexperienceofjobsbefore I getstartedonthis, theydidn't have a lotofexperiences.
Likeanyexperience.
Okay, good.
So I won't explainwhatconcertlogis, but, um, we'regonnagoahead, justrunthat, andrightthere, it's printedout.
Hello, world.
Sohowweranthisapplicationaswejustcallthenote, execute a bowlandtolditwhatscriptwantedtorun, andthenit'llrunthroughthatscript, andwithout a browser, itwillexecuteallofthedrama.
Thisis a superexcitingexample, butitgoestoshowjusttheabilitytorunJavascriptwithout a Webbrowser.
Sowe'llgoto a littlebitmoreindepthexamplethatshowssomestuffthatyoucouldn't necessarilydoingchrome, and I'llgoaheadandrunthroughwhatthiscodedoesbefore I runit.
Firstthingitdoesis a princeHelloWorldforyouguysagain.
Thenaccessis a globalvariablethat's a partofnocalledprocess, whichissomethingthat's nospecificandyoudon't youdon't reallydointhebrowser.
And, uh, itstores a lotofmetadataaboutwhatapplicationyou'rerunningand a lotofglobalthinggoingglobalthingstoit.
Soifyouhavevariablesthatyousetoutsideoftheapplicationorsomethinglikethatandwe'reaccessingtheargumentsonit, sobasically I wanttocallthisapplicationandpassthearguments, andthenit's goingtoiteratedthroughallthoseargumentsandprintoutwiththevaluesofthemall r andthen a printweredonewhenwe'redone.
Whenyou'rerunningWebapplications, they'rerunningon a Webserversomewhere.
Say, youhave a, forinstance, thatyouhave a tweetsthathas a pictureinit.
I don't knowhowexactlyTwitterhandleswereimagesofhowyoucouldhandleitishecouldsaveitlocallyontothatWebserver, whichyoucan't, whichmeansthatanybodywhomakes a requesttothatWebserverthatWebsterwillthenaccessthefilesystemontheWebservantsintheimagedown, soithas a centralizedplaceforallofyourtweets.
Anexampleofthatwouldbeyousend a tweetthathas a linkto a freecodecampblockpost.
AndwhenyouseethatsweetonTwitter, you'llseelikeusuallylike a littleimagethathastodowithit.
Thelink A couplesentencesaboutthelink.
WhathappensisyousaidThat's whereitgoesfromyourbrowserto a WebservertoTwitter's Webservers.
ThenTwitter's Webserversseethere's only a minuteandthenmake a networkrequesttofreecodecanslipserverssononeofthathappensonyourcomputer.
Itallhappensontheirserver.
Webserverscouldbewritten a notewritteninJava, Ruby C.
Sharpand a hostofotherlanguages.
Todaywe'regonnabefocusingonnotewhat I justdescribedtoyouguys, thoughithas a specificname, it's calledtheClientServermodel, andit's a waytosplitresponsibilitybetweenyourWebserverandtheuser's browser, wheretheWebserverhandlesdatabasesinherclientcommunicationandauthentication.
Theclienthandlesyoulogicrequests, infofromotherservers, stores, datain a database.
Um, forinstance, withsomethinglikeFacebook.
IfyouareonFacebookMessenger, you'd send a messagetosomebodyonFacebook.
Andonceagain, thisisgonnabenonsenseuntil I kindofbreakitdownandexplainitstepbystep.
ButnoJsisgoodforasynchronous.
Not a secondofapplicationsthatrequirenonblockinginputoutput.
Andoureventdrivendoesn't meanmuch.
I'llshowyouexamples.
No, JessisnotgoodforCPUintensivetasks, soanythingthatrequires a lotofmathmachinelearning a I stufflikethatnoteisn't verygoodatthatbecauseitdoesn't have a waytohandleitin a nonblockingway.
So, like I mentionedearlierwhen I mentioneduh, notblockingeventsandasynchronous I knowwhatthatmeansissosayyouhad a Webserverthatread a filefromthefilesystem.
Incentivebackdownto a client's browser.
Whoisrequestingitthatsayitwasanimage.
Sometimesreadingfilesfromfilesovertakestimesoyoucouldhave a veryslowdiskanditcouldtake a coupleseconds.
Soperson A, withtheirWebbrowser, makestherequestforthatimage.
PersonbewithanotherWebbrowser, thenmakes a requesttothesameWebserver, buttheyrequestsomethingthat's a lotquicker.
Forinstance, theywanttogettheinformationabout a user.
Soperson A makestherequestandbecausetheinputoutputandnoticednonblocking, itbasicallypushesthatofftothebackgroundbyitselfandcontinuesthatthatdiscreetwhilepersonbecanreallymake a requestforthatuserinformation, pullitbackdownanditgetspushedbackdowntotheircomputerjustfine.
Then, whenperson A Whentheimagesdoneloadingfromthedisk, itgetssentbackdowntopersonnel.
Whatwhathappened?
Andsomethingthatwasnotwasnotnonblockingherwasblockingisoneperson a madetherequestforthatimage?
Theserverwouldstopeverythinguntilthatimagewasreadinfromthediskandpersonbewouldbestuckwaitingtoseetheprofileinformation, eventhoughthat's a lotquickerthanwhatperson A istryingtodo.
Sothey'd havetowaitforperson a togetdonebeforetheycoulddoanythingin.
Thequestionwas, what's anexampleofsomethingthatwouldbesynchronisedversuswhyjustmentionedthatsomethingthatwas a synchronousSoreadingthatimagefromyourdiskonyourcomputercouldbesynchronousbutnodoesitinanasynchronousaway.
Sowhat?
Thatwhat I meanbythatiswhenyouwhenyoumakethatrequestforthatimagelike I said, nodepushesitoffintothebackground, continuesdoingotherthings.
Ifitwassynchronousandyoucouldread, youcannoteyoucanactuallyreadandyoureadsomefromthefilesystemin a synchronousway, but a lotofwhatit's likedefaultasynchronous.
Httphas a functiononitcalledCreateServerandyougivethatfunction a callback.
Andwhatthatmeansis, anytimeanybodyismakemakesrequeststotheserver, thishighlightedcodewillexecute, and I'llshowyouin a secondwhatthishighlightedcouldactuallydoes.
It's doingsomething a littlebitdifferentontherequest, but I gointothatin a secondport 8000 samedealcallingserverdotlisten, and I'm sayingtheservicestartedaslisteningonPort 8000.
Solet's goaheadandstartitup.
Startingatthesameway.
NoteinthefilenameserverstartedonPort 8000.
Sowhatisthisdoingdifferent?
Thishonorquestiscallingmyrouterfunctionongivingit a variablethatisontherequestthattheusersendsthem.
So I spoke a littlebitearlieraboutthis.
Getuphere.
There's alsopostputdelete.
It's takingthisandit's performing a differentactionbasedonwhatkindofissuetoberequestisbeingmade.
Thiswillgiveittoyouin a waythat's a loteasiertoconsuming a loteasiertohandlerequestshas a methodonthere, has a propertyon a calltoyour l rememberthatrequestiswhattheclientissendingyoutheWebserver.
Soittakesusyourhorses, it.
Andthenthere's a parameteronitcalledQuerybeingthisquarryarguments.
And I'm gettingthatprimeroftenassigning a query.
Andthisisgonnabelittlebitmoreofthesameresponse.
Thatrighthead I'm writing a 200 sayingeverythingwassuccessfulinthethatJasonis a typeofdata I'm sendingbacktotheclient.
Andthen I'm writingthemessage, which I'm sayingthanksforgetting.
It's oneofthefewwaysofJavascriptoffersencapsulationifanybodyknowswhatthatis, sonowwe'regoingtotalkaboutthepostrequest, whichis a littlebitmorecomplicated.
Luckily, youprobablywon't everactuallydothis.
There's a lotofthere's a lotofnotelibraries.
That's, um, thatdistractthisforyou.
Soyoudon't havetogetdownanddirtyreadingthisdateinlikethis, but I'm gonnakindofshowyouwhatitlookslike.
Andifyoudon't understandhowsomeofthedataisbeingreadandit's not a hugedeal, like I said, you'renotgonnadothisrightoffthebat.
So I wanttogoaheadandmakethatpost.
I'veactuallygotitrighthere, sodon't typeitallout.
So I'vegotitsettoposthere, whichmeanshey, whichmeans a clientsaying, Hey, server, goaheadandcreatethisdataandsaveit.
Howeveryouneedtosaveit.
I'm tellingtheserverrightherein a headerthattheconstanttypeit's gonnabe a basically a formUm, thisisthecontenttypeyouusuallyuseIfyou'refillingout a formon a website, remember, thiscontenttypebetteristhesamethingthattheserverusedtotelltheclientthatthey'resendingbackdown.
A lotofit's very, very, very, verygoodandprettymuchindispensabletothenodeecosystem.
Solet's talkaboutwhat a packagemanagerin a registry.
Ourpackagemanageris a wayofmanagingcode.
Yourprojectdependsonmakesiteasytoincorporatenewcodeinto a projectandhelpsmaintainconsistencybetweeninstallationsofyourproject.
Sosayyouhave a dependencyon a librarythatsomebodyelsewrote.
A packagemanagermakesiteasytoincorporatethatlibraryandbringoutlibraryintoyourproject.
Itcreates a wayforotherpeoplewhoareusingtheprojecttoknowwhatlibrariesyourcodeisusing.
Sothatway, whenyou'redevelopingsomethingandthenyourfriendtakesoverandstartsdevelopingitoryourcoworkertakesoverandstartdevelopingit, theyhave a waytoreinstallallthosepackagesthatyou'reusing.
Sothepackagemanagerletsyouhandlethosepackagesonyourcomputer, downloadtheminstalledoneverythingpackageregistryis a placewhereyoucanuploadcodeforotherpeopletouse.
Sousethemanagertoaccesstheregistry.
Basically, doesanybodyhaveanyquestionsaboutin P.
M?
I'm gonnagointosomeexamplesofhowthisallworksandsetup a projectusingin P.
M.
Injust a moment, allrights.
Sowe'regonnacreate a newdirectorhere, callittestsin P.
M.
I didnotcreatetherightplace.
Sohowyoucreate a newprojectandsaythisistheproductisgonnabethat's gonnausein p m eithertobeuploadedtoinPM's websitelaterforotherpeopletouseorforyoutodownloadotherpeople's packagestouseonyourapplication.
Youtypein P M.
Minutes.
Andthisisanexampleof a developertoolthatwaswritten a note.
Soit's gonnaask a couplequestionsforhow I wanttosetupthecoat, howtheywantusoutoftheproject.
Everythingelsethatwehadfromthenotestandardlibrarystuff, thestuffthat I'vewrittenmyself a lotofpeoplewillnamethevariableloadashandunderscoreuh, youcouldnamethisyoucouldnameisLowDashorwhateverelseyouwantedto.
Butmostpeoplejustcallunderscore.
SoifyoueverseeanybodyusingunderscorednotsomethingandJavaScriptthereeitherusingloadafterunderscoreprobablytodostuffandthere's like I said, there's there's tonsofotherpackagesonin P m thatabstractaway.
A lotofthenastystuffthat I wasdoinginthatpostrequestOnepopularoneiscalledExpress.