Fog Creek Software
Discussion Board

Scripting Languages?

I'm looking for an inexpensive scripting language to run on Win XP.  Windows XP Annoyances (a good book, BTW) mentions that XP has WSH or Windows Scripting Host that can be extended by third party products.

Here's some options that I know about.  I'm slightly familiar with each of the first three.  Let me of other suitable options.

Python (WxPython looks like a great way to build tools!)

Features I'd like
Regular expressions
database access (MySQL at minimum)
ability to call C/C++ libs (Java, COM, ActiveX too, if possible)

Features I'd like but don't think I'll get
ability to control other Windows programs*

*If I recall correctly, in Win 3.1/95/98, you could hook another app and feed it menu selections and so forth.  I believe that in NT/ME/XP, apps aren't sharing the same address space and can't hook each other.  Have I got that right?  It's been a few years since I've written a Windows program, let alone tried any tricks like this.

Bruce Perry
Tuesday, July 15, 2003

You might want to start off with:

I'm not sure about database access, mostly because I avoid dealing with them as much as possible, but everything else is covered, including scripting other apps, including gui only ones, on 2000,XP,2003.

This applies to wsh 5 and up of course.

Wednesday, July 16, 2003

You can use JScript (JavaScript) in WSH, in client-side browser code, as a scripting language for ASPs and also as a .NET development language (JScript.NET).

It also features Perl-style regular expressions.

Walter Rumsby
Wednesday, July 16, 2003

Tcl might be worth a look. It has regular expression support, and allows addition of extensions in C. There is an ODBC extension available for the Windows version, which might fill your needs for database access.

Wednesday, July 16, 2003

In both JScript and VBScript (the two scripting languages including with Windows as part of Windows Script Host) the languages themselves are quite limited. Almost all "real work" is done by instantiating COM objects and using those objects to accomplish your programming tasks. There is no mechanism to call directly into DLLs - one could argue if you want to do that, you should use a programming language not a scripting language.

Saying you want a scripting language that supports database connectivity might be a little misleading - JScript, on its face, does not have any mechanisms for doing that. However, the standard scriptable COM objects for accessing databases (ADODB, for instance) are accessible, so you're covered.

The language you pick will probably depend on what you are actually trying to do - if you have a large amount of raw text to parse or manipulate, Perl is probably the way to go. If you need to interact with Windows APIs like WMI or ADSI, VBScript or JScript are probably the easiest.

I do a lot of Windows scripting in my job, and I generally use JScript. However, the type of scripting I do (ADSI-type stuff) might be  vastly different than what you have in mind.

Mike Treit
Wednesday, July 16, 2003

JScript is a surpisingly powerful little language when you start looking under the hood; the prototype-based OO stuff is fairly neat, but take a brain warp to really appreciate.

Whatever language you end up choosing, make sure it does COM; that'll give you access to just about everything under Windows. JScript and VBScript both do. Perl and Python have access to COM. Python at least can also be used to create COM objects, I've never used much Perl so I don't know about that one.

To be honest, if you're using Perl or Python, using them in the WSH shell really doesn't buy you anything. Just use the existing interpreters. WSH itself doesn't do much more than host the language interprets anyway. Again, the real work is done via separate COM object.

Personally, I do my scripting in JScript when I don't have control over the client, and in Python when I can say "you must install this first." Works out pretty well.

TCL is an odd language - kind of a cross between LISP and Unix sh programming. I personally don't care for it because it has some rather odd limitations that really get in my way.

Chris Tavares
Wednesday, July 16, 2003

If you're on Windows, go with Windows technologies: VBScript (or maybe JScript) and MSDE (or maybe Access) for the DB.

Wednesday, July 16, 2003

I'd just like to say I find Python fairly useful. I'm not religious about it or anything, I just find it works well for me.

Neil Bloh
Wednesday, July 16, 2003

perl and python can do everything you need. database connectivity, regex, OLE, COM, GUIs, web, inline other languages.

Tom Vu 
Wednesday, July 16, 2003

Great responses!  Thanks for the information.

To clarify, I don't have a specific project in mind.  I'm just listing features that have either been useful to me in the past or are things I might need to do in the future.

I'm leaning toward Python at present, partly because of it's roots in Lisp and partly because WxPython looks like a good way to have utility apps with a Windows UI.

Bruce Perry
Wednesday, July 16, 2003

> Features I'd like but don't think I'll get: ability to control other Windows programs

Good responses above.  Let me just add that WSH comes with ActiveX objects which can manipulate the standard streams of console programs, and send keystrokes to Windows programs.  (Which is a weak kind of automation -- if only we had added automation support to the sticker list like Apple makes people support AppleScript...)

Note that I said "WSH comes with ActiveX objects" -- you don't need to use WSH to use these objects.  They're COM objects like any other. 


Eric Lippert
Wednesday, July 16, 2003

> If I recall correctly, in Win 3.1/95/98, you could hook
>another app and feed it menu selections and so forth.
> I believe that in NT/ME/XP, apps aren't sharing the same
> address space and can't hook each other.  Have I got
> that right? 

Not quite.  Even in Windows 95, programs did not share address space.  In all Win32 operating systems each process gets its own flat 32 bit address space.

But remember that Windows is based on _messaging_.  A menu selection is nothing more than a "menu select" message sitting in the menu's message queue.  Programs cannot party on each other's address spaces, but they certainly can send messages to each other!


Eric Lippert
Wednesday, July 16, 2003

Speaking of Python and wxPython, you might want to check out PythonCard, a combination of both that allows you to build GUI apps quickly and easily in the spirt of Apple's Hypercard (or MS's VB):

Herbert Sitz
Wednesday, July 16, 2003

Consider HTAs (HTML Applications) which are basically trusted web pages (they can instatiate COM objects) that run in their own window (without the IE gubbins). There was a topic about them last week.

I would go for JavaScript as a language, personally -- although there's a few quirks when dealing with some COM object types such as collections and Variant Arrays (for which there are the shims: Enumerator and VBArray respectively)

A good thing is that there is no runtime installation required for HTAs/JavaScript-- it's part of the OS (as long as you have IE4 (or 5?) or later installed on pre 98SE/2000 boxes).

Database access: you use ADO which again will likely be there already (otherwise install MDAC). You can talk to MySQL via the MySQL ODBC driver (which you'll need to deploy).

To control applications: many are controlllable via COM -- it's called "OLE Automation" -- you can do stuff like:
  var word = new ActiveXObject("Word.Application")
  word.Visible = true;
  word.Selection.Insert("hello world");
...but it does need to be supported for the app -- all the Office apps are OLE automatable, and any other vendors too.

Duncan Smart
Thursday, July 17, 2003

... can't call C++ libs though -- you'd have to write a COM or command-line shim.

Duncan Smart
Thursday, July 17, 2003

*  Recent Topics

*  Fog Creek Home