Closed unquietwiki closed 4 years ago
Actually the JS and the C halves are disconnected, the JS implementation is the old one, and I'm completely rewriting it in C because the goal was to make it as embeddable as possible. JS was chosen initially because I knew it well so it could at least be embedded in the website and in chat bots, but I prefer a C rewrite so I can embed it in other languages.
Edit; If Nim can compile to old c89 then maybe.
@Camto Thanks for clarifying. https://nim-lang.org/docs/nimc.html#cross-compilation might resolve that.
Related to what you're attempting, https://github.com/marcobambini/gravity might be relevant.
calc= isn't meant to be compiled on its own, the core in fact hos no IO whatsoever. It's meant to be used like Lua, as a library. The idea is for any language to be able to run calc= via its own C FFI. If Nim can produce stuff Python and JS can easily hook into, that could be neat. I'm an absolute noob when it comes to FFIs, never done it before, so I have no clue.
@Camto well for Nim - Python there's https://github.com/yglukhov/nimpy
Edit; If Nim can compile to old c89 then maybe.
Nim compiles to C code, but this code looks like a messy unreadable garbage.
Edit; If Nim can compile to old c89 then maybe.
Nim compiles to C code, but this code looks like a messy unreadable garbage.
well, I'm not sure what's the original reason for using Nim in this issue, but "unreadable garbage" isn't a reason to NOT use Nim - that C isn't supposed to be read by humans anyway, it's there for the C compiler. For Nim C is just a backend just like an LLVM IR might be (there's an unofficial backend for it - https://github.com/arnetheduck/nlvm) EDIT: Although I don't really know if Nim's C output is C89 compatible, sorry
For the current interpreter rewrite (same version of calc=), I'm just gonna stick with what I'm using. When I move on to calc= v2, then I'll start looking at other low level alternatives.
I run r/altprog on Reddit, and saw this posted there. I see this is being done with a mix of JS and C, with some fits & starts. I was made aware the other day of https://nim-lang.org/ ; which has tie-ins and outputs to both. It might be useful here?