Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Scripted Responses


May04: The New Adventures of Verity Stob

When, last week, Verity Stob found herself writing code in one scripting language to generate an API in a second to be called from a third, she thought it was time somebody looked into this Tower of Babel.

Verity is the pseudonym of a programmer based in the UK. She can be contacted at [email protected].


Name: ActionScript.

What is it? A proprietary version of JavaScript (qv).

Natural habitat: Inside Macromedia Flash animations.

Distinguishing features: (I should say my remarks refer to Flash MX, not the more recent Flash MX 2004, as my employer won't lay out the dosh for the rather pricey upgrade.) It has the worst editor you have ever seen. Honestly. Until you engage "expert" mode, the thing is flatly unusable. The editor window disappears when its application loses focus, to stop you comparing it with external code. It's a gas.

That's the editor. What about the language? The prescribed method for inheriting is so horrible that it is widely ignored (it instantiates an unwanted object of the parent class, forces an extra call to the parent constructor, and e-mails your partner that you've been playing away from home). A scary handcrafted version involving assignment to Subclass.prototype.__constructor__ is used instead.

Anything else? Heaps! For example: You can hide little pieces of script all over an animation, easily making it quite impossibly hard for a third party to work out what is going on. It's a dog's dinner of a pig's ear.

You don't like it then. No, quite wrong. I love it.

Huh? It's just such fun, writing bits of code to manipulate the pretty colored shapes. Whee! Look how clever I am! This is much better than working. This is one of the intensely selfish pleasures of life, like playing Bebop jazz on the tenor sax. No wonder web sites have those dire Flash intros.

Name: JavaScript.

Alternative names: JScript, ECMAScript.

ECMAScript?!? It's the choice scripting language of skin disease specialists.

Ho ho. Does it have curly brackets? Yup.

Natural habitat: Embedded in HTML.

How will I recognize a web page that uses JavaScript? It will say "Done, with Errors" in the left corner of the status bar, next to the "e" icon.

You browser-ist hussy! I'll have you know I always use Opera...Keep your knickers on. I prefer Firefox myself, but remember we are the elite. I must pander to the brute masses here.

Oh, all right then. What is JavaScript used for? It is used to determine which browser is running.

So how come it fails to run in Internet Explorer? The source looks like this:

if (isIExplorer) {

// **** To do: IE handling

The writer is an elite nonIE user, like ourselves.

Sorry, are you implying there is only one, buggy version of this routine on the whole of the Web? No. There are possibly as many as four versions. Client-side JavaScript is all POS (Perforce Open Source). Not free as in speech, nor yet beer, but free as in there is no effective way to prevent people half-inching it.

Does all JavaScript code fail in this way? I find that the code that displays "pop under" advertisements can be relied upon.

Name: PHP.

Natural habitat: Back end of fancy web sites, the most likely "P" in a LAMP intranet application.

LAMP? Linux Apache MySQL PHP (or Perl or Python). The chic way to do little multiuser database apps. Where have you been?

What is it? It's in the C-on-weak-tea tradition of scripting languages. "Perl without tears" is how I think of it.

Lots of curly brackets then. Absolutely.

How come you know about it? It was recommended to me by a kind DDJ reader.

Poke some cheap fun at it. It uses the "." symbol as a string concatenation operator, so is obliged to use the arrow thing -> to access object fields. There are a lot of these arrows, as one is forced to write $this->field1 to get at fields, even within methods. This is a bit tedious, and I keep forgetting to do it.

That's not very satirical. Sorry. I feel very affectionate towards PHP. Somehow, everything is where I expect it to be. And—how often do you read this phrase?—it has excellent online documentation.

Unexpected genuine tip: If you do use PHP, you absolutely must get an accelerator. Four times speed up or better, I found. Google up "Turck MMCache" on SourceForge; others are available.

Name: Python.

Pronunciation: Pie-thahn in U.S. accent, Pie-thn in Brit accent.

Natural habitat: Cross-platform Internetish apps such as spam blockers, Paint Shop Pro, Zope.

Curly brackets? Nope. Uses indentation instead, like Modula-2. Good call. Instant improvement in the clutter:content ratio.

What's it like? Clean, modern, fully featured, elegant, extensible, scalable, object oriented. A version of VBScript from an antimatter universe.

You are keen, then. Probably the best design of those considered here.

Bonus point in its favor: I hear it breaks .NET's supposedly language-agnostic model because, among other things, it can generate class attributes on the fly and .NET really wants to nail down class structure at compile time. Or something like that.

So you use it? No. As a winding-down Delphi user, I have had my fill of "technically best." From now on, it's strictly "most popular" for me. Within reason.

Random fact: Guido van Rossum, the affable Dutch geezer who devised Python, wears his specs on a cord round his neck, just like my late Auntie Jolly. They make him look very unthreatening.

Name: VBScript.

Natural habitat: Server side on .asp web sites; backup-across-the-LAN scripts, viruses of a certain vintage.

Not to be confused with: The language of those horrible recorded and amended macros in huge, fragile spreadsheets that the Accounts Department proudly got out all by its little self. That's VBA, sweetness.

What is it? VBScript is like Visual Basic, but surpasses the fundamental beauty and elegance of the original.

Are you pulling my leg, Verity? No flies on you, tosh.

Standard code layout, the theory: You can indent it, just like any other block-structured language.

Standard code layout, the observed practice: Higgledy-piggledy or flat left.

Tell me, do they still write "DIM" to "dimension" variables? Even nonarrays? Bless! Of course they do, the little angels. But don't knock their arrays. They can make variant arrays of up to 60 dimensions. This will sate even virus writers who model superstring theories on their days off.

Variants? Do I catch a whiff of COMunism here? I am not at this time and have never been...

Weasel words to be on the alert for: "Of course, what she doesn't say is that it is a great teaching language. I learned everything I know using VB and VBScript."

Sample counter-weasel reply: "I should never have guessed."

DDJ


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.