Scripting Type Library Constant Injection Performance Characteristics, Part One

(Sorry about the title. I work for Microsoft; we like nouns.) Over a year ago now a reader noted in a comment to this posting that defining named constants using Const in VBScript or var in JScript is way, way faster than importing a type library. My empirical JScript testing showed that loading constants from…

1

Bad Recursion Revisited

We have internal email lists for questions about programming languages. Here’s one that came across recently that I thought illustrated a good point about language design. An interview candidate gave the following awful implementation of the factorial function. (Recall that factorial is notated “n!”, and is defined as the product of all the integers from…

22

How Do Script Engines Implement Object Identity?

I’ve talked a few times in this blog about the semantics of the equality operators in various languages. (Such as here, and here.) Recently a reader asked me how JScript implements object identity. That is, given two objects, how do we know if they are “the same object” or not? For the remainder of this…

7

Binary Files and the File System Object Do Not Mix

OK, back to scripting today. But before I get back to scripting issues, one brief correction. An attentive reader noted that “The Well-Tempered Clavier” was in fact designed to sound good on a “well tempered” instrument, not an “equally tempered” instrument. The difference is that a “well” temperament is designed so that every key sounds…

33

VBScript Quiz Answers, Parts Eleven and Twelve

11) X andY are both Booleans.  Which of the following always assignsTrue?  Why? (a) Z = Not X Or Y = X Imp Y(b) Z = X Imp Y = Not X Or Y(c) Z = X Eqv Y = Not X XOr Y(d) Z = Not X XOr Y = X Eqv Y  (a)…

7

VBScript Quiz Answers, Parts Nine and Ten

9) Which of these statements is syntactically legal?  Why? (a) Const Z = -+-+-+-10(b) Const Y = 2 + 2(c) Const X = .1e310(d) Dim W(+10) (a) is legal. The rest are illegal. (a) is legal because you can put as many unary positive or negative operators on top of a constant as you want,…

7

VBScript Quiz Answers, Part Eight

8) Which of these programs is syntactically legal? (a) Class Bar  Function Foo  End Function  Function Foo  End FunctionEnd Class (b) Class Bar  If Blah Then    Function Foo    End Function  Else    Function Foo    End Function  End IfEnd Class (c) If Blah Then  Function Foo  End FunctionElse  Function Foo  End FunctionEnd If (d) Select Case Blah …

7

VBScript Quiz Answers, Part Seven

Before I get into today’s entry, a brief editorial comment: Pestilence is a frickin’ pain in the rear. Famine was no problem at all, Rodney didn’t touch me once, and Master Kaen fell to my powerful fists, but two Amulets of Life Saving, one Wand of Death and four potions of full healing were insufficient to…

9

VBScript Quiz Answers, Part Six

This question was designed to highlight some of the oddities in VBScript’s rules for what makes a legal identifier. 6) Which of the following are syntactically legal?  Why? (a) Explicit Error(b) For[i=1]=[To[1]To[1](c) For i =.For To Step Step Step(d) For Each Each In In (d) is illegal, the rest are legal. (a) is legal because…

14

VBScript Quiz Answers, Part Five

5) Which of the following statements are guaranteed to never print False?  Assume that On Error Resume Next is in effect. (a) If x = x Then Print True Else Print False(b) If CStr(x) = CStr(x) Then Print True Else Print False(c) If True Or x Then Print True Else Print False(d) x = True…

1