Compilers, How They Work, And Writing Them From Scratch

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ธ.ค. 2024

ความคิดเห็น • 431

  • @Conman9310
    @Conman9310 5 หลายเดือนก่อน +728

    ITS MY SLEEPOVER AND I GET TO PICK THE MOVIE

    • @CppExpedition
      @CppExpedition 3 หลายเดือนก่อน +6

      please invite me to all your parties! 🎈

    • @neithsan5110
      @neithsan5110 24 วันที่ผ่านมา +1

      so u pick how to write compilers from scratch? 😹

  • @fangbozhu7379
    @fangbozhu7379 13 วันที่ผ่านมา +12

    Finished a Masters at 22, and producing such neatly commentated videos... you're spectacular

    • @adammcdaniel536
      @adammcdaniel536  12 วันที่ผ่านมา

      @@fangbozhu7379 Thank you so much!

  • @ethanly1720
    @ethanly1720 5 หลายเดือนก่อน +136

    Yooo, you were my TA. Quality content and super clear way of explaining!

    • @adammcdaniel536
      @adammcdaniel536  5 หลายเดือนก่อน +27

      Hahaha great to see you here! Thanks so much!

  • @dragonfiregaming4427
    @dragonfiregaming4427 4 หลายเดือนก่อน +252

    Opened with Brainfuck, compared caveman speak to the x64 instruction set, and created a language even simpler than Python. My god, the steel balls and genius of this man are insane. Good things ahead for you. As an aspiring 17 year old programmer this vid makes me so happy.

    • @Scudmaster11
      @Scudmaster11 3 หลายเดือนก่อน

      FALSE is better

  • @kr8432
    @kr8432 หลายเดือนก่อน +5

    Even though I knew basically how it works, the animation at around 4:00 gave me an intuitive understanding about how from binary information and simple register commands complex programs can emerge. I took me a real long time but I think this gave me kind of a breakthrough. Nice..

  • @divy1211
    @divy1211 6 หลายเดือนก่อน +54

    As a fellow programming language and compiler/program analysis enthusiast, I find your work very inspiring. I've only recently discovered that this is one of my favourite areas of swdev, and I'm very pleased to see someone else out there with the same passion!

  • @Neel631
    @Neel631 6 หลายเดือนก่อน +37

    The breadth and depth of this video is blowing my mind. I work in storage, and I find working on the data path challenging. I envy you Adam. Very nice video!

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +2

      Thank you so much, that's super kind!! I'm glad you liked it, I worked hard on it!! Hahaha

  • @Turalcar
    @Turalcar 5 หลายเดือนก่อน +108

    1:51 "...very few grunts and gestures"
    x86-84 Instruction Set: Am I a joke to you?

    • @zackbuildit88
      @zackbuildit88 5 หลายเดือนก่อน +10

      Textbook definition of bloat tbh

    • @Microextent
      @Microextent 5 หลายเดือนก่อน +2

      @@zackbuildit88 i 100% agree

    • @zackbuildit88
      @zackbuildit88 5 หลายเดือนก่อน +5

      @@Microextent it's so bloated that a lot of its "features" make it actually SLOWER than ARM cpu stuff even tho ARM doesn't have as many optimization strategies

    • @Microextent
      @Microextent 5 หลายเดือนก่อน +2

      @@zackbuildit88 Absolutely, sometimes the phrase keep it simple stupid has great merit. Especially in complex systems like cpus, every one i have designed in logisim has been faster with less instructions. Sometimes you need to supplement with code but that is fine if you have fast clock speeds like all modern cpus do.

    • @zackbuildit88
      @zackbuildit88 5 หลายเดือนก่อน +2

      @@Microextent You said "actually" like you were gonna contradict me but, based on what you said, you agree with me. What? [Edit: I misread]

  • @therealestsnake
    @therealestsnake หลายเดือนก่อน +2

    I love your use of Manim! I've always been a fan of PL theory + Compilers, so videos like this are always great to see!

  • @tom901ful
    @tom901ful 6 หลายเดือนก่อน +851

    This dude casually demonstrates how he programmed a language, a compiler and a OS. He has Terry Davis levels of genius (Strictly talking about programming of course).

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +287

      Thank you so much!!! Terry Davis was certainly one of my heroes in highschool; he's God's chosen programmer after all!!!

    • @horrorhotel46290
      @horrorhotel46290 5 หลายเดือนก่อน +57

      I'd say that makes this video blasphemy and you a heretic - but in a good way

    • @terminallychill8029
      @terminallychill8029 5 หลายเดือนก่อน +11

      What other kinds of genius did Terry Davis have 🤔

    • @tom901ful
      @tom901ful 5 หลายเดือนก่อน +13

      @@terminallychill8029 I mean, he said a couple of things that resonate with Diogenes philosophy from time to time. But what I meant it's that he's like Terry Davis without having to bring the other stuff he had.

    • @akashchandra2223
      @akashchandra2223 5 หลายเดือนก่อน +4

      @@adammcdaniel536 how were you brought up when young? How did you know you were interested in this stuff and how did you get so motivated in this industry?

  • @vanadium6021
    @vanadium6021 6 หลายเดือนก่อน +22

    this was such a good video, you explained these concepts really well and I think you made great choices about what to include/not include. I hope to see more videos in the future but for now I will check out your blog!

  • @aymenbelghoul2713
    @aymenbelghoul2713 4 หลายเดือนก่อน +5

    This is one of those guys that appear from nowhere , drop a banger, then vanish forever

  • @kamalacharya4608
    @kamalacharya4608 6 หลายเดือนก่อน +16

    The video is really high quality.
    Keep making more.

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +3

      Thank you so much, I really appreciate the kind words!!!

  • @JackieJKENVtuber
    @JackieJKENVtuber 6 หลายเดือนก่อน +123

    A cool way I've found to visualise what a compiler does goes as follows:
    When I tell you "the apple fell from the tree", we both imagine the same thing. However, our brain learned each of those concepts - apple, fall, origin, tree - and the relationships between them - "from" is synonymous with "origin" - through different ways. Therefore, no two brains are the same, even if they hear the same words and imagine the same concepts.
    Two computers with different architectures are like two different brains: the words (source code) are the same, and so are the results (the concepts and the relationships between them, the machine code is the neurons interacting to make what the end user sees), but the interpretation of the words into those concepts is different for every one (compiler).

    • @uncleswell
      @uncleswell 6 หลายเดือนก่อน +4

      So we're all imagining that one picture of Newton, right?

    • @unnoticedspacegoat8537
      @unnoticedspacegoat8537 6 หลายเดือนก่อน +3

      I use a similar analogy to differentiate between interpreters and compilers. If we both know english, then i can give you instructions while you’re doing them like teaching you to cook a particular meal. But if i only know german and you know only english, i need a translator(a compiler) to do translate german to english. In this scenario you are the interpreter, you give meaning to combinations of sounds and the translator is the compiler.

    • @casev799
      @casev799 6 หลายเดือนก่อน

      ​@@uncleswell ... I wasn't at first but now I wonder how many different images of Newton there are

    • @edmunns8825
      @edmunns8825 5 หลายเดือนก่อน

      @@casev799 7

    • @iammichaeldavis
      @iammichaeldavis 3 หลายเดือนก่อน

      @@uncleswellwell, I am **now**

  • @devbites77
    @devbites77 6 หลายเดือนก่อน +16

    Top-notch presentation. I look forward to seeing the subs. rise up.

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +2

      Thank you so much, I'm really glad you liked it!! I hope to deliver more enjoyable content soon with what I've learned!!!

  • @steveclancy6474
    @steveclancy6474 3 หลายเดือนก่อน +2

    Really enjoying your output. The music is very complimentary.
    Now I won't deny it, I do learn but it's also great to listen to to go to sleep.

  • @OWOacnight
    @OWOacnight 5 หลายเดือนก่อน +6

    The thumbnail attracts me immediately when I saw it, great stuff!

  • @oli111222
    @oli111222 3 หลายเดือนก่อน +4

    Where were you when I was in school? Real talk, huge respect for your work and your way of presenting and explaining stuff :) Keep up the good work!

  • @_simoncurtis
    @_simoncurtis 5 หลายเดือนก่อน +12

    This is actually insane! Puts my little scripting language pet project to shame haha

    • @adammcdaniel536
      @adammcdaniel536  5 หลายเดือนก่อน +1

      Hahaha thanks so much, I appreciate it!!😄

  • @psibarpsi
    @psibarpsi 5 หลายเดือนก่อน +13

    I love people like you who delve into the fundamentals and build actually cool things.

  • @meronamsamho9410
    @meronamsamho9410 4 หลายเดือนก่อน +5

    5 seconds in and i get the best definition of what a computer is in my years of CE

  • @gottagofast0077
    @gottagofast0077 5 หลายเดือนก่อน +6

    Nice video. I do have to mention that not every compiler needs an IR. In fact, many early C compilers translated directly to machine code. IR does make value tracking much easier which is very important to modern optimizations. Also, not every compiler compiles to machine code. Some compilers compile to bytecode, and others compile to different source code.
    I would like to see you go over the frontend of a compiler more indepth. Parsing and building the AST and IR is something that can be very interesting.

    • @adammcdaniel536
      @adammcdaniel536  5 หลายเดือนก่อน +4

      If you don't use an intermediate representation, you need M * N backends for the compiler, while it's only M + N for those with intermediate representations.
      This is why GCC, Clang, Rust, Fortran, Haskell, and tons of others use IRs before compiling to machine code -- nearly all modern compiled languages do this
      Yes, I'm aware many languages don't compile to machine code -- Sage compiles to SageVM code, which can be interpreted or compiled for a target platform. These are really just a hypothetical "machine code" for an imaginary machine.
      Parsing, to me, is the least fun part of the compiler hahaha. The AST is essentially directly represented as an IR in Sage, and then lowered to another stage before being compiled to the VM.

  • @Stella-se1lg
    @Stella-se1lg 4 หลายเดือนก่อน +3

    I have 7 years of software development experience and recently get exposed to compiler, low level representation and type inference 😊. Your demo is clear and easy to follow!

    • @toby9999
      @toby9999 3 หลายเดือนก่อน +4

      I started coding in the 70s. There were no available languages, just machine code, all hex. That's how my journey started. I eventually went back to university , took a computer science degree, and learned a lot of this kind of stuff. Lots of theory and low-level concepts. I then worked for a company developing its own scripting language and compiler. This was my passion. I feel there are too many programming courses nowadays that focus heavily on web design, client server, Java and Python, etc. And miss out on the beauty hidden behind the scenes.

  • @thatonemailbox
    @thatonemailbox 6 หลายเดือนก่อน +570

    Bro opened with brainfuck 💀

    • @ccgarciab
      @ccgarciab 6 หลายเดือนก่อน +75

      Good choice for a simple machine code tbh

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +89

      Hahahaha I had to do it to 'em

    • @godowskygodowsky1155
      @godowskygodowsky1155 5 หลายเดือนก่อน +27

      BF is actually really easy to write a compiler for because of its small instruction set. Its difficulty is that due to Its small instruction set, it's hard to do anything useful.

    • @Bobbias
      @Bobbias 5 หลายเดือนก่อน +12

      BF is also baby's first esolang. If someone starts off with Malbolge then you know you're in for a wild ride.

    • @infrakazos
      @infrakazos 5 หลายเดือนก่อน

      @@godowskygodowsky1155 I've made addition, subtraction, multiplication, division, greater than and less than in brainfuck, so i think i can actually start making things, but im too lazy to continue working on it lol

  • @archive-underground
    @archive-underground 6 หลายเดือนก่อน +23

    I thought this video had like 1249124 views the first 2 minutes watching, how'd I just come across this randomly? Great stuff!

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +5

      Thank you so much, I'm glad you enjoyed it!! I think it's an incredibly interesting subject, I'm glad the TH-cam algorithm showed it to you hahaha

  • @mahdadbaghani2586
    @mahdadbaghani2586 3 หลายเดือนก่อน +3

    real nice. I see a soon-to-be successful channel in CS. keep up the good work!

  • @SimGunther
    @SimGunther 6 หลายเดือนก่อน +13

    Great (albeit super abstract) overview of compilers.
    90% of the time will be spent on optimizations, so it's not just important that you get the optimization sequencing correct, but also the AST transformations without losing the original meaning of the tree while still making good use of co-processors in the final binary executable/library output.
    Although languages like Rust, Haskell, and Idris make this task simpler via structured pattern matching, writing the optimizations themselves and seeing if they break other optimizations will still be a very hard task. Forgot to mention that on some hardware platforms, some very specific optimizations will turn out to be "slow downs", so be wary of that before customizing the optimizations that go into each target CPU/Co-processor.

    • @Turalcar
      @Turalcar 5 หลายเดือนก่อน +1

      So it's closer to a literary translation from one modern language to another than the examples given at the top of the video. Using different sets of fixed phrases and cultural references (e.g. Shakespeare quotes to Chinese classics) and convey not just the meaning but the author's intention (for compilers that mostly means recognizing which path is the hot one).

    • @meechsanims
      @meechsanims หลายเดือนก่อน +1

      he had to translate it into something my caveman brain could understand

  • @obiomajronyekwere4469
    @obiomajronyekwere4469 3 หลายเดือนก่อน +20

    Dear god reading your resume and github as a 17 year old programmer is like a mortal staring at a god? what kind of free time do you have to do all this?

    • @adammcdaniel536
      @adammcdaniel536  3 หลายเดือนก่อน +12

      @@obiomajronyekwere4469 Thank you so so much! Hahaha very little free time, but I don't play games or much else. Music and programming are my hobbies!

    • @obiomajronyekwere4469
      @obiomajronyekwere4469 3 หลายเดือนก่อน +4

      @@adammcdaniel536 oh god.. and your tryna be in the workforce. Dude. Chill. Like seriously you are the definition of talent. But yknow what ill admit youve got me excited to surpass you one day. Your doing much more than i ever thought that just possible for a casual programmer.

  • @abrianabir7127
    @abrianabir7127 28 วันที่ผ่านมา +2

    Awesome video and narration! finally got the time to sit down and watch. very informative!

    • @adammcdaniel536
      @adammcdaniel536  27 วันที่ผ่านมา

      @@abrianabir7127 Thanks so much, Im glad you liked it! :D

  • @vikaspoddar001
    @vikaspoddar001 3 หลายเดือนก่อน +5

    You are great, we want a full series on the compiler, language design, type system 😅😅😅

  • @oglothenerd
    @oglothenerd 3 หลายเดือนก่อน +4

    Brainfuck mentioned, let's go! I actually started writing a compiler for (human readable to) Brainfuck a little while ago!

  • @two_horus7337
    @two_horus7337 5 หลายเดือนก่อน +4

    Keep up the good work! Such a concise yet understandable video.

  • @Dominik-K
    @Dominik-K 6 หลายเดือนก่อน +3

    Very nice and in-depth overview of those topics. I'm highly interested in more information in those topics, so this is highly appreciated. Thanks for this and please keep it up 🙏

  • @tgrey_shift..mp334
    @tgrey_shift..mp334 19 วันที่ผ่านมา +2

    I absolutely adore this video! Hope to see more soon!
    On a more personal note, I really admire your passion for theoretical CS being taught in an applied manner! Hope we can chat and be friends someday!
    Would love to read a paper/book with you and discuss to your hearts content!
    You rock!!! :)

    • @adammcdaniel536
      @adammcdaniel536  18 วันที่ผ่านมา

      @tgrey_shift..mp334 Wow, thank you so much for the kind words!
      If you want to hang out with our community, you can join the Sage discord! I'm frequently there talking with others about type system things and off topic subjects!
      Hopefully I'll be making a new video relatively soon based on a new project I'm working on, which will likely be built on top of Sage's infrastructure!👀

  • @MikeWardNet
    @MikeWardNet 6 หลายเดือนก่อน +10

    Great content. Much better audio mix.

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +2

      Thank you so much!! I'm glad it's an improvement!

  • @pureatheistic
    @pureatheistic 4 หลายเดือนก่อน +2

    You live in TN? HELL YEA dude. Exciting to see a programmer content creator living here in this hill Billy hell.

  • @taux_gmigmi
    @taux_gmigmi 6 หลายเดือนก่อน +5

    2:36 Sumerian isn't any "smaller" or "simpler" than English just because it's an older language. Obviously this is just a metaphor, but if you know about linguistics then the metaphor kind of falls apart. Instead of translating from 1 natural language to the other, maybe something more accurate would be translating from English to formal logic, with the intermediate representation being a logic-based language like Lojban.

    • @lunkel8108
      @lunkel8108 5 หลายเดือนก่อน

      It's always interesting to me how many people think modern humans just a few thousand years ago were stupid idiots who couldn't even speak a proper language.
      A while ago I overheard a guy confidently explaining to his friends how biblical hebrew was incredibly "primitive" and how they didn't have poetry or complex narratives back then (while talking about the bible?!) because they were too busy getting chased by saber-toothed tigers (?!?). His main piece of evidence? That too many sentences in translations of the bible start with "and", which is obviously not something a "real language" would do. You know, that translation artifact of a grammatical construction (the vav-consecutive) that biblical hebrew had and modern english doesn't? Yeah, real primitive of them.

  • @PMA65537
    @PMA65537 3 หลายเดือนก่อน +2

    1:02 According to Bornat a major role of compilers is giving good error messages when compliation fails.

  • @nteasushz
    @nteasushz 4 หลายเดือนก่อน +2

    This guy compiles. Awesome

  • @suyash7120
    @suyash7120 4 หลายเดือนก่อน +2

    This is so awesome... Waiting for more such videos. Kudos 🎉

  • @Miguel_Vitta
    @Miguel_Vitta 10 วันที่ผ่านมา +1

    This was pretty useful in increasing my understanding of the subject

    • @adammcdaniel536
      @adammcdaniel536  10 วันที่ผ่านมา

      @@Miguel_Vitta Thank you, I'm glad it could help!

  • @GodofWar1515
    @GodofWar1515 5 หลายเดือนก่อน +1

    Really Awesome work! It's really nice to see a fellow Programming Language Enthusiast. Keep up the great work!

  • @ЕгорКолов-ч5с
    @ЕгорКолов-ч5с 6 หลายเดือนก่อน +70

    This video is basically about your personal abstract understanding of intermediate representations with a bit of Turing machines sprinkled in, and not about compilers.
    1) Your definition of compilers is too restrictive - the IR is not a necessary step during compilation (if you included it, what about other (more significant than IR in my opinion) aspects of compilation such as lexing, building ATS, parsing, type checking, optimization, etc.) and the result of compilation doesn't have to be an executable binary (for example Cfront, the original compiler for C++, translated C++ source code to C source code, javac translates from Java SC to Java bytecode, and if you make a transpiler from brainfuck SC to C SC without generating an executable, it would still be considered a compiler)
    2) The caveman analogy is unhelpful and misleading for programmers who don't know anything about compilers, and for those who do it will look as an unnecessary gross oversimplification
    3) The part about translating high level languages to IR doesn't explain anything about compilers, and programmers who aren't familiar with compilers and Rust won't be able to understand it
    The video production is good though, would be great to see an indepth explanation of all compilation stages for a real language with actual code (tcc for example)

    • @lawrencemanning
      @lawrencemanning 5 หลายเดือนก่อน +7

      Agreed. I’d be surprised if early C compilers used an IR, and compilers existed way before that. The presenting of IR as a core step is vey misleading.
      On production values; some of the text is unreadably small.
      IMO this kind of “instruction” would be clearer in a blog post or similar b

    • @logicaestrex2278
      @logicaestrex2278 5 หลายเดือนก่อน +4

      ok so i have a few questions. i really appreciate your comment btw friend. on number 2, could you elaborate on why its a bad example, or perhaps on what a better example would be? also, what resources do you respect for learning how to make a compiler like this? again, thanks for these points :)

    • @bossgd100
      @bossgd100 5 หลายเดือนก่อน +5

      I am waiting for your video

    • @bossgd100
      @bossgd100 5 หลายเดือนก่อน +2

      @@chocolatezt no, but its better if he do it ;)

    • @bruhmoment1835
      @bruhmoment1835 5 หลายเดือนก่อน +4

      @@bossgd100yeah, just use flawed knowledge until then, because nothing is gospel unless it's on TH-cam. For once in your life, read a textbook.

  • @thebirdhasbeencharged
    @thebirdhasbeencharged 6 หลายเดือนก่อน +7

    Good stuff my man!

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +3

      Thank you!! It took years to get the compiler solid hahaha

  • @redcrafterlppa303
    @redcrafterlppa303 5 หลายเดือนก่อน +1

    Great video. Especially interesting as I'm looking forward to write my first compiler myself soon. I found it quite frustrating to find a language to write the compiler in. As the reason for creating my own language was that I wanted to combine multiple languages powers into one. This however led to frustration while writing the compiler. I ran into the problems I wanted to solve compared to the other languages and wished I could write it in my own language. But I know that I at least have to write a bare minimum compiler in some other language to be able to bootstrap it.

  • @ukrustacean
    @ukrustacean 6 หลายเดือนก่อน +2

    That's the content we need!

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +2

      Thanks so much, I appreciate the kind words a ton!! I LOVE the Ukraine flag behind the Haskell logo lamba!!!🇺🇦🇺🇦🇺🇦🇺🇦🇺🇦🇺🇦🐑🐑🐑🐑🐑🐑 SLAVA UKRAINI🇺🇦🇺🇦🇺🇦🇺🇦🇺🇦🇺🇦🇺🇦

  • @khonello
    @khonello 5 หลายเดือนก่อน +1

    Just checked out your website and you are truly impressive. Would appreciate having you as mentor or tutor

  • @cellularmitosis2
    @cellularmitosis2 6 หลายเดือนก่อน +4

    Thanks so much for this - I was in the process of writing a brainfuck compiler and this gives me a good roadmap of what’s next

  • @oglothenerd
    @oglothenerd 3 หลายเดือนก่อน +6

    Dude! You're not one of the soy boys, this is actually the kind of stuff I wanna watch! I subbed and liked.

  • @TarkTheConlanger
    @TarkTheConlanger 6 หลายเดือนก่อน +2

    Damn, great video, you definitely deserve more views and subs

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน

      Thank you so much, I'm really glad you appreciated this content!! I spent a lot of time on it :)

  • @CoreDumpped
    @CoreDumpped 5 หลายเดือนก่อน +1

    I loved this video, nice job :D

  • @ゾカリクゾ
    @ゾカリクゾ 6 หลายเดือนก่อน +3

    awesome quality and very interesting. I really want to take a course in programming language theory in the future.

  • @TheTruthTheyHate
    @TheTruthTheyHate 2 หลายเดือนก่อน

    Great video. You just earned a new sub at 3:37. I’m starting my courses for B.S. in Cloud Computing in December. All of this is VERY new to me as i had no background in any of it. What you showed at 3:37 helped alot as i didn’t know what any of the instructions translate to. Now that i’ve got the basic knowledge of the symbols and what they do it’s making things alot more easier. Want to ask a favor. Do you think you can make a video thats more in depth and detailed for all the symbols or instructions and their functions please? Also how they could be used as an example. Once again I’m very new to the whole subject of computer coding and the different languages and what they’re used for. Thanks.

  • @unitedastronomer
    @unitedastronomer 4 หลายเดือนก่อน +1

    wow this really helped me understand the basics of it

  • @briancoghlan7353
    @briancoghlan7353 5 หลายเดือนก่อน +1

    Shout-out to UT! I still go back to Dr.Plank's course websites years later to refresh on concepts!

  • @Delta0001-y
    @Delta0001-y 6 หลายเดือนก่อน +2

    This is fantastic, thanks!

  • @andrewrusanov6262
    @andrewrusanov6262 5 หลายเดือนก่อน +1

    Brilliant video! I hope you continue making videos on computer science

  • @Hector-bj3ls
    @Hector-bj3ls 6 หลายเดือนก่อน +3

    One feature I'd like to see in more compilers is full compile time execution. That's what I'm working on in mine. Essentially I'm compiling to a custom byte code, executing it in a VM, and then inserting the output back into the earlier stages of the compiler.

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน

      The latest PR for sage DOES have compile time execution!!! Sage has an interpreter which can run at compile time -- also, the new PR adds a Lisp language as an AST preprocessor system which can manipulate user programs to add tests or benchmarks.
      With this system, you'll be able to write Sage to modify your Sage code!!!!

    • @Hector-bj3ls
      @Hector-bj3ls 6 หลายเดือนก่อน

      @@adammcdaniel536 Oh nice! Having one language to do all the things is my goal. For example, one specific feature of many languages that's always bugged me is, meta programming using a totally different syntax to the rest of the language.
      An example that many will be familiar with is Typescript's mapped types. Consider the following:
      ```
      type Readonly = {
      +readonly [K in keyof T] T[K],
      }
      ```
      A fairly simple example. It just adds the readonly attribute to each property of some type T.
      My problem with this is that it's not really Typescript code. To express the same in normal TS code you'd write something like:
      ```
      function Readonly(T: type): type {
      const result = typeDescriptorOf(T);
      for (const prop of result.properties) {
      prop.readonly = true;
      }
      return descriptorToType(result);
      }
      ```
      It's more verbose, but it's also more accessible to Typescript developers. Because, instead of being a separate syntax with different rules, it's just code. The only difference is it runs at compile time.
      Prior art would be comptime in the Zig language, and #run in the Jai language. I think D also had something like this, but it's been a really long time since I used that 😅

  • @jacobvartuli507
    @jacobvartuli507 5 หลายเดือนก่อน +1

    Brilliant! Keep up the great work.

  • @s8x.
    @s8x. 5 หลายเดือนก่อน +2

    Another genius kid in programming. They must be stopped

  • @edgeeffect
    @edgeeffect 6 หลายเดือนก่อน +4

    The Dragon Book would be a kinda obvious reference to cite... but can I also recommend "Understanding and Writing Compilers" by Richard Bornat a particular favourite of mine. :)

  • @GrindAlchemyTech
    @GrindAlchemyTech 3 หลายเดือนก่อน +1

    👌🏾 thank you for sharing your gift with us all

  • @kenana3456
    @kenana3456 4 หลายเดือนก่อน

    Nice video, I know you from your old blog where you talked about compilers!

  • @lorenzojojoba2832
    @lorenzojojoba2832 5 หลายเดือนก่อน +1

    Fantastic video dude. A video in more detail about the typechecker would be awesome. Alao youve dine a lot, im only just getting inro compielrs and this stuff blows my mind.

  • @worldordergaming3449
    @worldordergaming3449 หลายเดือนก่อน +1

    I can tell you are using manim for your visualizations. Awesome job Adam!
    Best CS 302 TA out there.

    • @adammcdaniel536
      @adammcdaniel536  หลายเดือนก่อน

      @@worldordergaming3449 Thank you so much for the kind words! It's great to see my fellow classmates here! :D

  • @chiquiflautro
    @chiquiflautro 2 หลายเดือนก่อน +1

    Great content!
    Out of curiosity, are you using manim to do the animations?

    • @adammcdaniel536
      @adammcdaniel536  2 หลายเดือนก่อน +1

      @@chiquiflautro Thank you so much, and yes I'm using Manim!

  • @KAZVorpal
    @KAZVorpal 3 หลายเดือนก่อน +1

    You should mention to people that it is really easy to write an interpreter in JavaScript to have your own programming language, that runs in the browser or in node.
    Of course that isn't quite as performant as using assembler or C and writing a compiler...but it means they can create almost anything, the very kind of stuff that you would do, without having to do quite as much heavy lifting.
    I'm working on a programming language with Klingon keywords, myself.

  • @jordixboy
    @jordixboy 5 หลายเดือนก่อน +2

    If you're really interested in this topic, I would recommend taking these courses: nand2tetris and nand2tetris2, its heavy, long but totally worth it. You start by building logical gates with boolean algebra, you build an ALU, RAM, Registers... then a CPU and wire everything together using hardware description language (HDL). Then you program your CPU in binary, then you create an assembler for an assembly language, then you build a Java-like language and a compiler, then you build an OS and programs for it on your language. Highly Recommended!!!
    Thanks for the video.

    • @vitalyl1327
      @vitalyl1327 5 หลายเดือนก่อน

      Or an even deeper course: Project Oberon - a complete RISC CPU + VGA + PS/2 keyboard and mouse controllers + SD card controller, all in a simplified HDL, along with a complete OS and a high level language compiler. With a windowed GUI.

    • @jordixboy
      @jordixboy 5 หลายเดือนก่อน +1

      @@vitalyl1327 interesting! any link? is this a course or something?

    • @vitalyl1327
      @vitalyl1327 5 หลายเดือนก่อน

      @@jordixboy youtube is likely to delete comments with links. Just search for "Project Oberon", you'll find all the course material in the first few links.

    • @vitalyl1327
      @vitalyl1327 5 หลายเดือนก่อน

      @@jordixboy just look up the "Wirth Project Oberon". Links are problematic here.

  • @seekilm_
    @seekilm_ 6 หลายเดือนก่อน +5

    Nice with new audio ahah. Keep it up!

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +1

      Thank you!!

    • @knkootbaoat6759
      @knkootbaoat6759 6 หลายเดือนก่อน +1

      i didnt view the other videos. but man audio makes such a HUGE difference in terms of watchability (at least for me)

    • @seekilm_
      @seekilm_ 5 หลายเดือนก่อน +1

      @@knkootbaoat6759 Yep the more time passes, the more I feel like I just have the sound of the voice and that's it. It became almost impossible to follow a video with music.

  • @MichaelGarcia-e1b
    @MichaelGarcia-e1b 3 หลายเดือนก่อน

    2:42
    Such a great "conveniently". Kinda funny how so many of humanity's greatest inventions work thanks to conveniences like this. 😁

  • @bigyihsuan2
    @bigyihsuan2 4 หลายเดือนก่อน +1

    Great video, however it gives a vibe of the "draw the rest of the owl" meme in terms of how high level the explanations are.
    I've got an interest in building programming languages and so far the hardest part is changing from an interpreter to a compiler (which I have yet to do).
    You mention you use IRs to represent the higher level code in a form that's easier for the compiler to deal with. However you didn't really explain about what should go into an IR. How much of the original language should be stripped out? At what point should the IR be translated into another IR (if at all)?
    Another thing with the same "draw the rest of the owl" feeling is the final SageVM asm to native machine code step. IMO that is the most important step, but you glossed over it so fast that I wondered of it is indeed that easy (probably not).
    Summing up, I guess I had different expectations for this video based on the title than what was actually presented (a more low level view vs the high level view presented in the video). As another commenter said, great presentation, great dowmo. But as an educational explainer, leaves people more confused after watching it than before.

  • @newbie8051
    @newbie8051 2 หลายเดือนก่อน +1

    0:42 damn, you are 22 and finished with your masters damn
    I'm 21 and am thinking of opting for a masters degree after I graduate in a year

  • @shaquille_oatmeal207
    @shaquille_oatmeal207 4 หลายเดือนก่อน +104

    PhD at 22. That’s it. I’m so cooked 🙏

    • @JohnSmith-op7ls
      @JohnSmith-op7ls 3 หลายเดือนก่อน +3

      Stop trying to make “cooked” a thing

    • @shaquille_oatmeal207
      @shaquille_oatmeal207 3 หลายเดือนก่อน +107

      @@JohnSmith-op7ls ur right bro. My vocabulary is cooked 😔

    • @proceduralism376
      @proceduralism376 2 หลายเดือนก่อน +2

      i always had a phd, a pretty huge d-

    • @bjdooi
      @bjdooi 2 หลายเดือนก่อน +4

      bro it's ok he's a PHD student, he doesn't actually have his PhD yet lol

    • @elorrambasdo5233
      @elorrambasdo5233 2 หลายเดือนก่อน +1

      ​@@shaquille_oatmeal207chat, are we oatmeal's vocabulary?

  • @johncaruthers315
    @johncaruthers315 4 หลายเดือนก่อน +1

    Fellow Vol! Great video, interested to see your research.

  • @kevin42
    @kevin42 5 หลายเดือนก่อน +1

    Exceptional work!

  • @funky_tree
    @funky_tree หลายเดือนก่อน +1

    PLEASE make more videos like this, explaining the base stuff that nobody really bothers to learn because of the complexity in the multi page documents and unclear videos. I'm not very good with code, but you made me understand brainfuck

  • @andreffrosa
    @andreffrosa 6 หลายเดือนก่อน +3

    I created a compiler for my own language but didn't create an IR language. The "compiler" has 2 execution modes: directly intrepret or transpile to another language (C and Java). In either case, the AST is used directly in the final step, without any IR. What advantages would create an IR bring to this compiler? I'm not compiling to assembly, so the "intermediate simpler language" point doesn't seem to matter here. Unless I can use it somehow to simplify the transpilation into other languages. Can you provide insights on how an IR would be useful for this compiler?

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน +5

      You already have an intermediate language: your intermediate language here is C or Java. You're compiling to C or Java before that gets compiled to an even lower form that can be executed. These languages aren't executed by machines in the source code form -- you depend on the abstractions these languages provide that make it easier on you to execute your code.
      One drawback of relying on C and Java is that it's harder to get it working in an environment like the web -- you'd have to write a JavaScript backend or port the interpreter, which may be difficult depending on how you implemented your other backends. Porting an IR language to the web can be easier if you design it to be more abstract for other platforms
      The benefit of creating your own IR is that you can perform optimizations with the knowledge of the kind of code your frontend produces -- C can't optimize certain things that might be possible with the knowledge of how it got compiled.
      You can also represent constructs for your source language in your IR that make it map simpler to your language, so the logic for lowering the AST to your IR is simplified
      Additionally, you don't have to rely on GCC or Javac -- you can do the compilation yourself with no dependencies

  • @ChristopherFlodin
    @ChristopherFlodin 3 หลายเดือนก่อน

    Super clear and good content! Btw, what do you use to do these animations?

  • @RichardLofty
    @RichardLofty 6 หลายเดือนก่อน +16

    Holy C compiler translates source to machine code directly line by line.
    No intermediate representation is required depending on the language.

    • @toricon8070
      @toricon8070 5 หลายเดือนก่อน +1

      this used to be the case, but CPUs have advanced significantly since C was created, and the C standard has not/will not/cannot change enough to keep up with it. there are a _lot_ of adjustments and optimizations that the GCC does to keep C performing at the blazing speeds we expect of it. see "C Is Not a Low-Level Language".

    • @sudarshanrobot
      @sudarshanrobot 5 หลายเดือนก่อน +4

      @@toricon8070 OP was talking about Holy C, not C, that's another language. Although I'm not sure if the given information is correct.

    • @toricon8070
      @toricon8070 5 หลายเดือนก่อน +3

      @@sudarshanrobot oh thank you! that will be fun to learn about

    • @Isaac-zy5do
      @Isaac-zy5do 5 หลายเดือนก่อน +1

      The tiny C compiler is also famously a single-pass compiler

  • @ladyville3
    @ladyville3 2 หลายเดือนก่อน +1

    In all my years of learning and studying, I have found the best people to learn from are the ones that are not geniuses. Geniuses forget they are geniuses, and often leave you behind a few sentences in. I will say, I find people who are physicists usually can explain things a lot clearly than most. Lol.

  • @kleanse
    @kleanse หลายเดือนก่อน

    I just stumbled across your channel and visited your website, and I am awestruck. The number of projects you’ve built with such detail and depth at your age is mad impressive. Do you have any books or resources you could share that you believe helped bring you to where you are today? I’d love to learn more about the topics you’ve covered and cultivating the work ethic you possess :)

  • @gowthamk7416
    @gowthamk7416 5 หลายเดือนก่อน +1

    Now you became my inspiration ❤️

  • @joviel6620
    @joviel6620 3 หลายเดือนก่อน

    Interesting video, thank you.
    19:29 constants are a subset of expressions. types are a subset of constants. The arrows in the diagram are pointing from constants to expressions and from constants to types, even though they have opposite relationships. Am I missing something?

    • @adammcdaniel536
      @adammcdaniel536  3 หลายเดือนก่อน

      @@joviel6620 The reason there are arrows from both Expr and Const to Types is, even though types are a subset of constant expressions, every expression and constant *must* have an associated type with it -- all expressions and constants must be able to produce their "type" papers at the type checking customs office. Maybe I should've had the arrow indicate your understanding, in which case it would be the other way haha. Sorry for the confusion!

    • @joviel6620
      @joviel6620 3 หลายเดือนก่อน

      @@adammcdaniel536thanks for the clarification!

  • @randomhardcoreplayer7779
    @randomhardcoreplayer7779 5 วันที่ผ่านมา +1

    Inspiration dude

  • @Valurinn
    @Valurinn 2 หลายเดือนก่อน

    20:23 10/10 on intense musical fade-inn on epic greatness 🫡

  • @NanR
    @NanR 5 หลายเดือนก่อน +1

    Great video! It's really well made and very educational.
    BTW, your website's About Me has a small error in the spanish section. "He estado hablando" implies you started talking spanish in 2021, and haven't ever stopped since. A more correct way to say that would be "(Yo) Llevo hablando español desde 2021". I'd also recommend changing "puedo hablar muy bien" to "puedo hablar*lo* muy bien" (I can speak very well --> I can speak it very well).

  • @discotecc
    @discotecc 3 หลายเดือนก่อน +1

    You're a great communicator

    • @adammcdaniel536
      @adammcdaniel536  3 หลายเดือนก่อน

      @@discotecc Thanks so much!!

  • @MKVideoful
    @MKVideoful 5 หลายเดือนก่อน +2

    It would be really nice to see the OS run on simple embedded platform (ARM/Risc V) with screen and keyboard. Then you can run compiler on it. No longer need to have PC.

  • @poisonbar844
    @poisonbar844 5 หลายเดือนก่อน +2

    Thanks a lot man for the informations. Hope to see more from you. Really enjoyed the video. [ Tho a bit harsh for my brain to understand it all so I will be watching them for a number of time to understand it whole.] Keep'em coming

  • @theodoremawuli9885
    @theodoremawuli9885 2 หลายเดือนก่อน +1

    Are there compilers or research being carried out that make use of machine learning or some form of AI to optimize the process of converting high-level programming languages to machine code or even in debugging steps? (The AI hype is crazy, I know!)

  • @vvarhand3985
    @vvarhand3985 6 หลายเดือนก่อน +1

    Awesome vid, will follow your content with great pleasure; just started reading crafting interpreters and will try some funky zig stuff

    • @adammcdaniel536
      @adammcdaniel536  6 หลายเดือนก่อน

      That's great, writing an interpreter is always a super important first step towards a compiler!!! Have you experimented with lisp at all? Lisp is an incredible start towards making one's own programming language!!!

    • @vvarhand3985
      @vvarhand3985 6 หลายเดือนก่อน

      @@adammcdaniel536 I’ve never tried Lisp, and honestly, given the “mystique” it gives off, it sounds like a mind-bending experience (coming from self-taught web dev trying to learn how computers really work). But I am VERY interested in FP as well: I was thinking about Elixir for future job prospects or OCaml because of its overall shilling on various platforms😄 Any specific variety of Lisp?

  • @Troynjk
    @Troynjk 5 หลายเดือนก่อน +1

    So x86 and ARM are sets of instructions for compilers?
    Is a compiler something physical? Where is it located, in the CPU?

    • @adammcdaniel536
      @adammcdaniel536  5 หลายเดือนก่อน +1

      x86 and ARM are different organizations of CPU instructions that CPUs can run directly
      A compiler is a program. It's stored in memory and executed by a CPU

    • @Troynjk
      @Troynjk 5 หลายเดือนก่อน

      @@adammcdaniel536 thanks

  • @alexanderserafeim9416
    @alexanderserafeim9416 5 หลายเดือนก่อน +1

    Very nice explanation. Not too much whiteboarding and very easy to follow code. Good luck with your PhD :)

  • @AgentMatt47
    @AgentMatt47 6 หลายเดือนก่อน +1

    Your voice is so cute 🥰. Your promotor is so lucky to work with you

  • @kurtisrios8820
    @kurtisrios8820 3 หลายเดือนก่อน

    What is the piece that plays at 9:44?

  • @boltez6507
    @boltez6507 5 หลายเดือนก่อน +1

    It would be great if you could make a video or just post a blog about the prerequisites to actually make your own compiler or language,though this video serves as a good introduction as to how a compiler is supposed to work,the knowledge can't be directly used to implement a language as such.
    Alot of things need to be explored prior to even attempting to build your own compiler,i hope that you can make a blog about all the prequisites required from beginning to end.

  • @KayOScode
    @KayOScode 3 หลายเดือนก่อน

    I made a language called que in 2 weeks from scratch. It used byte code interpretation instead of fully compiling to machine code, but still quite cool. It’s interesting that your byte code is more high level than mine was. Mine was almost one to one with the ARM instruction set. I figured if it were low level it would be easy to translate, but I think that wasn’t correct thinking.

  • @senzu4081
    @senzu4081 หลายเดือนก่อน

    Hey, great video, I juste have a question. I'm finishing programming a chess engine in c and I would like to begin another big project, is creating an os a good idea? It requires a lot of work but it seems like the most instructive

  • @preston7376
    @preston7376 5 หลายเดือนก่อน +13

    Compilers are not limited to programs that generate machine code... it is any program which takes a language as input and generates another one as output. Not limited to machine code

    • @adammcdaniel536
      @adammcdaniel536  5 หลายเดือนก่อน +2

      Yep, you can compile to an IR or another source language if you like

  • @deryilz
    @deryilz 6 หลายเดือนก่อน +1

    Great video!