Looking Under the Hood of JavaScript

  Рет қаралды 173,432

ThePrimeagen

ThePrimeagen

Жыл бұрын

Ever wonder what in the world is going on with JS? Well in this we deep dive into v8, into the internals to figure out WTF IS GOING ON WITH SETTIMEOUT???
SMI in v8?? v8.dev/blog/pointer-compression
Aleksei: / the_kozy
Twitch
Everything is built live on twitch
Twitch : bit.ly/3xhFO3E
Discord: discord.gg/ThePrimeagen
Spotify DevHour: open.spotify.com/show/4MLaDrQ...
Editor
All my videos are edited by Flip. Give him a follow! / flipmediaprod He is also open to do more editing, so slide deeeeeeeeep into his dms.
Join this channel to get access to perks:
/ @theprimeagen
Links
Linode: linode.com/prime
/ discord
Twitch: / theprimeagen
Insta: / theprimeagen
Twitter: / theprimeagen
VimRC & i3: github.com/ThePrimeagen/.dotf...
Keyboard 15% off bit.ly/Prime360 USE CODE PRIME360
#coding #neovim #typescript #programming #vim #softwareengineering #codinglife #webdesign #webdevelopment #webdev #javascript #rustlang #rust #twitch #twitchstreamer #programmerhumor #codinghumor #software #softwareengineer #softwaredeveloper #softwaredevelopment

Пікірлер: 574
@ThePrimeagen
@ThePrimeagen Жыл бұрын
I really enjoyed making this video. Its more of a new style for me, do you like it? Should I do more of this style? (send the algorithm signals!!!)
@the_flask
@the_flask Жыл бұрын
Yes
@dhruvtekker1220
@dhruvtekker1220 Жыл бұрын
It's super complicated and i didn't understand most of it. But i liked it bc i wanna learn more about js--> c++ stuff
@matiasbpg
@matiasbpg Жыл бұрын
I loved the video. It's really difficult to give content like this that deep dive into the internals
@mouradaouinat8721
@mouradaouinat8721 Жыл бұрын
Duh
@user-alesomething123
@user-alesomething123 Жыл бұрын
Yes please, I really like that the content is aimed towards explanation for intermediary stuff. Especially the fact that you’ve posted a link for further explanation and I can go and see things I don’t understand. There’s already content on KZbin code space aimed towards beginners and people with an agenda to obscure info to sell a course. It’s why I mostly avoid KZbin these days and just focus on odin project.
@RunningRay9
@RunningRay9 Жыл бұрын
this shows that JS is BLAZINGLY fast. It executes a code that is supposed to take infinitely long time in just an instant. Blazingly fast
@wlockuz4467
@wlockuz4467 Жыл бұрын
It has done executing while Rust hasn't even compiled!
@wadecodez
@wadecodez Жыл бұрын
Or is it infinitely fast?
@igorordecha
@igorordecha Жыл бұрын
@@wlockuz4467 I just thought... You have an algorithm written in both JS and Rust (both in source form). You enter commands "node program.js" and "cargo build && ./target/debug/program" respectively and measure time from pressing enter to the program returning. How large the input must be (the N in big O notation) for rust to win? Then check how building for production changes the results.
@kamuridesu
@kamuridesu Жыл бұрын
@@igorordecha I made this test some time ago with python and it really depends on the operation and performance of the machine. Using an 7th gen Intel core i7 and a simples multiplication operation, even with compilation rust executed faster than Python. I assume that JavaScript has a performance similar, if not worse, than python
@HuntingKingYT
@HuntingKingYT Жыл бұрын
@@igorordecha cargo run**
@kebien6020
@kebien6020 Жыл бұрын
To summarize (please correct me if I misunderstood): - The infinity case is just special handling where it's treated the same as 0 - Any other number gets casted to a 32 bit integer so some of the bigger numbers get truncated to small or even negative values - Negative values are handled effectively the same as 0
@ricardoamendoeira3800
@ricardoamendoeira3800 Жыл бұрын
What I don't understand is if you're making a special case for infinity why would you run it immediately instead of simply not scheduling it at all?!
@MrSuperNova46
@MrSuperNova46 Жыл бұрын
@@funnyav "This is the way"
@alxandr90
@alxandr90 Жыл бұрын
@@ricardoamendoeira3800 As far as I understood, the converting of Infinity to 0 has nothing to do with `setTimeout`. Rather, `Infinity` converts to 0 if you try to treat it as an integer. If you do `Infinity | 0` you get 0.
@nathanhedglin931
@nathanhedglin931 Жыл бұрын
@@funnyav divide by zero would be NaN. Weird stuff
@rosenthalpiano
@rosenthalpiano Жыл бұрын
@@nathanhedglin931 setTimeout with NaN also executes immediately. Fun huh?
@mattshnoop
@mattshnoop Жыл бұрын
Excellent video. This video has less of a "look how shitty JS is" vibe and is more just a great deep dive into the internals of V8.
@ThePrimeagen
@ThePrimeagen Жыл бұрын
thats the point! no need to bag on JS, its been bagged on enough, its more "why" does it do something
@some-dev8884
@some-dev8884 Жыл бұрын
👍👍
@ricardoamendoeira3800
@ricardoamendoeira3800 Жыл бұрын
@@ThePrimeagen Actually I think this was more the "how it happens", in the future it would be nice to include the discussions on why some decisions were made (from issue trackers, PR's, etc. For example why choose to treat infinity as 0 instead of not scheduling the callback at all.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
So basically, it is V8 that is shitty.
@jongeduard
@jongeduard Жыл бұрын
For me it's not completely the first thing about V8 that I have watched around the subject of data types. I forgot which video it was, but it was some years ago and they had a very detailed explanation about the V8 engine and how you could write your code smarter to become more high performant. They also talked about SMI numbers and how using arrays of SMI's where the most efficient ones to use (because of preventing those extra pointers and memory allocations), also how important it was in general not to mixup several types in the same array. For example 1 object or string inside your array also containing numbers makes the whole thing based on extra pointers and allocations (in other words, the whole array becomes a boxed one). It's also true the language has a ton of initial design problems. But other languages also have their issues. C and C++ have their own huge problems for example (being very unsafe and vulnerable for example). It's great that powerfull JS engines exist these days. I would like to know more about the Firefox JS engine as well. Because V8 is not the only workhorse one that exists.
@snoopy8870
@snoopy8870 Жыл бұрын
this type of content on programming is what we need more!!!
@chrismuga
@chrismuga Жыл бұрын
Facts
@DiscipleW
@DiscipleW Жыл бұрын
@@chrismuga
@spicybaguette7706
@spicybaguette7706 Жыл бұрын
Massive props to the v8 devs for making a garbage (collecting) language actually performant, these optimizations are just insane. Also SO to the people working at JSC and SpiderMonkey
@ThePrimeagen
@ThePrimeagen Жыл бұрын
yayay! its nuts that v8 team is so talented they took a language that is TERRIBLE for perf and made it semi decent. its ackshually nuts.
@Nurof3n_
@Nurof3n_ Жыл бұрын
More videos like this one please!
@ThePrimeagen
@ThePrimeagen Жыл бұрын
ya!
@DiscipleW
@DiscipleW Жыл бұрын
​@@ThePrimeagen And make them pretty LongLongLong xD
@peternoire
@peternoire Жыл бұрын
I know we are kinda making fun of JavaScript but.. its so educational it just makes me love JavaScript more. You're great at doing this type of content. Definitely do more.
@peternoire
@peternoire Жыл бұрын
I said we as in we made this video together apparently. I don't know why I typed that.
@ThePrimeagen
@ThePrimeagen Жыл бұрын
btw, i am not trying to make fun of javascript, just trying to have fun with it :) and try to explain things in a fun way!
@RainOrigami
@RainOrigami Жыл бұрын
classic case of stockholm syndrome
@peternoire
@peternoire Жыл бұрын
@@ThePrimeagen you killin it, thanks for the good content. 👍
@professornumbskull5555
@professornumbskull5555 Жыл бұрын
Yo... You love JS? Are you alright? Do you need therapy? /s
@scottiedoesno
@scottiedoesno Жыл бұрын
Love love love this video. This is the kind of stuff that really gives so much insight into what's going on behind the scenes. Thanks a ton for taking the time, not only to figure out why, but also to explain it so well.
@ThePrimeagen
@ThePrimeagen Жыл бұрын
:) ty bud !!
@johndavidson8096
@johndavidson8096 Жыл бұрын
Great video! Love seeing in-depth JS stuff! It's crazy impressive how much work V8 does to make JS run faster
@SoKette
@SoKette Жыл бұрын
Diving into internals is always fun ! When everything gets demystified after a long and arduous journey of grepping and filling your brain with as much as you can, it's sooooo satisfying.
@ThePrimeagen
@ThePrimeagen Жыл бұрын
I also didn't fight anyone, i got a stye, a duct in my eye closed and eff'd me for a few days...
@tini_
@tini_ Жыл бұрын
hmmmm, your last sentence "he is the best Engineer I have ever worked with" sounded kinda sus. Blink twice with the other eye if you need help!
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
Hey, it was a chance to use the old “you should see the other guy” joke ...
@user-dz7bi8de7z
@user-dz7bi8de7z Жыл бұрын
I am so happy that I stumpled across this channel. You are such an inspiration, your videos are so well made, funny and you are very authentic. Love it! Thank you very much for your content!
@bryanchulander
@bryanchulander Жыл бұрын
This is so entertaining as well as informative. Learned a lot! Found you from the vim and algorithm courses on frontend master . Huge fan of your teachings
@m.minkov
@m.minkov Жыл бұрын
Really enjoyed this video! Love covering these details that are much more in depth than what you regularly see. Thanks! :D
@judedavis92
@judedavis92 Жыл бұрын
It’s actually refreshing to see a JS dev with a good understanding of under-the-good mechanics. We need more like that.
@SuperRedstoneman
@SuperRedstoneman Жыл бұрын
Saddens me that not more people are doing videos like this and there are some concepts you go through very quickly but nevertheless I like how you explained a single thing in detail quickly while throwing in knowledge and remarks about how things work
@LiveType
@LiveType Жыл бұрын
I remember at one point in time, long ago, being very confused by fixed point numbers. Floats are horrifically slow on microprocessors that don't have dedicated floating point hardware. This somehow brought me back to that time.
@JosephHenryDrawing
@JosephHenryDrawing Жыл бұрын
This is really important to teach that! Don't be afraid to understand the internals and check the source code. Amazing video
@samsupplee-niederman1752
@samsupplee-niederman1752 Жыл бұрын
More of this, please. I've never seen what "under the hood" of JS before this video, and this was an awesome introduction to the WHY behind the weirdness.
@vvarhand3985
@vvarhand3985 Жыл бұрын
I loved this!! Would really enjoy seeing more intricate and technical details of the browser’s implementation. You have a great instructional style
@masteringmui
@masteringmui Жыл бұрын
This video was awesome. I'd love more stuff like it, and also more stuff on your learning process and how you set about getting such in-depth knowledge on nitty-gritty stuff like this.
@Simon-vy8fe
@Simon-vy8fe Жыл бұрын
Love these deep dives! Keep them going please. :)
@mediopalodev
@mediopalodev Жыл бұрын
Brilliant Video. Absolutely more, please!
@shekishral6570
@shekishral6570 Жыл бұрын
Very informative and interesting, please more of those videos when you brake the javascript code into c++ code!
@y3v4d
@y3v4d Жыл бұрын
Awesome video, short and full of interesting information and analysis!
@juniorrueda8180
@juniorrueda8180 Жыл бұрын
That’s quite deep indeed Amazing video and thanks for sharing your knowledge!
@ThePrimeagen
@ThePrimeagen Жыл бұрын
yayaya
@marcoaugustovitangeli1300
@marcoaugustovitangeli1300 Жыл бұрын
I really enjoyed this video, this kind of content is great, is beautiful to see how "high-level" code, works all the way down and spot this kind of tricky things.
@ThePrimeagen
@ThePrimeagen Жыл бұрын
:)
@jgttech
@jgttech Жыл бұрын
I loved this video. It explains the situation really well.
@bashbunni
@bashbunni Жыл бұрын
This is amazing! You crushed this new format 🔥
@ThePrimeagen
@ThePrimeagen Жыл бұрын
oh bash... stawp
@deank179
@deank179 Жыл бұрын
Super interesting! Would love to see more content like this
@moodynoob
@moodynoob Жыл бұрын
Absolutely love this kind of content!
@jfdirienzo
@jfdirienzo Жыл бұрын
This style of video is pure gold 🔥🔥🔥
@pd5711
@pd5711 Жыл бұрын
Thanks for that video ! Props for Westbrook usage :D
@oscarh4066
@oscarh4066 Жыл бұрын
I just found you, Prime, and man I became a fan BLAZINGLY FAST!
@ThePrimeagen
@ThePrimeagen Жыл бұрын
LETS GO!!!
@blackfrog1534
@blackfrog1534 Жыл бұрын
Wow awesome video :3 the more technical the content the more prime shines
@st-jn2gk
@st-jn2gk Жыл бұрын
love your videos (waiting on your rust ergonomics vid btw 🥺)
@petrpechkurov3095
@petrpechkurov3095 Жыл бұрын
Thank you, Mr. ThePrimeagen!
@bravesirrobin9576
@bravesirrobin9576 Жыл бұрын
I love this video, I'd like to see more of this type.
@Ma1ne2
@Ma1ne2 Жыл бұрын
This was actuall very interesting, I was building a project for university with Rust to Webassembly and a lot of the ideas that you explained here to interface JS with C++ actually apply directly or similarly to wasm-bindgen, including how there is a wrapper struct for passed and returned JS values.
@UsefulProgrammer
@UsefulProgrammer Жыл бұрын
I really liked this one. Keep it up.
@kardashevr
@kardashevr Жыл бұрын
a fascinating piece of knowledge I'm never gonna need
@awave7710
@awave7710 Жыл бұрын
def looking forward to more of these
@alexibnz
@alexibnz Жыл бұрын
This style reseembles a lot with what I do at my job, but without SAP frameworks… fortunately for the rest of the viewers. Pls do more!
@timdithmer9184
@timdithmer9184 Жыл бұрын
This really is some next level sh*t! Thank you very much. I was already enjoying your content a lot. But this teaches people how to find out stuff by themselves, along with providing a very deep understanding of this specific topic. Again, thanks alot! MORE! :D
@ThePrimeagen
@ThePrimeagen Жыл бұрын
yayaya
@thehibbi
@thehibbi Жыл бұрын
I like understanding stuff like this by inspecting the source code. Very nice video, thanks :)
@sooollchhu
@sooollchhu Жыл бұрын
i am gonna have to rewatch it a couple of times to understand it, my brain is not cooperating today . Thank for this video.
@hugodsa89
@hugodsa89 Жыл бұрын
God I love these videos. Thanks prime.
@jocdiazm
@jocdiazm Жыл бұрын
Loved the new format!
@ThePrimeagen
@ThePrimeagen Жыл бұрын
lets go!
@AlexanderBorshak
@AlexanderBorshak Жыл бұрын
Nice investigation, many thanks!
@hendersonfernandes7378
@hendersonfernandes7378 Жыл бұрын
You are the senior I'd like to have in my life... Awesome video!!! ❤
@ThePrimeagen
@ThePrimeagen Жыл бұрын
hio! ty bud :)
@stefanhall6415
@stefanhall6415 Жыл бұрын
Love your videos❤
@ThePrimeagen
@ThePrimeagen Жыл бұрын
hey thanks stefan :)
@henrybenedict6357
@henrybenedict6357 Жыл бұрын
I just watch your course about vim on frontend masters and I love it.
@CodeWithAhsan
@CodeWithAhsan Жыл бұрын
I loved this Deep dive. Been working with JS for the past 10 years I never knew about this :) I'd love more of this and would perhaps now start looking into the chromium source code myself as well! Thanks the swolleyeagen
@abhishekgururani6993
@abhishekgururani6993 Жыл бұрын
This video is pure gold, I learned how to research things.
@lastink444
@lastink444 Жыл бұрын
alright, wow. that was an interesting dive into V8. thanks for "What JS really looks like 101"
@ImranSheikh-kg4qd
@ImranSheikh-kg4qd Жыл бұрын
We need more of this type of content...
@petarkolev6928
@petarkolev6928 Жыл бұрын
This video is beyond amazing!
@ThePrimeagen
@ThePrimeagen Жыл бұрын
oh well ty :)
@diegolikescode
@diegolikescode Жыл бұрын
That is some juicy ass content. Loved this format, you keep getting better and I'll keep coming to you (wat?)
@ThePrimeagen
@ThePrimeagen Жыл бұрын
LETS GO, KEEP COMING BABE!
@quintencabo
@quintencabo Жыл бұрын
I really loved this video!
@Aspiiire
@Aspiiire Жыл бұрын
Thanks really amazing and informative video
@eliasrojas5326
@eliasrojas5326 Жыл бұрын
beautiful, prime
@AlexSharikov
@AlexSharikov Жыл бұрын
Yes, entertaining and knowledgeable 💥
@ubitubee
@ubitubee Жыл бұрын
Amazing drawing skills!
@millions-senterprise
@millions-senterprise Жыл бұрын
Please do more of this......awsome content
@_randombob
@_randombob Жыл бұрын
Amazing vid, may have to watch again but neat
@headlights-go-up
@headlights-go-up Жыл бұрын
This was simultaneously interesting and confusing. I'm not smart enough for this, should I be ashamed? lol
@ThePrimeagen
@ThePrimeagen Жыл бұрын
i think you have achieved a victory?
@danielknight1570
@danielknight1570 Жыл бұрын
sometimes idk wtf ur talking about Prime but it’s soothing to hear ur voice
@mondirhallouli
@mondirhallouli Жыл бұрын
you sir are just different! in a very awesome way!
@andrewrush7667
@andrewrush7667 Жыл бұрын
Great video, thanks!
@smile4992
@smile4992 Жыл бұрын
I didn't know gimp can be used to create tutorial videos like this. This is amazing.
@leonardoantunes1598
@leonardoantunes1598 Жыл бұрын
Awesome type of vídeo! I want to see more
@mzg147
@mzg147 Жыл бұрын
I hate js, I am doing challenges to write web apps without touching js, but this deep dive is just great. Makes appreciating it much easier (it's still hard tho), thank you really much!
@alexIVMKD
@alexIVMKD Жыл бұрын
Amazing stuff dad
@igboman2860
@igboman2860 Жыл бұрын
So in summary, setTimeout expects a 32 bit signed integer and overflows . Thanks for the video. I actually didn't know that
@kr0k3tt
@kr0k3tt Жыл бұрын
Liked for the instance promotion. Thanks prime
@totalmonkeyspeed260
@totalmonkeyspeed260 Жыл бұрын
Good video, do whatever you want dude.🙏
@anshsharma5514
@anshsharma5514 Жыл бұрын
Loved the video tho, pretty informative ❤
@palkollar7739
@palkollar7739 11 ай бұрын
this is an awesome channel
@lotfikamel5947
@lotfikamel5947 Жыл бұрын
Really special content 💖
@ThePrimeagen
@ThePrimeagen Жыл бұрын
i feel special sometimes
@RBZzzStyle
@RBZzzStyle Жыл бұрын
Awesome mate!
@amans6504
@amans6504 Жыл бұрын
This time i finally could understand a little c++ in production.
@alexibnz
@alexibnz Жыл бұрын
This sparks joy!!!!!!!!!!!
@npgoalkeeper
@npgoalkeeper Жыл бұрын
Reviewing an example of chromium doing something seemingly unexpected while on Firefox, truly a chad move
@matthewvaccaro8877
@matthewvaccaro8877 Жыл бұрын
More! More you son of a bitxh!!! More content like this, it’s absolutely amazing ❤❤❤
@ARLX-yo1wr
@ARLX-yo1wr Ай бұрын
man, it's blazingly amazing)
@medamine3142
@medamine3142 Жыл бұрын
my mind is exploded from this explanation😵
@ThePrimeagen
@ThePrimeagen Жыл бұрын
hopefully in a good way
@medamine3142
@medamine3142 Жыл бұрын
@@ThePrimeagen HAHA right
@adamclarke403
@adamclarke403 Жыл бұрын
Really interesting content!
@ThePrimeagen
@ThePrimeagen Жыл бұрын
ty
@ascourter
@ascourter Жыл бұрын
Nothing like pulling out the ole 2's complement to see some jaws hit the floor
@matthieumatsima5628
@matthieumatsima5628 Жыл бұрын
Gréât vidéo, very instructful
@bobobo1673
@bobobo1673 Жыл бұрын
Good vídeo , very interesting
@boulaakladyous
@boulaakladyous Жыл бұрын
I love your channel❤😂
@TRex266
@TRex266 Жыл бұрын
Yes. Please more
@qodesmith520
@qodesmith520 Жыл бұрын
You're a friggin genius.
@ThePrimeagen
@ThePrimeagen Жыл бұрын
just a man with curiosity
@drsensor
@drsensor Жыл бұрын
Thanks for sum it up your stream 👍 Request Topic: JSX vs Go template vs Mustache (i.e Ramhorn)
@Guilherme-qk9so
@Guilherme-qk9so Жыл бұрын
this is awesome lol gonna farm that promotion now brb
@zacanger
@zacanger 11 ай бұрын
So in the first few seconds my mind already jumped to "32 bit signed integers" and it turns out that was right, but I didn't know the default behavior for something larger was 0. The spec is really fascinating, especially since it includes so much stuff that JS users (like me) would love to see changed, but it can never change because JS has to be backwards-compatible forever. There's always a _logical_ explanation for JS weirdness that made sense at one point in time, but that doesn't mean it's always rational in 2023 (except for typeof null, which was just an accident, but now we're stuck with it).
@heitorcsn
@heitorcsn Жыл бұрын
what a content!
@michaeldeloatch7461
@michaeldeloatch7461 Жыл бұрын
I'm a little stopped up in the ears tonight, and a lot hearing impaired every night, and the speakers on my laptop are lousy. @ 2:40 I thought you said "ideologue" which certainly could figure in philosophically between the loosy-goosy world of JS and the cold, heartless metal of C calls ;-) -- oh, you actually said IDLong
@darylclarino5439
@darylclarino5439 Жыл бұрын
this is an inspiration to create confusing prs that work to confuse colleagues for the lols
Are Developers Ok?
11:46
ThePrimeagen
Рет қаралды 166 М.
Is JSON Blazingly Fast or...?
9:57
ThePrimeagen
Рет қаралды 182 М.
Парковка Пошла Не По Плану 😨
00:12
Глеб Рандалайнен
Рет қаралды 13 МЛН
одни дома // EVA mash @TweetvilleCartoon
01:00
EVA mash
Рет қаралды 1,2 МЛН
SUPER tasty dinner for my husband #shorts by Tsuriki Show
00:16
Tsuriki Show
Рет қаралды 3,2 МЛН
Final muy inesperado 😨
01:00
Juan De Dios Pantoja
Рет қаралды 50 МЛН
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,5 МЛН
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 695 М.
The Heart of React || How React works under the hood
10:32
AI Bruise
Рет қаралды 5 М.
Performance of JavaScript Garbage Collection | Prime Reacts
26:46
ThePrimeTime
Рет қаралды 68 М.
5 Things I Hate About JavaScript
7:17
ThePrimeagen
Рет қаралды 236 М.
How to Vim in 2023: Tips and Tricks
15:53
ThePrimeagen
Рет қаралды 377 М.
Gitlab DELETING Production Databases | Prime Reacts
17:27
ThePrimeTime
Рет қаралды 286 М.
everything is open source if you can reverse engineer (try it RIGHT NOW!)
13:56
Low Level Learning
Рет қаралды 1,2 МЛН
🔥Новый ЛИДЕР РЫНКА СМАРТФОНОВ🤩
0:33
Infrared Soldering Iron from Cigarette Lighter
0:58
ALABAYCHIC
Рет қаралды 1,8 МЛН
All New Atlas | Boston Dynamics
0:40
Boston Dynamics
Рет қаралды 5 МЛН
🤯Самая КРУТАЯ Функция #shorts
0:58
YOLODROID
Рет қаралды 1,6 МЛН