• CanadaPlus@futurology.today
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    1 year ago

    Alright, thanks for the help with terminology. I’m a bit confused about changing types at runtime. I thought a compiled or interpreted language stopped having types at runtime, because at that point it’s all in assembly. (In this case of course it’s scripting, which someone pointed out to me elsewhere)

    • CapeWearingAeroplane@sopuli.xyz
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      That’s a compiled language, an interpreted language is translated to assembly at runtime, in pythons case: pretty much one line at a time.

      Disclaimer: To the best of my knowledge, please correct me where I’m wrong.

      • Skyhighatrist@lemmy.ca
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        1 year ago

        That’s really only native compiled languages. Many popular languages, such as C#, Java, etc. Lie somewhere in between. They get compiled to intermediary byte code and only go native as the very final step when running. They run in a runtime environment that handles that final step to execute the code natively. For .NET languages that’s the CLR (Common Language Runtime).

        For .Net the process goes like this:

        • You write the code
        • Code is compiled to MSIL
        • At runtime when the MSIL is executing a JIT (just-in-time) compiler translates the MSIL into native code.
        • The native code is executed.

        Java has a similar process that runs on the JVM. This includes many, many languages that run on the JVM.

        JavaScript in the browser goes through a similar process these days without the intermediary byte code. Correction, JS in modern browsers also follow this process almost exactly. a JIT compiler compiles to bytecode which is then executed by the browser’s JS engine. Historically JS has been entirely interpreted but that’s no longer the case. Pure interpreted languages are pretty few and far between. Most we think of as interpreted are actually compiled, but transparently as far as the dev is concerned.

        Last, but certainly not least, Python is also a compiled language, it’s just usually transparent to the developer. When you execute a python program, the python compiler also produces an intermediary bytecode that is then executed by the python runtime.

        All that being said, I welcome any corrections or clarifications to what I’ve written.

      • CanadaPlus@futurology.today
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        edit-2
        1 year ago

        I did know the difference, but I didn’t realise it ran one line at a time! I had kind of assumed it at least did one pass through everything before giving output. Thanks.

        • CapeWearingAeroplane@sopuli.xyz
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          I believe it does “one pass” when it loads the code into ram, because syntax errors can be caught before anything runs. But I think the actual interpretation happens pretty much one line at a time :)