The macro facilities of Nim seem very impressive. So maybe ES6 module support 
can be done simply as a Nim library, along the lines you describe here? My main 
concern here is not to duplicate generated code: If I make two modules in Nim, 
A and B, and A imports B, and B imports A, then of course two ES6 modules A and 
B should be generated which only contain the code corresponding to Nim module 
A, and B, respectively. As far as I can see right now (and I am an absolute 
newbie in Nim, so I don't see much, probably), what could easily be done is to 
generate two ES6 modules A' and B', where A' includes all of A and B and 
exports only interface A, and B' also includes all of A and B but exports only 
the interface of B. But that's obviously not very nice, or scalable, for that 
matter.

I actually quite like Javascript's module system. I am more of a Standard 
ML/Swift/Scala kinda guy, but JavaScript is starting to look really good in 
terms of being a solid operating system on which to build on. And it seems to 
me that Nim's package and module system is actually a great match for ES6 
modules. Furthermore, types could be optionally encapsulated by wrapping them 
in class wrappers, to guarantee data type invariants even at runtime, if so 
desired. Together with proper support for and integration of WebAssembly out of 
the box, Nim would be one hell of a value proposition for that operating 
system, pretty much impossible to ignore.

But yeah, I can see how that is a lot of work. In principle, do you think this 
could be done via a library?

Reply via email to