Runtime vs. Compile time

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

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

27条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 07:37

    Compile Time:

    Things that are done at compile time incur (almost) no cost when the resulting program is run, but might incur a large cost when you build the program.

    Run-Time:

    More or less the exact opposite. Little cost when you build, more cost when the program is run.

    From the other side; If something is done at compile time, it runs only on your machine and if something is run-time, it run on your users machine.

    Relevance

    An example of where this is important would be a unit carrying type. A compile time version (like Boost.Units or my version in D) ends up being just as fast as solving the problem with native floating point code while a run-time version ends up having to pack around information about the units that a value are in and perform checks in them along side every operation. On the other hand, the compile time versions requiter that the units of the values be known at compile time and can't deal with the case where they come from run-time input.

提交回复
热议问题