5 ms·
You may be interested in Nim. If you can tolerate working without a REPL, Nim hits essentially all the bullet points you mentioned, from macros to coroutines, m
by pathsjs 10y ago
You may be interested in Nim. If you can tolerate working without a REPL, Nim hits essentially all the bullet points you mentioned, from macros to coroutines, multiple dispatch, ability to call c trivially and python easily and so on.
It has static types and is fast. The libraries for scientific computing are not there yet, but it lends very nicely to mathematical abstraction.
- jjnoakes 10y agoHow does Nim's "trivial" C interop work if Nim is garbage collected and C is not? (Not trolling, genuinely curious).
- pathsjs 10y agoNim compiles to c, hence you can just call c functions. All you need is a signature, which can even be generated automatically from a c header. You can manually allocate memory if you want, and you can also pass pointers, either to manually allocated or gc memory. The gc will not run when c is working, since it is triggered by allocation
- jjnoakes 10y agoSo if I call from Nim to C (passing a gc'd Nim-owned pointer), then that C routine calls back into Nim (via a function pointer, or some other way through the FFI), the nested Nim routine may trigger gc and wipe out the pointer my C code is working with?
- dom96 10y agoYou can instruct the Nim GC to not do that using GC_ref (http://nim-lang.org/docs/system.html#GC_ref,string http://nim-lang.org/docs/system.html#GC_ref,string).
- jjnoakes 10y agoThat's what I figured. So not "trivial".
- dom96 10y agoAre you aware of any language's whose FFI is that trivial?
- jjnoakes 10y agoDo I have to be aware of some other language with such a trivial FFI in order to question the claim that Nim has such a trivial FFI? (C++ has such a trivial FFI, as well as non-GC languages which compile to C code... there may be more as well)
- dom96 10y agoSorry, it wasn't my intention to imply that. I'm genuinely curious, I haven't used many language's FFI to know which is best. You mention non-GC languages. Are there any GC languages that do? :)
- jjnoakes 10y agoI don't think so. I think by virtue of having a GC language you pretty much have to manually anchor pointers before calling code which knows nothing of the GC. But if anyone knows of counter examples, I would be interested in them as well.
- pathsjs 10y agoThe situation that you describe could happen, but it is quite rare in practice. Usually, I call c functions that do their work and be done, such as BLAS. For such cases, you can either manually allocate the pointers you pass to c, or temporarily disable the gc. Each thread has its own heap, so gc for one thread does not break anything in other threads
- jjnoakes 10y agoIt's just those "quite rare in practice" bugs that I'm concerned about. Those tend to cost the most.
- IndianAstronaut 10y ago>If you can tolerate working without a REPL This is going to be a tough sell for any data analytics work.