Questions up front:

For the Nim roadmap, how much attention is going to be spent improving the 
backends besides C? Will the js backend be considered a part of the official 
1.0 release?

Are there plans for other official backends in the future?

* * *

Excitement:

I wanted to quickly prototype some visualizations for some graph data I was 
working with. Picked out a Javascript library like visjs or d3js to learn and 
decided to try writing an example in Nim. The experience was wonderfully simple 
after a tiny bit of poking around jsffi.nim and dom.nim.

grapher.nim 
    
    
    import dom, jsconsole, jsffi
    
    var vis {.importc.}: JsObject
    
    var
      nodes = @[
        JsObject{id: 1, label: "Node 1"},
        JsObject{id: 2, label: "Node 2"},
      ]
      edges = @[
        JsObject{"from": 1, "to": 2, "arrows": "to"},
      ]
      options = JsObject{
        "autoResize": true,
        "height": "100%".cstring,
        "width": "100%".cstring,
      }
    
    when isMainModule:
      let container = document.querySelector("#network")
      var data = JsObject{"nodes": toJs nodes, "edges": toJs edges}
      var network = jsnew vis.Network(container, data, options)
      
      console.log(network)
    

index.html 
    
    
    <html>
      <head>
        <title>Grapher</title>
        <link rel="stylesheet" type="text/css" 
href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css"; />
        <script 
src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js";></script>
      </head>
      <body>
        <div id="network"></div>
        <script src="nimcache/grapher.js"></script>
      </body>
    </html>
    

What a lovely experience. Just geeking out about it 

Reply via email to