How does a compiler work?

Sdílet
Vložit
  • čas přidán 3. 06. 2024
  • In this video we'll take a look at how compilers work and the process they take to turn code into something a computer can execute
    0:00 Intro
    1:04 Stage 1
    1:42 Stage 2
    2:22 Stage 3
    2:40 Stage 4
    Links
    ========================================================
    Lexer output:
    - clang++ -fsyntax-only -Xclang -dump-tokens code.cpp
    - godbolt.org/z/zTTrYs189
    Parser output:
    - clang++ -fsyntax-only -Xclang -ast-dump code.cpp
    - godbolt.org/z/Td71dcKzP
    Code gen output:
    - clang++- -S -masm=intel code.cpp && cat code.s
    - godbolt.org/z/acrsGqxKM
    💭 All views are my own 💭
    Kit
    ========================================================
    🎥- DJI Pocket 2 Creator Combo - amzn.to/3kxQeZh
    🎙️- Blue Yeti - amzn.to/3EE1Wsm
    💡- Govee Floor Lamp - amzn.to/3ZisN4Y
    ⌨️- Corsair K70 RGB MK.2 - amzn.to/3EDIonM
    Books
    ========================================================
    📖 - Effective Modern C++ - amzn.to/3EDIonM
    📖 - A Tour of C++ - amzn.to/41pI1qH
    📖 - C++ Templates: The Complete Guide - amzn.to/3Zmi0ql
    Music
    ========================================================
    Get Summer's Shadow by Max Brodie and over 1M + mainstream tracks here go.lickd.co/Music
    License ID: ab7ZXzLZ4lX

Komentáře • 35

  • @Prakyy
    @Prakyy Před rokem +31

    Got it, compilers are black magic.

  • @carecoable
    @carecoable Před rokem +13

    Your production and editing is getting better! Honestly your videos deserve a lot more views. Thanks a lot for teaching us how a compiler works!

    • @nathanbaggs
      @nathanbaggs  Před rokem +1

      Thanks for the kind words, glad you enjoyed it (:

  • @AntonDelgadoACA
    @AntonDelgadoACA Před rokem +1

    I love the production value!!! The sound effects and random bits and bobs flying around are meme-worthy.

  • @JakeJJKs
    @JakeJJKs Před 6 měsíci +1

    Dude, I am so happy I came across your channel. I am equally impressed between your depth of knowledge, presentation and pedagogy. Subbed & liked!

  • @mlindroth
    @mlindroth Před 6 měsíci +2

    You hand movements are very distracting. But I learn a lot from your videos. Thanks for the videos!

  • @georgecop9538
    @georgecop9538 Před rokem +1

    Well, I fiddled around with TCC, modifying it, and that helps you understand how it works(tokens, optimization and assembly)

  • @higiniofuentes2551
    @higiniofuentes2551 Před rokem +1

    Thank you for this very useful video!

  • @TeslaPixel
    @TeslaPixel Před rokem +4

    A visualisation of the AST would be nice (not used by clang but ANTLR has nice tools for this) as would you moving your arms slightly less - it's a little distracting.
    Overall another great video.

    • @nathanbaggs
      @nathanbaggs  Před rokem

      Thanks for the suggestions, unfortunately that's just how I talk/teach as it helps me keep pace. Glad you enjoyed it (:

  • @lelsewherelelsewhere9435
    @lelsewherelelsewhere9435 Před 6 měsíci

    Hilarious Anamorphs thumbnail! 10/10 made me lol

  • @mannb1023
    @mannb1023 Před 7 měsíci

    great video

  • @ed9w2in6
    @ed9w2in6 Před 6 měsíci

    Love your presentation. Can you make a video on full bootstrapping too? The first time I have heard about the trusting trust issue it blew my mind. Its the elephant in the room that nobody ever talks about. I think everyone should at least know about it.

  • @user-lx1ib1qn6h
    @user-lx1ib1qn6h Před rokem +1

    Hello , i have a question i know how computer add and substract by binary but i don't know how it convert the results to things that i can read and understand for an example comuter added 2 and 5 the result is 7 how computer shows me specific pixels on 7 shape which i can read ?

  • @CreeperShorts
    @CreeperShorts Před 11 měsíci +1

    Good video!

  • @ryoukaip
    @ryoukaip Před rokem +1

    noice!

  • @juanmacias5922
    @juanmacias5922 Před rokem +2

    That Animorphs thumbnail tho!

    • @nathanbaggs
      @nathanbaggs  Před rokem

      I spent longer on that thumbnail than I care to admit...

  • @sameerakhatoon9508
    @sameerakhatoon9508 Před rokem +2

    thanks!!

  • @dehrk9024
    @dehrk9024 Před 5 měsíci

    Yeah that’s cool but the actual magic happens where the assembly turns into binary right? Where does this happen?

  • @higiniofuentes2551
    @higiniofuentes2551 Před rokem +1

    For me the compiling process is:
    Syntax scanning
    Semantic analysis
    Code optimization
    Code generation
    Is correct?

    • @nathanbaggs
      @nathanbaggs  Před rokem +1

      Pretty much, I omitted optimisation for brevity, but did include the linker stage.

  • @menachemlevi
    @menachemlevi Před 5 měsíci

    amazing well explain just subscribe ,though i will recomend to increase the volume

  • @higiniofuentes2551
    @higiniofuentes2551 Před rokem

    Please, can you tell me what is the stage4?

    • @nathanbaggs
      @nathanbaggs  Před rokem +1

      Sorry I'm not sure I understand, I covered the four stages in the video?

    • @higiniofuentes2551
      @higiniofuentes2551 Před rokem

      Sorry@@nathanbaggs in the video, the last box is named "stage 4". Which will be the name to replace it?

    • @nathanbaggs
      @nathanbaggs  Před rokem +1

      Ah I see what you mean. Last stage is linker

  • @RusticaBeachHouse-TortugaPrope

    the hand gestures are way too fast and your avatar is in the middle of the screen which adds no value, please edit that out to make your video more effective.

  • @mournful_m
    @mournful_m Před 10 měsíci +1

    You probably are British or my listening skills are so pity... (English is not my native)