React Native仍然是解释型的,还是现在已经基于编译了?

huangapple go评论64阅读模式
英文:

Is React Native still interpreted or now it's compilation-based?

问题

在2016年,答案是基于这个问题https://stackoverflow.com/questions/41124338/does-react-native-compile-javascript-into-java-for-android 进行“解释”。然而,自从2022年以来,React Native引入了新的架构:

> 新架构放弃了“桥梁”的概念,转而采用了另一种通信机制:JavaScript接口(JSI)。JSI是一个允许JavaScript对象持有对C++的引用,反之亦然的接口。
一旦一个对象引用了另一个对象,它可以直接调用其方法。所以,例如,C++对象现在可以要求JavaScript对象在JavaScript世界中执行一个方法,反之亦然。

https://reactnative.dev/docs/the-new-architecture/why

据我理解,它仍然是一种解释性方法。但是今天我阅读的一些文章和一个硕士论文声称它是基于编译的,但没有明确解释这种说法。也许我的理解是错误的。那么React Native是仍然是解释性的,还是现在已经编译了?

英文:

In 2016 the answer was " interpreted " based on this question https://stackoverflow.com/questions/41124338/does-react-native-compile-javascript-into-java-for-android. However, since 2022 React Native has introduced new architecture:

> The New Architecture dropped the concept of The Bridge in favor of another communication mechanism: the JavaScript Interface (JSI). The JSI is an interface that allows a JavaScript object to hold a reference to a C++ and vice-versa.
Once an object has a reference to the other one, it can directly invoke methods on it. So, for example, a C++ object can now ask a JavaScript object to execute a method in the JavaScript world and viceversa.

https://reactnative.dev/docs/the-new-architecture/why

To my understanding, it's still an interpreted approach. But some articles and one master's thesis I read today claim that it's compilation-based without clear explanation of the statement. Perhaps my understanding is wrong. So is React Native still interpreted or now it's compiled?

答案1

得分: 4

React Native仍然包括在JS解释器中执行的JavaScript代码,具体来说,由于新架构的更改,将打开哪个解释器将会公开。

以下是一篇详细比较旧架构和新架构的优秀文章:https://medium.com/coox-tech/deep-dive-into-react-natives-new-architecture-fb67ae615ccd

英文:

React Native still includes Javascript code which is executed in a JS interpreter, which one specifically will be open thanks to the changes of the new architecture.

Here's a neat article which compares the old and new architectures in sufficient detail: https://medium.com/coox-tech/deep-dive-into-react-natives-new-architecture-fb67ae615ccd

答案2

得分: 1

React Native 仍然主要是一种解释性语言,即使引入了基于新 JSI 架构的功能。JSI 允许 JavaScript 与原生代码之间更直接的通信,但这并不改变 JavaScript 代码在运行时仍然是解释执行的事实。

英文:

React Native is still primarily an interpreted language, even with the introduction of the new JSI-based architecture. The JSI allows for more direct communication between JavaScript and native code, but it does not change the fact that the JavaScript code is still interpreted at runtime.

huangapple
  • 本文由 发表于 2023年4月19日 22:16:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76055585.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定