Extension languages, how does one it into a language ?

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
Primoz128
Enthusiast
Enthusiast
Posts: 212
Joined: Sat Sep 10, 2011 8:25 pm
Location: Slovenia

Extension languages, how does one it into a language ?

Post 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... ?
Zach
Addict
Addict
Posts: 1677
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Extension languages, how does one it into a language ?

Post 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.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Extension languages, how does one it into a language ?

Post 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 :mrgreen:

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.
sorry for my bad english
User avatar
Primoz128
Enthusiast
Enthusiast
Posts: 212
Joined: Sat Sep 10, 2011 8:25 pm
Location: Slovenia

Re: Extension languages, how does one it into a language ?

Post by Primoz128 »

Just 1216 pages to translate :O.
Post Reply