News for hackers. Stuff that matters.
Re:Nimforum: Lightweight alternative to Discourse written in... by tyingq on Friday August 27, 2021 @01:41PM (#28330780)
Interesting. It generates some odd looking JS with a boatload of global vars. https://forum.nim-lang.org/js/forum.js?t=2020-08-2420%3A22%3...
Re:Nimforum: Lightweight alternative to Discourse written in... by dom96 on Friday August 27, 2021 @01:52PM (#28330921)
The forum's frontend and backend are both written in Nim, so what you're seeing is the JavaScript that Nim generates.

Could definitely use a lot of minification.

Re:Nimforum: Lightweight alternative to Discourse written in... by ptx on Friday August 27, 2021 @02:07PM (#28331109)
Having all those globals in the code generated by the Nim compiler seems less than ideal, though. Especially since some of them have very generic names like "raiseException" and "addInt", which could conceivably conflict with some other JS library.
Re:Nimforum: Lightweight alternative to Discourse written in... by sedatk on Friday August 27, 2021 @02:32PM (#28331399)
Isn't that more on the library that has globals registered rather than the application which isn't supposed to be shared?
Re:Nimforum: Lightweight alternative to Discourse written in... by ptx on Friday August 27, 2021 @03:03PM (#28331743)
Yes, Nim being the library in this case. These names are not defined by the application but are part of the code that the Nim compiler generates for any application.

If you wanted to integrate some Nim code in an existing JS application and your existing application already defines the name "raiseException", or "unhandledException", or "framePtr", or "lastJSError", or ... that's going to be a problem.

Re:Nimforum: Lightweight alternative to Discourse written in... by sedatk on Friday August 27, 2021 @03:09PM (#28331803)
You're right about that. Nim compiler needs better isolation. I thought you were talking about the web app.
Re:Nimforum: Lightweight alternative to Discourse written in... by greyivy on Friday August 27, 2021 @03:49PM (#28332245)
Oh yikes. Can anyone shed some light on what this is about?
Re:Nimforum: Lightweight alternative to Discourse written in... by tyingq on Friday August 27, 2021 @04:08PM (#28332436)
Nim compiles to C, but can also compile to JS:

https://nim-lang.org/docs/backends.html#backends-the-javascr...

It appears that the way it does that creates a lot of global vars and functions.