Page 1 of 1
Extension languages, how does one it into a language ?
Posted: Sat Oct 20, 2012 7:13 pm
by Primoz128
I have heard and read that Lua, Python, Ruby and more are extension languages made to add functionality and make coding easier where performance is not needed.
But heres the question... how does one plug in such languages into languages like C, C++, Visual Basic, Pure Basic and others... ?
Re: Extension languages, how does one it into a language ?
Posted: Sun Oct 21, 2012 4:14 pm
by Zach
I don't know the specifics about what is involved.
But basically it is like any other plugged in functionality that we use wrappers for. You need to have bindings for the language in question to interface with your programming language.. I suppose an overly simplified way would be to think of it as a "virtual stack" that the two languages use to pass data back and forth between each other, in that way allowing access to each other.
i.e Purebasic says, "Hey stack, tell Python to change Variable to value 5" and the Stack says "Hey Python, PB wants you to change this Variable to the value 5" and Python says "OK, but I also need Purebasic to change Var_Mystery to "whodunnit?", oh and I need to know the value of "Thewaiterinthekitchen" ", and so on and so forth.
If you look around the forum, you will find wrappers for scripting languages in various states of (in)completion.
Scripting languages can do a lot to help simplify and facilitate rapid development and also user / on-the-fly interaction with your program. But not all languages are created equal. LUA is highly optimized and a favorite for game developers, who usually use it for A.I scripts. Python has a lot of specialized math libraries that makes it very useful to scientific based research.
So scripting languages don't necessarily have to come with a performance hit.
Re: Extension languages, how does one it into a language ?
Posted: Sun Oct 21, 2012 9:44 pm
by Josh
To run a scripting language you need a scripting host, like implemented in IE, WSH, SQL Server or Outlook Forms.
A simple way to use scripting languages is the
ScriptControl. You can find some examples here in the forum. But the using of this dumb host is very limited and microsoft has suspended further development. So there is no version for X64.
To get the 'full power' of active scripting, you can write your own host. A good tutorial is the book
Windows Scripting by
Holger Schwichtenberg. 1216 pages in german language
Active scripting is implemented in windows with vbscript and jscript. There are further languages like PerlScript, REXX, PythonScript, ActiveScriptRuby or LUAScript are running under active scripting.
Re: Extension languages, how does one it into a language ?
Posted: Mon Oct 22, 2012 11:35 am
by Primoz128
Just 1216 pages to translate :O.