Short Lesson - Compilation vs Interpretation

Поділитися
Вставка
  • Опубліковано 10 лют 2025
  • What exactly are the differences between compiling and interpreting a programming language? What are the pros and cons of each? Find out in this video!

КОМЕНТАРІ • 98

  • @gr33ngunner007
    @gr33ngunner007 4 роки тому +30

    Just to be clear about interpreting, the interpreter doesn't convert the source code to machine code during runtime. Instead a separate pre-compiled program called the interpreter looks at your source code and then decides which functions in itself it will use to get the same effect. The interpreter is a program that already has all the basic functions of a program build into it and is compiled for a specific machine. In reality you always have to have some part of your language dependent on the type of processor due to their unique instruction sets.
    Java on the other hand actually does compile as it runs each line at a time but this is possible because it firsts compiles java to an intermediate language called byte code. The byte code can be optimized here for runtime-compilation, then it compiles one line at a time directly to machine code. This is referred to as Just In Time (JIT) compilation. A good thing about this is once the program is compiled once, it doesn't have to recompile until some changes are made. That also goes for byte code, you can pass that around after compiling to any machine that has the java virtual machine.
    A rough analogy for all the systems could be compiling is like ordering a chair from a factory. You give the factory blueprints and it creates the chair from scratch. [Code -> Machine Code]
    Interpreting is like going to a store that has pre-built chairs, the store looks at your blueprint and finds the best match to what you want. Meanwhile, the store already stocked up on chairs made from a factory. [Code -> Fed into Interpreter -> Interpreter executes some basic function for one expression of code]
    Java or JIT is like ordering from IKEA. The factory will pre-build parts of the chair for you, but once you get the package at home, you have to put the parts together on the fly.
    [Code -> Byte code -> runtime compilation]
    This is my basic understanding of these systems and I hope it helps.

    • @navneetiyer
      @navneetiyer 4 роки тому +1

      Thanks

    • @gaborm4767
      @gaborm4767 3 роки тому

      what is the benefit of interpreter over compiler?

  • @kpath74
    @kpath74 3 роки тому

    Your the 5th video I watched for this subject and you by far explained it the best and in less time.

  • @ashwinramaswamy4059
    @ashwinramaswamy4059 4 роки тому +2

    Great video! Finally someone that explains it clearly and concisely

  • @jorgeozunaadams6760
    @jorgeozunaadams6760 3 роки тому

    I was taking notes and this gave me everything I needed and in a short video to boot

  • @bharatnc
    @bharatnc 7 років тому +70

    Java is a compiled language rather than an interpreted language. However, Java does not directly compile into machine code. It goes through an intermediate step and gets compiled into bytecode and then finally into machine code. That is probably why the video mentions that it is interpreted. But, rather it should be classified as a compiled language.

    • @bgzdevtips3762
      @bgzdevtips3762  7 років тому +22

      bharat nc Yes, your right. I will see about updating the video since its getting more views. Thanks!

    • @petteroakley8000
      @petteroakley8000 4 роки тому +1

      This was great, thanks, I've been looking for "building your own compiler with c++ pdf" for a while now, and I think this has helped. Have you heard people talk about - Fanilliam Nonpareil Formula - (do a google search ) ? It is a good one off guide for discovering how to create your own programming language minus the normal expense. Ive heard some super things about it and my friend got amazing results with it.

    • @zeektm1762
      @zeektm1762 4 роки тому +2

      Why does it require the Java Virtual Machine if it could theoretically be compiled beforehand?

    • @kevingepulle4371
      @kevingepulle4371 4 роки тому +2

      @@zeektm1762 Java is both compiled and interpreted. It uses the ability of compilation to shorten the running time and also the ability of interpretation to make it runnable on any platform such as windows or mac without the need to recompile. JVM or the Java Virtual Machine is very important since it is the "reason" why it can be runnable on any platform. It is what we may say a "pseudo-computer" where your java bytecode needs to run. A ghost machine indeed if you ever bumped on that term.

    • @kevingepulle4371
      @kevingepulle4371 4 роки тому +1

      @@zeektm1762 also, the java bytecode is Java's own bytecode, meaning it cannot be run by any platform (OS) unless they have the JVM.

  • @arturshalimov4396
    @arturshalimov4396 5 років тому +9

    Thank you so much mate, I couldn't wrap my head around the idea of "compiling/interpreting", coz others use some incomprehensible examples😄

    • @toxin1882
      @toxin1882 4 роки тому +1

      I've seen other people explain it with complicated words to sound more sophisticated.

    • @trejohnson7677
      @trejohnson7677 3 роки тому +1

      This is pretty high level. If you truly want to understand, read the compiler book with a dragon on it, trust

  • @Tutomenacom
    @Tutomenacom 7 років тому +1

    The most important tutorial on this subject,
    I just have one note :
    V8 Engine compiles JavaScript code into machine code at execution by implementing a JIT compiler like a lot of modern JavaScript engines such as SpiderMonkey or Rhino (Mozilla) are doing.
    Thank you (y)

  • @akrm3240
    @akrm3240 3 роки тому

    Thank you sm! You helped me understand it quicker than reading miles of words on google. :D

  • @mosab643
    @mosab643 4 роки тому

    Best video out there explaining this stuff.

  • @ninalin7611
    @ninalin7611 6 років тому

    I am doing a project fitting IronPython in some C# codes. This helps a lot to understand basic language concepts. Please make more tutorials! I love those graphs, very straight-forward.

    • @bgzdevtips3762
      @bgzdevtips3762  6 років тому

      Nina Lin that's awesome. Very glad to hear that!

  • @SamuelHauptmannvanDam
    @SamuelHauptmannvanDam 6 років тому +3

    All I fucking needed. Thanks!
    Asked my professor: "You should already know this."

  • @VirtuesQuest
    @VirtuesQuest 4 роки тому

    Thanks so much for sharing. I am taking a class now. Programming is tough for me. I am a visual learner. This helped a ton.

  • @NarePoghosyan
    @NarePoghosyan 3 роки тому

    This was the best explanation, thank you!

  • @coldflames3603
    @coldflames3603 4 роки тому

    Finally understand the difference. Thnx

  • @charlesliang4118
    @charlesliang4118 4 роки тому

    Thanks man really clear and simple video

  • @rasheedm2084
    @rasheedm2084 5 років тому +3

    Great clarification ..

  • @thedoctor5036
    @thedoctor5036 3 роки тому

    answering to your last question : yes it does! Thank You!

  • @huskyspeaks
    @huskyspeaks 6 років тому +1

    Easy to understand and informative. Thank you.

  • @pepaokurka3892
    @pepaokurka3892 4 роки тому +1

    This is an excellent video! Thank you :)

  • @zachslichta5858
    @zachslichta5858 3 роки тому

    So helpful, thank you!

  • @TeamUnpro
    @TeamUnpro 3 роки тому

    Duuuude, that game editor reference :D

  • @RageAgainstTheFist
    @RageAgainstTheFist 7 років тому +2

    Great explanation .
    Thanks!!

  • @dominiquedevries9972
    @dominiquedevries9972 4 роки тому

    You are great! When is the next video?

  • @neerajmahapatra5239
    @neerajmahapatra5239 6 років тому

    superb explaanation !!!! the best one....

  • @devgarg7469
    @devgarg7469 4 роки тому

    THANK YOU

  • @jordangaines496
    @jordangaines496 7 років тому +3

    It is my understanding that the compiler does not directly convert a language into to binary. (I may be wrong feel free to correct me.) It rather feeds the language into an assembler to converted into binary. Just a small slip-up i thought I'd mention. Other than that, great video.

    • @bgzdevtips3762
      @bgzdevtips3762  7 років тому +3

      Comedic Chimera Yes! you are correct. Though it can depend on the compiler. Some compilers will use an assembler and some have options to convert directly to machine code. Though I didn't want to get too bogged down in the details in this video. Although if you look at my 'Translation/Compilation Process' video, I do go over the involvement of the assembler. But good catch!

    • @MR2SpyerJournal
      @MR2SpyerJournal 7 років тому +2

      He's leaving out heavy details for guys like me! haha! Great video. Currently learning Python coming over from Java. Wow! It's kind of refreshingly fun. Super flexible, easy to just run it.

  • @sankarsan
    @sankarsan 6 років тому

    Thanks a lot for the video. Keep up the good word.

  • @limitless1692
    @limitless1692 5 років тому +7

    Aaaa
    I always believed that C# is compiled ...
    Nice so it is interpreted ..
    Thanks :)

    • @MGSncB
      @MGSncB 5 років тому +1

      Not exactly - the CLR JIT-compiles the CIL code method by method just before running and then native machine instructions are stored in some cache areas. It is never interpreted, and methods that are never called just don't get JITted at all.
      Java, on the other hand, uses the JVM interpreter to execute the bytecode, in conjunction with the HotSpot JITter when there's potential for optimization.
      Both C# and Java can be AoT-compiled by NGen and LLVM (for example) respectively.

  • @muhammadsafiullah8428
    @muhammadsafiullah8428 5 років тому +2

    Thanks for such a fine explanation. Love you 💖💖💖💖

  • @vezcalizee_
    @vezcalizee_ 5 років тому

    Thank you so much man, i owe you one...
    your video helps me for my college task hahaha...

  • @Emmaplaysviolin
    @Emmaplaysviolin 7 років тому +1

    Thank you very much, it helped me a lot 😃😃

  • @benedictjojo5761
    @benedictjojo5761 6 років тому

    Good teaching!

  • @sudhakarankmps389
    @sudhakarankmps389 5 років тому

    Awesome broo

  • @fiyinaregbe2740
    @fiyinaregbe2740 3 роки тому

    I am guessing that is why you can see JavaScript source code in chrome "View Page Source" because it is interpreted.

  • @tekguru7
    @tekguru7 6 років тому

    Wonderful info 👍🏻

  • @Hamheadon
    @Hamheadon 2 роки тому

    If intermediate languages compile to GIT, but are actually still interpreters, can you call them a hybrid of compiler & interpreter?

  • @vikramsarabhai1
    @vikramsarabhai1 6 років тому

    Pretty good explanation.

  • @ValueBluff19
    @ValueBluff19 5 років тому

    Thank you.

  • @DulanaSenavirathna
    @DulanaSenavirathna 5 років тому

    Thanks.

  • @YoutubeUser01
    @YoutubeUser01 4 роки тому

    you deserve more subscibers :)

  • @jimbo2849
    @jimbo2849 5 років тому

    Thank you

  • @gahlyogu4570
    @gahlyogu4570 7 років тому +27

    5:55 ...wait, "java is interpreted language" ?

    • @gahlyogu4570
      @gahlyogu4570 7 років тому +1

      ...I know how the JVM works. Ive actually coded a VM and interpreter in Java for a dummy source code
      ...I would just consider the whole process more like a compiled language rather than interpreted , or at least "compiled and interpreted"

    • @bity-bite
      @bity-bite 4 роки тому

      @@gahlyogu4570 k

    • @ghume79
      @ghume79 4 роки тому

      No it is not. And this is a error taught by many. Java source code is compiled into bytecode. Bytecode is then interpreted into the respective machine language. When someone says Java is interpreted, it shows a fundamental lack of understanding (understandably) of how Java source code gets to machine code.
      Finally, as the author himself said, there are no 'compiled' or 'interpreted' languages. They are operations that can be carried out on ANY programming language.

  • @erensrtky
    @erensrtky 5 років тому

    Nice explonation thank you !

  • @dhanashekaranm4725
    @dhanashekaranm4725 6 років тому

    Thank you soo much for the video💐

  • @samuelp7847
    @samuelp7847 4 роки тому

    Why do I need to compile my JavaScript changes before I check into the build then? Am I technically “compiling” it into IL?

  • @bryanstark324
    @bryanstark324 5 років тому +1

    Wait a minute what??? Java and C# are compiled languages not interpreted!

  • @vortical911
    @vortical911 3 роки тому

    i like how you pronounce the word 'executable' lol

  • @tom_something
    @tom_something 4 роки тому

    Why is it that a major piece of software can be provided to consumers as a pre-compiled executable which seems to work on all CPUs within a specific operating system, rather than the user having to compile from source for their hardware? (You can probably guess I'm an absolute beginner when it comes to compiled software.)

    • @ghume79
      @ghume79 4 роки тому

      Because it has been precompiled for the main CPU families and operating systems. That is when you click on a download link, you would be given the executable that is pre-compiled for your system.

  • @Layarion
    @Layarion 6 років тому +1

    2:45 people always mention "speed". if we are talking about a videogame, are we talking about a) how fast I can make my character jump? b) how long it takes to load a level? c) how long it takes to put the cd in and wait for it to load? or d) all of the above?

  • @isurajdhungel
    @isurajdhungel 6 років тому +2

    How Compilation would be more faster than Interpretation as you mentioned it requires extra compiling step ?

    • @nish3003
      @nish3003 4 роки тому

      Suraj Dhungel I have that exact same doubt

    • @mr_madds
      @mr_madds 4 роки тому

      compiling doesn't mean running the code. The CPU is way faster than a program that reads line by line and has to execute everything on the spot.

    • @ghume79
      @ghume79 4 роки тому

      The compiled binary is executed faster, because it is compiled into machine code. When people make the comparison, they are talking about a compiled executable's performance vs an interpreted progams's performance.
      Not compilation vs interpretation.

  • @Xxcept1onXD
    @Xxcept1onXD 6 років тому

    nice content

  • @PouyaAtaei
    @PouyaAtaei 3 роки тому

    Javascript is utilizing JIT.

  • @userR2157
    @userR2157 5 років тому

    which program did u use to make these slides ??

  • @johnbrooks5752
    @johnbrooks5752 5 років тому +4

    cool thanks.
    I wish my brain was like C#(interpreter). After 2 hours of work, it stops working and needs to recompile my whole life(like C++). Which takes hours and A lot of people dont get it since its not cross platform.
    I need to share my private parts? My source code is private I need to make it public.

    • @auiko4
      @auiko4 5 років тому

      and people might get it… each person has kind of the same source codes, if we go on with the metaphor ;)

  • @inang1968
    @inang1968 4 роки тому +1

    4:33 wait did u say computer engineers?
    I just graduated from that but had no idea we do those to improve???
    Im shookt

  • @iedi3
    @iedi3 3 роки тому

    PHP has now JIT

  • @OnsoDev
    @OnsoDev 5 років тому

    Interpreters don't translate into machine code directly, this causes confusion for beginners. The difference between an Interpreter and Compiler is not just in timing or sequence but also on the output.

  • @igmetrix1481
    @igmetrix1481 4 роки тому

    Why can't I compile a single line????

  • @user-qw8ku3pn9x
    @user-qw8ku3pn9x 8 років тому

    great
    thanks

  • @aimenmedjadder7202
    @aimenmedjadder7202 8 років тому

    thnx bro

  • @fitcrocompany7467
    @fitcrocompany7467 5 років тому

    Are you whispering in the mic?

  • @Stoic623
    @Stoic623 5 років тому

    is Java not cross-platform.?

  • @ghume79
    @ghume79 4 роки тому

    Java is not interpreted. Java is compiled into bytecode. The bytecode is then interpreted. If Java was interpreted, there would be no need for the -javac command. Java source code is not bytecode. Great video anyway.

  • @joefivaz6087
    @joefivaz6087 4 роки тому

    is it too difficult to be clear about whether you are representing a compiler or interpreter?

  • @HdRFan7
    @HdRFan7 6 років тому

    Wait, modern browsers jit-compile JavaScript...

    • @bgzdevtips3762
      @bgzdevtips3762  6 років тому

      Honestly, now a days the line is becoming blurred on what exactly gets compiled and what doesn't. I know at one point in time Javascript and php were not jit-compiled. However, I believe, technically, javascript is 'jit-compiled' in most all modern browsers but don't quote me on that. Though I don't think this process happens in the same way as C# and Java as no 'bytecode' is produced. Someone can correct me if I'm wrong.

  • @mirandansa
    @mirandansa 7 років тому +1

    For me, the source code being public is not a con.