Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I already have a working implementation that adds scripting to an application. The application currently generates and compiles scripts from C# snippets (taken from different user provides configuration files) into assemblies using the CodeDOM. As it sounded like a good idea at first I ran into following issues:

  1. difficult AppDomain handling and need for Serialization
  2. performance issue => frequent script changes trigger a recompilation
  3. changes cannot be made in-place in the scripts while running
  4. difficult to provide a GUI for debugging (breakpoints), the script writer actually needs a debugger...

I "hacked" a solution against 1 by loading everything in the main AppDomain. The problem is that nothing can be unloaded... After some time the memory use is huge.

For this reason I eventually would consider to switch to an interpreted solution but want to remain near to a C# language because of the existing code-base. There is a bunch of libs around Vsa, S#, Script.NET, ... I need to access objects in my application from the scripts and also run methods in the scripts from my application. Do you also think that switching to an interpreted language the right strategy or should I try to add a debug mode to the existing concept by injecting code like calling a method between each line of the script to allow a step by step execution.... However the AppDomain handling remains a nightmare to handle.

It is certainly not the first time someone runs in such a situation. I could not find any FOSS wrapper/helper library to make the CodeDOM handling easier nor GUI elements to provide building blocks for a minimal debugger. Currently I built ma own GUI and step over calls in the scripts and show changes in the application objects (before/after calls) inside the GUI.

Please only refer to FOSS source/libs.

share|improve this question

migrated from stackoverflow.com Mar 2 '12 at 17:28

This question came from our site for professional and enthusiast programmers.

    
Dupe of Roslyn? –  Austin Salonen Mar 2 '12 at 16:29
2  
Is there a reason you don't just use PowerShell? If your platform is Windows I would highly recommend it. –  Joshua Honig Mar 2 '12 at 16:33
    
Why only FOSS libs? Or do you just mean free libs? –  svick Mar 2 '12 at 16:41
2  
Have you considered Javascript? see here stackoverflow.com/questions/4744105/… –  Simon Mourier Mar 2 '12 at 17:41
3  
If not your desire to stat with C# or something close I'd suggest IronRuby or IronPython –  Christian Horsdal Mar 3 '12 at 6:51

2 Answers 2

There are a few interpreted options that are more dynamic but close relatives of .NET. I think I would let my audience drive the choice.

  • For sys-admins I would try and expose powershell commandlets and let them use that. They should be comfortable over there, and it is a very powerful and .NET friendly tool. Credit to @jmh_gr for suggesting this in the comments.

  • For developers I would look at a dynamic CLR implementation of a well-known language. IronPython comes to mind. F# also has an interactive scripting mode that you might be able to use if you want to stick to more official-like languages.

  • For non-developers I would think about using something like Boo to create my own DSL so I could make the verbage make sense.

Finally, none of these strategies are mutually exclusive. In some ways, they build on one another as they require many of the same facilities to be successful.

share|improve this answer

You can reuse the machinery in Mono's C# Shell. It does what you've being doing with some improvements, like using a library containing a C# compiler, instead of running the command line one...

http://www.mono-project.com/CsharpRepl

Adding automatic imports and referenced assemblies is quite easy, to make them available for your users.

It is dual licensed under the terms of the MIT X11 or GNU GPL

Code at https://github.com/mono/mono/tree/master/mcs/tools/csharp

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.