GithubHelp home page GithubHelp logo

It would be good for Static Hermes if it could use pure JavaScript code(that has no type annotations) with automatic type guessing like "var" code in Dart, or ":=" in Go. about hermes HOT 7 CLOSED

Foxchandaisuki avatar Foxchandaisuki commented on April 28, 2024
It would be good for Static Hermes if it could use pure JavaScript code(that has no type annotations) with automatic type guessing like "var" code in Dart, or ":=" in Go.

from hermes.

Comments (7)

avp avatar avp commented on April 28, 2024

We're designing Static Hermes typed code to be interoperable with existing untyped JS for use with existing libraries, to allow for gradual or partial conversion to typed code.

Inferring and enforcing static types onto untyped code which was not written with static types in mind would be difficult. We can't be sure of the intent of a programmer who thought they were writing untyped (potentially highly dynamic) JS. We do currently do some type inference in the optimization pipeline of the compiler, though - this allows us to emit special instructions when we know you're adding numbers, for instance. There's no runtime checks inserted, this is solely for optimization based on known types.

We do intend to allow some static type inference within typed JS (with certain fallbacks to any type) to allow for easier migration to typed JS and easier authoring. While Static Hermes is still a work in progress, even today var x = [1, 2, 3] will infer that the type of x is number[] in JS code compiled with -typed.

from hermes.

Foxchandaisuki avatar Foxchandaisuki commented on April 28, 2024

We're designing Static Hermes typed code to be interoperable with existing untyped JS for use with existing libraries, to allow for gradual or partial conversion to typed code.

Inferring and enforcing static types onto untyped code which was not written with static types in mind would be difficult. We can't be sure of the intent of a programmer who thought they were writing untyped (potentially highly dynamic) JS. We do currently do some type inference in the optimization pipeline of the compiler, though - this allows us to emit special instructions when we know you're adding numbers, for instance. There's no runtime checks inserted, this is solely for optimization based on known types.

We do intend to allow some static type inference within typed JS (with certain fallbacks to any type) to allow for easier migration to typed JS and easier authoring. While Static Hermes is still a work in progress, even today var x = [1, 2, 3] will infer that the type of x is number[] in JS code compiled with -typed.

Is it possible to migrate existing RN apps running on the Hermes Engine to a fully compiled native binary app, which requires no Virtual Machine like Hermes, without any code changes?

from hermes.

tmikov avatar tmikov commented on April 28, 2024

Is it possible to migrate existing RN apps running on the Hermes Engine to a fully compiled native binary app, which requires no Virtual Machine like Hermes, without any code changes?

Yes, that is already possible, but it is not beneficial. At the moment, untyped code in Static Hermes executes between 0% to 20% faster than Hermes. The resulting binary is very large, because native code is several times larger than the corresponding bytecode.

from hermes.

Foxchandaisuki avatar Foxchandaisuki commented on April 28, 2024

from hermes.

tmikov avatar tmikov commented on April 28, 2024

Yes. Although we are not recommending that, it is certainly possible.

from hermes.

Foxchandaisuki avatar Foxchandaisuki commented on April 28, 2024

from hermes.

tmikov avatar tmikov commented on April 28, 2024

Static Hermes is a JS compiler and engine. It is the equivalent of v8 (JSC, SpiderMonkey, etc). File APIs fall outside of the JS engine responsibility.

Node is not the same as v8, it is a completely separate project by different people (not even the same company) which uses v8 and implements various APIs on top of it. If there is a Node API implementation for Static Hermes, it will not originate from our team.

With that said, Static Hermes makes it very easy to access the existing system APIs (fopen, etc), so in many cases the Node API wouldn't even be necessary.

from hermes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.