Nim programming language finally hit 1.0

bachmeier no at spam.net
Sun Sep 29 14:04:36 UTC 2019


On Sunday, 29 September 2019 at 03:53:57 UTC, Laeeth Isharc wrote:

> I haven't done much with it yet but I hooked up your embedr to 
> our scripting language written in D and it works for examples 
> with very little effort.  I was planning to do same for Julia 
> so we can steal their libraries too.  So currently you can 
> write inline D and R in SIL.  Python isn't far off working and 
> C++ and C# one can do a hello world but not much more (using 
> cling and mono). I think using cling one could maybe expose 
> quite a lot of C++ libraries to D if you don't insist on zero 
> overhead.
>
> What were the practical limitations you encountered with using 
> R libraries from D via embedr?

The practical limitation is that it only does what I need. It's 
built around R's matrix/vector types, which are the ones I use. 
The released version doesn't provide support for multidimensional 
arrays, for instance, and the wrapper for working with R lists 
can still lead to segfaults under some use cases. I have personal 
code (not in embedr) to read both arrays and lists, and to create 
lists to return to R. That was easy to do, but it is limited to 
those uses.

In a nutshell: If you want to pass data between the two languages 
as a vector or matrix, access that data in either language, or 
make changes to the data, it's all there and it should work. If 
you want to return a list from D to R (needed in order to return 
multiple items from a function), that will work. If you want to 
do fancy things, like passing a list from R to D and then making 
arbitrary changes on the D side without unpacking the data, there 
might be problems. There are a lot of issues with automating the 
protection/unprotection from R's garbage collector that the 
cost-benefit analysis has never been in favor of getting it to 
work.

These days, when I do have time to work on this, it's mostly 
going into compilation of a subset of R to D. The idea is that 
while it's useless to try to compile arbitrary R code, there's a 
subset that can be made fast, and it's that subset responsible 
for most bottlenecks. Add type information to your R code, 
compile, and you've got something that runs as fast as D. 
Ultimately, I want it so that a coauthor can write their code in 
R, I can write my code in D, and either of us can run it with 
good performance. If I win the lottery I will take time off of 
work and complete it. :)



More information about the Digitalmars-d mailing list