views:

1303

answers:

3

I've always had this dream of creating a 'real exe' from a scripting language. With the available of DLR-based implementations of Python and Ruby, is this getting any closer to reality?

I'd like to create a 'real application':

  • A Windows Forms App
  • A Console App
  • A Windows Service

And have the unit of distribution be a compiled exe.

Is this possible? Or has MS just created script file interpreters based on .NET?

If you are doing this, how are you structuring your applications / projects? Are you using a hybrid of C# and DLR code?

A: 

Not sure how complex your application is going to be but Ruby shoes seems to be able to distribute simple applications as exes.

Steve Weet
+1  A: 

You can create exe's from regular python using Py2Exe. But there shouldn't be anything preventing you from creating exes with IronPython using Visual Studio or SharpDevelop

DoxaLogos
+3  A: 

An IronPython or IronRuby project can be compiled to a dll or executable just fine and will be 'real' executables in every way with the proviso that the person running them must have the relevant .Net framework and dependencies installed (dependencies may be present in the same directory by default instead but the framework must be installed). The integration with Visual Studio is still not there but projects like IronPythonStudio use the free VS Shell to good effect. The existence of the DLR as a dependency for c# dynamic in VS 2010 should mean that integration with VS from the Iron* groups becomes an easier goal and a higher priority.

The result is in no way interpreted (the CIL is jitted into machine code at runtime or via ngen if desired) and certain aspects of the DLR mean some actions are deferred in a similar fashion to latebinding but more powerfully and crucially with some sophisticated caching mechanisms to allow this to be relatively fast compared with naive interpreters.

Many traditionally interpreted scripting languages are creating their own VM based compilation strategies or leverage existing ones (like the JVM, the .Net CLR or open ones like the LLVM) since this leads to significant performance increases in many common cases.

In the case of the Iron* languages the benefit of the MS CLR as a basis is that the resulting executables 'Just Work' on the vast majority of installations of the most common OS family. Contrast to Java where a jar file is not 'runnable' by directly clicking / or 'executing' via the shell in many operating systems. The flipside from this is that this reduces interoperability compared to say a JVM or LLVM based solution where the platform support is broader but, inevitably, more diverse in OS integration.

ShuggyCoUk
Can you provide documentation or a procedure for this? It doesn't seem that you can "File->New Project" Python in Visual Studio, so some extra work is required.
JoshRivers
The VS integration is still not there (I will add a note to that effect) but you can use http://www.codeplex.com/IronPythonStudio to get a VS like environment (it uses the cut down VS Shell as its base)
ShuggyCoUk
What is the actual method of getting compiled DLR code into your executables? I've only been able to find the link in the answer below, and it only seems to refer to beta code.
JoshRivers
the IronPython.Hosting.Compiler is what you want to use. The shell integration project I linked to uses that to provide IronPythonTasks to compile to dll/exe/winexe and is likely usable from vanilla VS with some tweaks.The python code is always going to need to be in its own dll (you could merge the dlls after via ilmerge.exe if you want) and the compilation will be messy till the VS integration is there.
ShuggyCoUk