10

I need a programming language to make tiny applications. As a C++ programmer, I think C++ is not practical for this purpose, because it takes too much effort to create a new application from scratch and to deploy it. However, I'd like to use a language equally powerful, so I was wondering whether C# can be used as a scripting language?

  • 4
    I agree with Thomas. How can you expect people to take the time to answer your questions if you won't accept them. I'll pass on this one. – Drew Noakes Sep 29 '09 at 10:19
  • Does that not kinda miss the point of SO though? – RobV Sep 29 '09 at 13:21
  • @RobV: I don't think so. I prefer the voting system over my own opinion to select the best answer. – Dimitri C. Sep 29 '09 at 13:43
19

Read this one

CS-Script - The C# Script Engine

CS-Script is a CLR (Common Language Runtime) based scripting system which uses ECMA-compliant C# as a programming language. CS-Script currently targets Microsoft implementation of CLR (.NET 2.0/3.0/3.5) with limited support on Mono.

CS-Script is an open-source initiative that is distributed under the license agreement, which can be found here. However commercial support is also available.

CS-Script combines the power and richness of C# and FCL with the flexibility of a scripting system. CS-Script can be useful for system and network administrators, developers and testers. For any one who needs an automation for solving variety of programming tasks.

and

Treating C# Like A Scripting Language

| improve this answer | |
  • good answer. Right on the nail! – Preet Sangha Sep 29 '09 at 10:33
5

You could try Python, which is both a very understandable and powerful language. It is possible to parse/execute Python from many languages.

For example: Use SWIG to use C++ code in Python or Boost to embed Python code in your C++ app.

| improve this answer | |
  • 2
    Agreed. If the OP wants the strength of the .NET framework, IronPython is readily available. – Marc Gravell Sep 29 '09 at 11:28
5

I would say that the usual benefits of a scripting language are:

  1. It normally has a command line interpreter
  2. You don't necessarily have to compile it
  3. It's easy to change the code - because the source file is the actual 'executable'

These are not features of C#, so a language that can do pretty much all that would be powershell, as it uses .net so it has access to all the features you might use in c#.


Edit: Just to resurrect this one from the dead...

Had a chat with a colleague, after thinking a bit about scripting languages that I have used like Ruby and Python.

One of the most important features for me in a scripting language is the ability to have code run directly in the script, without needing a main function. You don't do this in c#. However you do this in all the scripting languages that come to my mind:

eg, Ruby, Python, Javascript, Powershell

| improve this answer | |
  • 1
    Mono provide a repl for C# (see link in my answer) – mavnn Sep 29 '09 at 11:33
4

An other useful tool if you want to use C# for scripting is http://www.mono-project.com/CsharpRepl : a C# interactive prompt from the mono team.

I'd say that Mono in particular provides all of the tools to use C# as a very effective scripting language, and nearly anything you write in will run fine in .net if thats your main target environment.

| improve this answer | |

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