I'm a rebol, python, C programmer. And I have a need for speed. :-)
(We do a lot of intensive data importing and reconfiguring)
FYI: I've been looking at lua as a way of using C as a host application
for scripts, and Lua is really designed for that.
The problem I've run into is that although one can easily install lua packages on ubuntu (for instance) thru apt-get or Adept Manager, installing from source (which might be necessary to install one's work on a remote slackware, redhat or fedora server) is tough. The tarballs are not documented with install instructions, some tarballs are missing header files, and I haven't had any luck getting help from the lua ML. Grrr! :-(
So my question is: Can newlisp be embedded in a C/C++ application so
that the product is an executable?
OR
Is that in newlisp's future?
OR
will linking the newlisp interpreter directly to the code via
link.lsp (as an example) give a significant increase in performance?
Thanks
Tim
Hi Tim! I have no idea what you're talking about (;-) but it looks a bit like you're trying to do what the newLISP manual says you can do (section 4), ie make newLISP into a shared library that can be called from C.
Is that what you mean by 'embedded'?
newLISP can be compiled as a shared library and you can evaluate newLISP source from inside C code. This chapter in the manual has a C example to import newlisp.so:
http://newlisp.org/downloads/newlisp_manual.html#shared-lib
There are makefiles for all mayor platforms in the source distribution to compile newLISP as a shared library.
Personally I prefer to go the other way around, write speed-critical code in C and import it into newLISP, both approaches are possible.
Lutz
Howdy cormullion:
Quote from: "cormullion"
Hi Tim! I have no idea what you're talking about (;-)
My fault. I should drink more coffee before I write.
Quote from: "cormullion"
but it looks a bit like you're trying to do what the newLISP manual says you can do (section 4), ie make newLISP into a shared library that can be called from C. Is that what you mean by 'embedded'?
Pretty much...
The manual says: Quote
newLISP can be compiled as a UNIX shared library called newlisp.dylib on Mac OS X and as newlisp.so on Linux and BSDs
So the newlisp interpreter is now "embedded" in libdemo.c
To take it a step further:
I'm wondering if newlisp code that I could write could itself be embedded
just as the shared object.
Example: I write a newlisp script, and let's call it "ImportTaxData.lsp"
Could ImportTaxData.lsp be embedded in the c code?
I looks like the libdemo executable in the example in the manual would
be evaluating code passed from "outside" of the application as
opposed to being embedded.
Thanks
tim
Quote
I looks like the libdemo executable in the example in the manual would be evaluating code passed from "outside" of the application as opposed to being embedded
There is now difference if the string containing newLISP source comes from the command-line as in the demo piece in the manual, or is embedded in the C code as a string constant or loaded from a file during runtime. All three methods would work.
Lutz
Quote from: "Lutz"
loaded from a file during runtime.
Hello Lutz:
Would that result in better performance than just running such a file
from the newlisp interpreter?
Thanks
Quote
Would that result in better performance than just running such a file
from the newlisp interpreter?
Not sure what you mean, but when you embedd newlisp in your app the DLL/shared_lib is only loaded once.
So then you have only load-times/execution-time from your loaded/called functions.
When you then load huge newlisp code at startup and only call the code later you will have much difference.
(Also the embedded newlisp will keep state/variables in it's memory/namespace)
Quote
Example: I write a newlisp script, and let's call it "ImportTaxData.lsp"
Could ImportTaxData.lsp be embedded in the c code?
When you compile the newlisp source as a resource string in your app, you can pass it to newlisp on startup with one call. I do this in my neobook-plugin (on WIN) on startup to install some utility/interface functions in newLISP.
Thanks. Mind you - I am asking these questions as someone who
has not written any newlisp code. :-)
It would appear that the greatest performance increase would be in an application that was loaded and remains in memory until terminated by the user (stateful) as opposed to a "stateless" application like a cgi program or a cron job.
I think that my questions might be composed better once I
wrote some code.
Thanks to all for the responses.
Tim
Hey Tim!
Are you really in Palmer? The closest I have been to you is when my family took a cruise to Alaska two years ago and we got as far up as Whittier. What beautiful country you have up there!
--Rick
Indeed I am.
I've taken several day cruises out of Whittier
with visitors to AK and I have surveyed in that area.
The weather in the Whittier area leaves much to be
desired.
Palmer has much better weather.
Tim
(palmer(temp: 20%f snow: 8inches))
Quote from: "Lutz"
newLISP can be compiled as a shared library and you can evaluate newLISP source from inside C code.
GPL requires any code linked with GPLed library (and shared libraries counts too) be also GPLed. This can prevent many people from using newlisp as an embedded scripting language. Lutz, was this you intent? If you want not this, but to require the modifications of newlisp interpreter code itself only be free, then the LGPL license was invented exactly for that.