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 :D
Our caveman ancestors had this silly belief that a tool should "do one thing and do it well"...
But then came Nim!
Nim does everything!
It slices, it dices, it generates code that generates code that generates code...
Write a kernel in Nim. Write your Web client-side in Nim. Earlier today I rewrote some shell scripts in Nim. It's SQL. It's even Haskell!
I predict that soon Nim will compile to DNA, subatomic particles, music videos, sexual fantasies, and even tactless bizarre forum rants that go on and on and don't really have a point...
I predict that soon Nim will compile to DNA, subatomic particles, music videos, sexual fantasies, and even tactless bizarre forum rants that go on and on and don't really have a point...
Don't mistake Nim for Haxe : P