tags:

views:

520

answers:

10

We have a number of electronic test technicians with next to no programming experience. I would like a scripting language that is easy to learn with simple forgiving syntax that can integrate with .NET and invoke exposed static or singleton instance methods easily. What scripting language can meet these requirements?

Note: Perl is eliminated, C# script would be nice but the syntax is a bit unforgiving.

Edit: I'd like to be able to do something like this.

Instrument("MultiMeter1").Measure
if (LastMeasurement.IsInRange(50,100))
{
   Test.Pass = true;
}
+3  A: 

Take a look at IronPython

There is also IronRuby. I haven't seen references for embedding it, but I haven't looked.

Dennis Palmer
I've been taking a look at it and I'm only slightly impressed, not a huge fan of Python, but honestly it's also a little unforgiving, but it's not too bad.
Firoso
+3  A: 

Why not PowerShell?

John Saunders
+1  A: 

PowerShell might be a good option.

guillermooo
+1  A: 

I'd recommend looking at the Dynamic Language Runtime project. There are many languages already that run on this, including IronPython and IronRuby.

These all integrate very well with .NET (that's the point).

Reed Copsey
I think only IronPython and IronRuby are stable, though. Prety sure the Managed JScript is on hold. I think there's an IronScheme. Are there others? I think IronPython would be the best choice for engineers who haven't done programming.
Nosredna
+7  A: 

The short list includes

  • PowerShell
  • IronRuby
  • IronPython
  • Boo

PowerShell has a number of things going for it, not the least being that it will be installed on all Win2008 and Win7 installations.

The syntax isn't totally forgiving, but PowerShell will do what it can to convert types as required, in addition it has a powerfull dynamic type system that helps make sense of XML, COM, AD, and WMI types.

Here's just a few lines on type conversion

> $five = "5"
> $five + 5
55
> [int]$five + 5
10
> [datetime] "Nov 12"
Thursday, November 12, 2009 12:00:00 AM

Edit: to address your situation, you might create a cmdlet (or module in v2) which wrapped your .net classes and then do something like

$meter = Get-Measurement MultiMeter1
if ($meter.IsInRange(50,100))
{   
   Set-TestResult $meter $true
}
Scott Weinstein
why powershell, I can't find much on scripting with it.
Firoso
On the topic of boo, which I'm liking what i'm seeing, can I say, write a script hosting application in C# and then expose methods to be called from boo scripts on C# object instances? Where can I find literature on this?
Firoso
There are a number of podcasts and good books on PowerShell. Can't find the one I saw the first time, but I got the impression that it was crazy powerful...It's everything that batch files weren't.
Robert Harvey
A: 

I cringe to say it, but what about VBScript? You can create / invoke CLR objects registered for COM from it. The COM requirement is a bit of a PITA, but easy to accomplish, and vb is known as a... forgiving language, among other things!

with apologies to fans of VB

Josh E
"Simple" and "Integrates with .NET easily" are two things VBScript doesn't have. And how much sense does it make to live in the past?
John Saunders
living in the past isn't the answer, but kev's answer below addresses a lot of the concerns.
Josh E
+1  A: 

VBScript is not the answer, however with .NET it's not very difficult to invoke new .NET code in a sandbox, even with access to provided objects as most of the suggests already are using it, just to run languages like Python.

So, why not just plug VB*.NET* in there. As a developer VB isn't a great language, but if you want a "simple" language, a BASIC variant would seem to fit the bill. If it didn't turn out the way you wanted, .NET means you have the flexiblity to just substitute any of the above languages so long as the CLR compiler is included.

David
+2  A: 

Dr Dobbs has an article about embedding VB.NET in your application:

Add VB.NET Scripting to .NET Apps (Dr Dobbs Journal)

That said, I think the choosing one of the DLR languages is probably the way forward.

Kev
+1  A: 

F# (aka F-Sharp, now part of VS2010) has a lot of features you may find worth looking at. Taking a quote from the F# At Microsoft Research page:

F# developed as a research programming language to provide the much sought-after combination of type safety, succinctness, performance, expresivity and scripting, with all the advantages of running on a high-quality, well-supported modern runtime system. This combination has been so successful that the language is now being transitioned towards a fully supported language on the .NET platform. Some of the reasons for this move are that F# gives you:

  • succinct, type-inferred functional programming,
  • interactive scripting like Python and other languages,
  • the foundations for an interactive data visualization environment,
  • the combination of type inference and safety, like that of ML,
  • a cross-compiling core shared with the popular OCaml language,
  • a performance profile like that of C#,
  • easy access to the entire range of powerful .NET libraries and database tools,
  • a foundational simplicity with similar roots to Scheme,
  • the option of a top-rate Visual Studio integration, which is usable with the freely available Visual Studio 2008 Shell
  • the experience of a first-class team of language researchers with a track record of delivering high-quality implementations,
  • the speed of native code execution on the concurrent, portable, and distributed .NET Framework.

The only language to provide a combination like this is F# (pronounced FSharp) - a scripted/functional/imperative/object-oriented programming language that is a fantastic basis for many practical programming tasks.

Some of the things you may find interesting include:

  • It can infer types, which means you need to specify type information very infrequently so it looks like script, but the resulting code ends up typesafe and fast.
  • It automatically detects when it can generate "generic" code to operate over multiple datatypes.
  • It does not require everything to be in a class - stand alone functions are well supported.
  • It has both a command-line REPL and integration with Dev Studio which allows selecting snippets of code and executing them in a hosted REPL.
  • Many concepts can be expressed very succently, due in part to higher-order functions like filter, map, and reduce for lists and sequences.
  • VSLab, an interactive graphing plug-in for VS2008 (with VS2010 soon), similar to MATLAB and Mathematica.

Once you get over the "it's not C" syntax, you can write code pretty darn quickly and with typically fewer bugs (less code + type inference + higher order functions = fewer bugs).

The syntax is not as forgiving as, say, JavaScript (in fact, sometimes it can be frustrating, as can any language). But, for most simple things its rather straight forward.

let a = 1                    // bind 1 to identifier a
let b = a + 1                // bind function which adds 1 and a to b
let s = "Simple add"         // bind string to identifier s
printf "%s: %i %i" s a (b 1)

It has higher-order functions, pipelining, and lambdas, which means data transformations on sequences are a breeze:

[ 1; 2; 3; 4; 5; 6 ]
|> List.map (fun a -> a + 1)            // add +1 to every item in the list
|> List.reduce_left (fun a b -> a * b)  // Multiply all the elements together

Or, when you get good, write it even more succently:

[ 1; 2; 3; 4; 5; 6 ]
|> List.map ((+) 1)
|> List.reduce_left (*)
James Hugard
A: 

Don't forget JScript.NET .

steamer25