Runtime vs. Compile time

前端 未结 27 954
后悔当初
后悔当初 2020-11-22 06:50

What is the difference between run-time and compile-time?

相关标签:
27条回答
  • 2020-11-22 07:19

    IMHO you need to read many links , resources to make an idea about the difference between Runtime vs Compile time because it is a very complex subject . I have list below some of this pictures/links that I am recommend .

    Apart from what it is said above I want to add that sometimes a picture worth 1000 words :

    1. the order of this two: first is compile time and then you run A compiled program can be opened and run by a user. When an application is running, it is called runtime : compile time and then runtime1 compile time and then runtime1 ;

    CLR_diag compile time and then runtime2  CLR_diag compile time and then runtime2

     from Wiki  
    

    https://en.wikipedia.org/wiki/Run_time https://en.wikipedia.org/wiki/Run_time_(program_lifecycle_phase)

    Run time, run-time, or runtime may refer to:

    Computing

    Run time (program lifecycle phase), the period during which a computer program is executing

    Runtime library, a program library designed to implement functions built into a programming language

    Runtime system, software designed to support the execution of computer programs

    Software execution, the process of performing instructions one by one during the run time phase

    List of compilers https://en.wikipedia.org/wiki/List_of_compilers

    • search on google and compare runtime errors vs compile errors:

    runtime errors

    compile errors ;

    1. In my opinion a very important thing to know : 3.1 the difference between build vs compile and the Build Lifecycle https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

    3.2 the difference between this 3 things : compile vs build vs runtime

    https://www.quora.com/What-is-the-difference-between-build-run-and-compile Fernando Padoan, A developer that's just a bit curious for language design Answered Feb 23 I’m going backwards in relation to other answers:

    running is getting some binary executable (or a script, for interpreted languages) to be, well… executed as a new process on the computer; compiling is the process of parsing a program written in some high level language (higher if compared to machine code), checking it’s syntax, semantics, linking libraries, maybe doing some optimization, then creating a binary executable program as an output. This executable may be in the form of machine code, or some kind of byte code — that is, instructions targeting some kind of virtual machine; building usually involves checking and providing dependencies, inspecting code, compiling the code into binary, running automated tests and packaging the resulting binary[ies] and other assets (images, configuration files, libraries, etc.) into some specific format of deployable file. Note that most processes are optional and some depend on the targeted platform you are building for. As an example, packaging a Java application for Tomcat will output a .war file. Building a Win32 executable out of C++ code could just output the .exe program, or could also package it inside a .msi installer.

    0 讨论(0)
  • 2020-11-22 07:20

    Compile-time: the time period in which you, the developer, are compiling your code.

    Run-time: the time period which a user is running your piece of software.

    Do you need any clearer definition?

    0 讨论(0)
  • 2020-11-22 07:20

    As an add-on to the other answers, here's how I'd explain it to a layman:

    Your source code is like the blueprint of a ship. It defines how the ship should be made.

    If you hand off your blueprint to the shipyard, and they find a defect while building the ship, they'll stop building and report it to you immediately, before the ship has ever left the drydock or touched water. This is a compile-time error. The ship was never even actually floating or using its engines. The error was found because it prevented the ship even being made.

    When your code compiles, it's like the ship being completed. Built and ready to go. When you execute your code, that's like launching the ship on a voyage. The passengers are boarded, the engines are running and the hull is on the water, so this is runtime. If your ship has a fatal flaw that sinks it on its maiden voyage (or maybe some voyage after for extra headaches) then it suffered a runtime error.

    0 讨论(0)
  • 2020-11-22 07:21

    Following from previous similar answer of question What is the difference between run-time error and compiler error?

    Compilation/Compile time/Syntax/Semantic errors: Compilation or compile time errors are error occurred due to typing mistake, if we do not follow the proper syntax and semantics of any programming language then compile time errors are thrown by the compiler. They wont let your program to execute a single line until you remove all the syntax errors or until you debug the compile time errors.
    Example: Missing a semicolon in C or mistyping int as Int.

    Runtime errors: Runtime errors are the errors that are generated when the program is in running state. These types of errors will cause your program to behave unexpectedly or may even kill your program. They are often referred as Exceptions.
    Example: Suppose you are reading a file that doesn't exist, will result in a runtime error.

    Read more about all programming errors here

    0 讨论(0)
  • 2020-11-22 07:21

    Here is a quote from Daniel Liang, author of 'Introduction to JAVA programming', on the subject of compilation:

    "A program written in a high-level language is called a source program or source code. Because a computer cannot execute a source program, a source program must be translated into machine code for execution. The translation can be done using another programming tool called an interpreter or a compiler." (Daniel Liang, "Introduction to JAVA programming", p8).

    ...He Continues...

    "A compiler translates the entire source code into a machine-code file, and the machine-code file is then executed"

    When we punch in high-level/human-readable code this is, at first, useless! It must be translated into a sequence of 'electronic happenings' in your tiny little CPU! The first step towards this is compilation.

    Simply put: a compile-time error happens during this phase, while a run-time error occurs later.

    Remember: Just because a program is compiled without error does not mean it will run without error.

    A Run-time error will occur in the ready, running or waiting part of a programs life-cycle while a compile-time error will occur prior to the 'New' stage of the life cycle.

    Example of a Compile-time error:

    A Syntax Error - how can your code be compiled into machine level instructions if they are ambiguous?? Your code needs to conform 100% to the syntactical rules of the language otherwise it cannot be compiled into working machine code.

    Example of a run-time error:

    Running out of memory - A call to a recursive function for example might lead to stack overflow given a variable of a particular degree! How can this be anticipated by the compiler!? it cannot.

    And that is the difference between a compile-time error and a run-time error

    0 讨论(0)
  • 2020-11-22 07:24

    Translation of source code into stuff-happening-on-the-[screen|disk|network] can occur in (roughly) two ways; call them compiling and interpreting.

    In a compiled program (examples are c and fortran):

    1. The source code is fed into another program (usually called a compiler--go figure), which produces an executable program (or an error).
    2. The executable is run (by double clicking it, or typing it's name on the command line)

    Things that happen in the first step are said to happen at "compile time", things that happen in the second step are said to happen at "run time".

    In an interpreted program (example MicroSoft basic (on dos) and python (I think)):

    1. The source code is fed into another program (usually called an interpreter) which "runs" it directly. Here the interpreter serves as an intermediate layer between your program and the operating system (or the hardware in really simple computers).

    In this case the difference between compile time and run time is rather harder to pin down, and much less relevant to the programmer or user.

    Java is a sort of hybrid, where the code is compiled to bytecode, which then runs on a virtual machine which is usually an interpreter for the bytecode.

    There is also an intermediate case in which the program is compiled to bytecode and run immediately (as in awk or perl).

    0 讨论(0)
提交回复
热议问题