The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Scripts in Application

I am sure there will be an easy answer to this.  I want to develop a Visual Basic application (or possibly C++) that can load "code" on the fly.  I want to be able to change how a program executes without having to reload the entire EXE.  This will be a server application and I dont want to restart the server as many connections will be lost.

I have done some searching for scripts in your application but havent seen anything that hits the mark.

It would be nice if I could have all the support code (the stuff that could change) be in DLL's which I could unload and then reload.  I have seen things about this but dont know if its feasible.

Other thoughts that came to mind were scripts that the app loads and could unload.

Any thoughts or comments are appreciated.
Nick Koranda Send private email
Friday, September 09, 2005
 
 
For C++, DLLs are probably the easiest, because you won't need to write a debugger for a scripting language. (Even the off-the-shelf ones were limited in that respect, last I looked.) It's neat-o to avoid the compilation step, and you'll get nerd brownie points from making your stuff scriptable, but you'll pay a hard price, in the shape of debugging by "print" -- sure, you can do it, it's just divide and conquer, but just one or two annoying tricky bugs will wipe out in one step all of the time advantage. If you have decent support classes and avoid lots of new/delete (use CArray/std::vector, CString/std::string, etc.) then you'll be pretty productive in C++ anyway.

I'm afraid I don't know what the VB equivalent might be.
Tom_
Friday, September 09, 2005
 
 
If using C++ I would definitely reccomend using Lua (http://www.lua.org).  Lua is easy to embed within your C++ application as a DLL or static library. You can then link your C/C++ data and functions to Lua so that it can be accessed through Lua scripts in a post-compilation manner.
Bacon
Friday, September 09, 2005
 
 
Python is embeddable in C++ applications. For an example in action, check out http://blender.org

It's a 3d modelling/animation/rendering application with an embedded Python interpreter that's used for scripting the application.
BenjiSmith Send private email
Friday, September 09, 2005
 
 
Tcl was designed specifically as a scripting language for C/C++ programs. It has a pretty straightforward API. I think Perl can also be used as an embedded scripting language.
EKB Send private email
Friday, September 09, 2005
 
 
You could also embed the SpiderMonkey javascript engine. Iit's the same code that underlies the FireFox browser, so you know it's a very solid javascript implementation.

http://mozilla.org/js
BenjiSmith Send private email
Friday, September 09, 2005
 
 
Since you mentioned VB, you're on Windows. You're in luck.

Take a look through MSDN for the ActiveX Scripting Control. Its a control you can drop onto your form and it'll run scripts in any ActiveX scripting language. These include VBScript and JScript out of the box, and there are ActiveX Script Engines for Perl, Python, TCL, Lua, and tons of other languages as well.

The control is available for free from Microsoft here:

http://www.microsoft.com/downloads/details.aspx?FamilyId=D7E31492-2595-49E6-8C02-1426FEC693AC&displaylang=en
Chris Tavares Send private email
Saturday, September 10, 2005
 
 
For Windows apps, use Microsoft stuff--implement IDispatch objects and host ActiveX scripts. That is (or was) the buzzword name for how you host Javascript, VBScript, etc.

This might be helpful, though I only glanced at it:

http://www.codeguru.com/Cpp/COM-Tech/activex/scripting/article.php/c2563/
mb Send private email
Saturday, September 10, 2005
 
 
Thanks for all the great advice!  I will look into these.  These are what I am looking for.
Nick Koranda Send private email
Sunday, September 11, 2005
 
 
Another option is to use Windows Script Host (WSH).

The Zeus editor uses WSH to implement its Java Script and Visual Basic scripting and based on that experience I would say it is quite straight forward to embed WSH into any windows application.
Jussi Jumppanen
Monday, September 12, 2005
 
 
If you only want to do this so you can update the app without terminating all running instances there might be another option.
I seem to remember that Windows has the ability to overwrite a DLL that is being used. Any existing users continue with the version in memory and any new users get the new version.
Adrian
Tuesday, September 13, 2005
 
 
My use is to have a running executable that can be updated without breaking the connections and losing the data it has.  I want the "support code" to be changeable on the fly.  There will be times when the program will need to be restarted, but I wanted as much functionality to be changed dynamically.  I believe the best choice for me right now is to load and unload DLL's.

In case any one wanted to know, this will be for a persistent online game server.
Nick Koranda Send private email
Tuesday, September 13, 2005
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz