|Embedding julia?||Tim||3/20/12 6:24 AM|
This is surely a naive question, but: how hard would it be to embed julia
I took an idle gander at the code in julia_init (init.c), and I was wondering
Two applications occur to me:
2. GUIs. Mike, I only dimly understand you current work on the graphics
Since I know nothing about these issues, it would be nice to hear back from
|Re: [julia-dev] Embedding julia?||Stefan Karpinski||3/20/12 6:29 AM|
Jeff has contemplated this a lot, so I'll let him answer at greater length, but in short the answer is not that hard, but it does require some work still. In "the fullness of time", it will become completely trivial (like as easy as calling a C library from C code).
|Re: Embedding julia?||Tim Hoffmann||3/21/12 2:39 AM|
I was wondering this too. I am playing around with making a small
interactive working environment (especially with 3d graphics) in java
and for now I've settled to communicate with a julia instance via
socket - in fact mimicking the way the scgi-julia server talks to it
(see ui/webserver/...). This seem to work for me until "in fullness of
time" I can just wrap a c library :), but I would like to see some
introspective features to be doable from within julia. Especially is
there a way to get something like the tab_completion from inside
julia? repl-readline does this by traversing a symbol tree, but I have
not found a way to get a handle on that tree from within the language.
(I even played around with calling the c methods via ccall (fun
calling julia implementation methods form within julia) which should
work but I've not yet figured what to give it for the **char
argument... a hint for that anyone?)
Reason I mention that here is, that many application that embed a
julia will need a way to get information about the current session
(like defined symbols, etc...) and I don't know how to get them right
Sorry for jumping on the wagon here...
|Re: [julia-dev] Re: Embedding julia?||Jameson||3/21/12 7:58 AM|
I did some demo language introspection last night (using the tab_completion callback actually). I'll find some place to make that code accessible later tonight. However, I was thinking of writing some more direct methods, to make access to this from Julia easier, if nobody is opposed. Depending on what you are looking for, the function call whos() gets some of that information.
I'm guessing some of libuv stuff will be helpful for doing the sockets directly in Julia, once that branch is stable.
|Re: [julia-dev] Re: Embedding julia?||Stefan Karpinski||3/21/12 8:14 AM|
Moving all of that introspection machinery and even all the repl code into Julia should be doable, and in fact, should ultimately be done. It was all originally in C and gradually more and more of it has migrated to Julia, which is why it's half and half now. The three things that are necessary to make it happen fully are:
None of these is *too* hard, but they are a fair amount of work put together, and not, at the moment strictly necessary, which is the main reason it hasn't happened yet. I personally would love to see all of them.
|Re: [julia-dev] Embedding julia?||Jeff Bezanson||3/21/12 1:12 PM|
Yes, julia is embeddable; in effect ui/repl.c is a C program that
embeds julia. It uses jl_get_global and jl_apply to call the julia
"_start" function, which takes control from there. This is needed
since julia manages its event loop (which includes stdin and sockets
connected to worker nodes). If you don't want/need the event loop
though, it's easy. You can just call a different function than _start.
The "embedding API" is not fully worked out though. There are only a
few entry points, like jl_alloc_array_2d, etc.
Jameson is right, we need some more hooks like getting the list of
On Tue, Mar 20, 2012 at 9:24 AM, Tim Holy <tim....@gmail.com> wrote:
|Re: [julia-dev] Embedding julia?||Jameson||3/21/12 9:02 PM|
I started to add some hooks to allow more introspection and some example code using it (inspect.c and autodoc.jl, respectively). Since it isn't quite complete, I've pushed it only to my fork on GitHub (https://github.com/vtjnash/julia)
Does anyone know how to force unreferenced functions to still be included in the binary? They are in the library, but I can't ccall them without explicitly dlopen'ing libjulia-release.dylib first.
@Jeff: I added some code to ccall to turn null pointers to pointers into Julia exceptions instead of segfaults when I try to use them. However, this seems to reveal that compile_hint in sysimg.jl fails on more or less everything. It this intended/expected behavior?
|RE: [julia-dev] Embedding julia?||Keno Fischer||3/21/12 9:05 PM|
> Does anyone know how to force unreferenced functions to still be included
Add them to src/julia.expmap
|Re: [julia-dev] Embedding julia?||Jeff Bezanson||3/21/12 10:35 PM|
I never intended to allow returning NULL from a c function declared to
return a julia value. I think it should just not be allowed. Re-using
jl_get_specialization for the purposes of compile_hint was kind of a
hack; compile_hint should actually call a void C function that calls
jl_get_specialization and ignores its value.
I think a better interface would be to write a C function that returns