Forums

Hosting Cobra in VB.NET or C#

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Hosting Cobra in VB.NET or C#

Postby Stugol » Sat Nov 19, 2011 12:05 pm

Hi. Python and Ruby can be hosted in VB or C# like this:

Code: Select all
Imports Microsoft.Scripting, IronPython.Hosting

Dim pyEngine = IronPython.Hosting.Python.CreateEngine
Dim ScriptSource = pyEngine.CreateScriptSourceFromString("...some code...", SourceCodeKind.Statements)

ScriptSource.Execute()

Is there any way to do the same with Cobra? I'd like to run Cobra scripts on the fly in my own software.
Stugol
 
Posts: 5

Re: Hosting Cobra in VB.NET or C#

Postby Charles » Sun Nov 20, 2011 3:33 am

I set Cobra up to provide a library containing the compiler, but it apparently broke at some point as I discovered the last time I went to use it. It's on my list to fix.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Hosting Cobra in VB.NET or C#

Postby Stugol » Sun Nov 20, 2011 7:20 am

Hmm. When .NET languages are compiled on the fly using the CodeDom, they take a few seconds to compile; and utilise temp files on the system and stuff like that. It's quite a heavyweight operation, and not really suitable for quick scripts. When IronPython and IronRuby are compiled on the fly, in the way I showed you, they execute immediately with no system impact. They are, in essence, scripting languages.

So, my questions are these. Firstly, when Cobra is hosted in this manner (which, as you say, doesn't currently work), how will it be done? Like Python, or like .NET? Is it a heavyweight operation, or a quick one suited to scripting?

Secondly, assuming it is a lightweight operation, how soon could we expect this facility to work properly? (If it is a heavyweight operation, then I'll just carry on using Python for my in-app scripting.)
Stugol
 
Posts: 5

Re: Hosting Cobra in VB.NET or C#

Postby Charles » Sun Nov 20, 2011 11:42 am

I'm sorry to report that currently it is a heavyweight operation, primarily because Cobra uses C# as its back-end. While this has some nice advantages, it has the disadvantage of being slow.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 46 guests