0 votes
by Philip Butler (150 points)
edited by Philip Butler

J, an array language, is my main language and find it excellent for 95% of what I do, mainly data analysis working directly from the REPL.

Forth looks great for my remaining 5%, such as:

  • domain specific sublanguages,
  • on the fly compilation of complex calculation logic that has to run through millions of loops,
  • higher level bindings to systems that require repeated DLL calls using small (i.e. non array) objects
  • (plus a possible smack of hardware tinkering with data loggers).

I never got round to doing all this in C because on Linux I just find a quick and dirty workaround with shell scripts, whilst on Windows, I wouldn't touch a C compiler with a snake hook.

Ideally, I would like to have both a J and a Forth interactive session open simultaneously, which communicate together, as both languages have the same type of interactive development. I will try and do this with a thread on each side communicating through a websocket. However, this would eventually require sending big arrays back and Forth; if on the other hand I use shared libraries (one way or the other, but more likely J calling Forth), I will be loosing lots of interactivity.
The J FFI can allocate a chunk of memory (full forth system?) and directly call a memory address if needed, as well as provide pointers to the data areas of arrays: maybe this is the way to go in the long run?

So I was wondering, can VfXForth be loaded into the address space of another interpreter to combine the benefits of interactive development without any overheads?
(the use case would probably be for semi-tested code, to reduce the frequency of crashes...)

1 Answer

0 votes
by Stephen Pelc (4.3k points)
My apologies for the delay in answering - domestic and technical nightmares now resolved.

When we did this in the past, we used named pipes for comms because there is no need to interfere with other processes address space.
1) you can tell if the pipe is there. This allows you to determine if the pipe server (say Forth) is running.
2) You still have two processes running. On one or both sides side you can have a pipe task that feeds source code into the REPL.
ago by Philip Butler (150 points)
Thanks. Sounds nice and robust;
...