官术网_书友最值得收藏!

  • R High Performance Programming
  • Aloysius Lim William Tjhi
  • 293字
  • 2021-08-06 19:17:06

R is interpreted on the fly

In computer science parlance, R is known as an interpreted language. This means that every time you execute an R program, the R interpreter interprets and executes the R code on the fly. The following figure illustrates what happens when you run any R code:

R is interpreted on the fly

Interpreted language versus compiled language

R first parses your source code into an internal R object representation of all the statements and expressions in your R code. R then evaluates this internal R object to execute the code.

This is what makes R such a dynamic and interactive programming language. You can type R statements into the R console and get results immediately because the R interpreter parses and evaluates the code right away. The downside of this approach is that R code runs relatively slow because it is reinterpreted every time you run it, even when it has not changed.

Contrast this with a compiled language such as C or Fortran. When you work with a compiled language, you compile your source code into the machine code before you execute it. This makes compiled languages less interactive because the compilation step can take several minutes for large programs, even when you have made just a tiny change to the code. On the other hand, once the code has been compiled, it runs very quickly on the CPU since it is already in the computer's native language.

Due to R being an interpreted language, every time you run an R program, the CPU is busy doing two things: interpreting your code and executing the instructions contained in it. Therefore, the CPU's speed can limit the performance of R programs. We will learn how to overcome CPU limitations in chapters 3 to 5.

主站蜘蛛池模板: 通渭县| 罗源县| 淄博市| 夏津县| 乌拉特前旗| 龙口市| 安仁县| 呼伦贝尔市| 巧家县| 张掖市| 柳林县| 泰顺县| 新密市| 海口市| 彭阳县| 宽甸| 玉田县| 清水河县| 讷河市| 淮北市| 奉化市| 福贡县| 黎平县| 邵东县| 泰州市| 沾化县| 芦溪县| 高阳县| 叶城县| 湖南省| 安吉县| 陕西省| 鹰潭市| 卓尼县| 晋城| 霍州市| 清涧县| 诸城市| 濮阳市| 安康市| 廉江市|