> But the problem is that the types will not match, eg a string in JS and TS 
> will be actually an array of int in the generated JS of Nim etc.

It could be solved by improving macro system, so it would transform the whole 
source AST. It may work as follows, at the top of the `.nim` file you specify
    
    
    rules: js_runtime
    
    echo "hi" # will be translated to JString.init("hi")
    
    
    Run

And the rules `js_runtime.nim` contains bunch of macros to be applied to nim 
sources
    
    
    Pseudocode: replace any string `"anything"` into `JString.init("anything")`
    
    # Also, you may add `fmt` by default,
    Pseudocode: replace any string `"anything"` into `fmt"anything"`
    
    
    Run

And you write `jstring.nim` implementation.

With this approach you'll have seamless Nim interoperability with any library, 
like React, etc, it should even work with transpilers like Svelte.

The downside you won't be able to use Nim libraries that use string and don't 
use the `js_runtime` rules. But that's ok, as you barely need any Nim server 
side library in JS land. 

Reply via email to