Microsoft Invented AJAX

Okay, I’m not really sure Microsoft invented AJAX, but I do know Internet Explorer had several asynchronous scriptable technologies and techniques long before any other browser.

To enumerate:

  • DSOs (ADC, TDC, RDS).  The TDC was pretty good, ADC was too heavy, and RDS was too much of a security issue, but they were all early ways to asynchronously data-bind elements at the browser.  They were also fully scriptable.
  • IFRAMEs – IE4/1997 or newer had IFRAMEs (Netscape 4 did have ILAYER, but Netscape 4 generally sucked).  I actually thought I invented this technique, and used it on many projects to much success.
  • Java – Meh, too bad about the JVM.  Same basic technique, though.
  • XMLHTTPRequest – Slightly more recent (circa IE5/1999 I think).  This object IS what modern AJAX code runs on.  Firefox, et al have only added similar objects in the last couple years.

“Remote Scripting” was Microsoft’s term for this technique.  (Heck, here’s an April 1999 MSDN article on the topic).

SO, I’m rather annoyed when well-known journalists say Microsoft is working “Not to be left out of any development trends…”, or better yet,
“Microsoft has decided [Ajax] is something it can’t ignore… the Redmondians have jumped on the Ajax bandwagon.”.

…Microsoft built that bandwagon.

Update: Perhaps I’m not the only one annoyed they’re not getting their due.
Scoble’s got a good laugh over AJAX, and Scott Isaacs has
thoughts on an AJAX (DHTML) framework.

Hack Lives!

Hack screenshot

So I played this game, half-a-lifetime-ago, called Hack. 
It was a ASCII-graphical game for DOS, where you explore a dungeon, seeking the Amulet of Yendor. 
You could play as a Wizard, Barbarian, or various other character types, and would of course fight monsters, gather treasures, and have various adventures along the way.

The user-interface was obviously very simple (even at the time), but the gameplay was amazingly rich. 
I loved it, and spent many days of my life “in the dungeon,” but eventually moved on to flashier graphical games.

So flash-forward 15 years to last week, I see this User Friendly comic mentioning “NetHack,” and then another random mention of the game got me curious and googling. 

NetHack screenshot

Lo and behold, Hack is still alive and kicking! (great history writeup here)  15 years of development (and enrichment) has added a simple GUI (mostly easier on the eyes) and richer (but completely faithful) gameplay.  I’m not at all disappointed. 

I am tempted to say I want some sort of multi-player version, tho.  Especially considering a favorite game of mine: BattleZone, an early 80s arcade classic, which Activision did an amazing (groundbreaking) job resurrecting in ~1998 as a multiplayer FPS.  I’m still playing it 7 years later.

But for now, it’s NetHack again.  It’s nice when old friends visit.

my Code: wipe_commentrange

*sigh*, more comment Spam today — 150 in a few minutes, despite my nice new .Text spam filters (they were all identical).

Unfortunately, I can’t just go into blog_content and delete the range (since the comment count wouldn’t be updated), and I didn’t want to click [Delete], [Yes], [Continue] 150 times, SO: I just fired-up SQL Profiler, reverse-engineered a standard delete call, and slapped together a utility Stored Procedure to loop that call, for big cleanup jobs.

It takes IDs for the first and last comment spam which make it through, and wipes them all out with .Text’s native blog_DeletePost stored proc.  Just paste this into Query Analyzer and run to install:

CREATE PROCEDURE re_wipe_commentrange 
@p_ID int,
@p_lastID int
AS

DECLARE @v_sql varchar(8000)
WHILE @p_ID <= @p_lastID
BEGIN
	SET @v_sql = 'exec blog_DeletePost @ID = ' + cast(@p_ID as varchar(5)) + ', @BlogID = 0'
	EXECUTE(@v_sql)
	SET @p_ID = @p_ID + 1
END
GO

(Note: this is for single user .Text blogs.  Multiple-user blogs will need fiddling with the embedded BlogID parameter.)

Then to use it, call like so in QA: EXEC re_wipe_commentrange 900, 1000.

Might save someone a few minutes (even with writing and posting it here, I think I'd still be clicking delete right now).

Time to consider a way to implement MT-Blacklist...

Javascript -vs- VBScript, pros and cons compared

Yes, this sounds like an all-too-familiar “Intro to Web Scripting” class or article, but I haven’t actually seen these more advanced scripting topics compared before, so I wanted to nail it down in print. 

feature Javascript VBScript
Object-Oriented: Very powerul and easy to create custom object classes Now supported with version 5+ CLASS construct, but is comparatively less powerful and syntax is much more verbose
Object-Based: More object-based, wraps core functionality in intrinsic objects like Date, Math, Number, String, and Array Less object-based, dumps functionality into global functions
Optional procedure arguments: Supported Not supported! (hence kludgy workarounds)
Getter/Setter properties: Not supported! (yet?) Supported
Dialog/User-input support: None built-in, depends on the current object model (e.g. window.alert/prompt/confirm, or WScript.Echo/popup). Has powerful native Msgbox and Inputbox functions.
Convenience tools (aka synactical sugar): Few (escape/unescape?) Plenty (Explicit Conversions, Formatting, Dates, Strings)
Date Manipulation: Difficult (hence the need for a Javascript Date library Easy (see convenience tools)
Leftovers/Quirks:
• Has ternary operator (e.g. var foo= true ? 'bar' : 'grep';
• No ternary operator and no IIF function like VB (but a custom IIF can be added).
General strength Powerful, more “nuts&bolts” Easy-to-learn, more common functionality built-in
General weakness Some common tasks are much too inconvenient Verbose, disorganized, weak OO capabilities
key:
good 
bad 
eh..

Yes, of course it’s my opinion, based on experience (and frustration!)  Feel free to proselytize me otherwise, but back it up!

My perspective is this: scripting languages are about convenience — quickly whipping out something that works, is readable, and is maintainable.  If you want perfect academic code, or fastest performance, get another tool!  For scripting languages, the less code and reference to accomplish a task, the better.

Interestingly, different scripting languages reach convenience by different routes.  For example, where VBScript chooses a “simple” route of a bunch of unorganized global functions, Javascript groups them as methods of intrinsic objects.  Normally I prefer simple, but Javascript’s better organization makes me more efficient: I don’t have to remember 90 or so distinct global functions — if I can simply remember the object (Date/Array/whatever), then I’m set, because VS.net’s Intellisense will help me quickly find the method I need without cracking a reference.

(Aside about Intellisense: it reminds me of the tabs -vs- spaces debate: I say tabs all the way.  Any decent code editor should be able to display tabs how you like.  Fewer characters to store/send, and less arrowing around pays for itself.  And yes, a coder should be using a decent code editor!)

To be clear, I favor neither VBScript or Javascript as a rule — each has its time and place (goal of this chart).  Ideally, I’d like to marry them for the best of both.  Both Classic ASP and WSCs can use both in the same context, which rocks.  Too bad ASP.net lost this feature, but it matters less since it now runs full-fledged programming languages.

Finally, for entertainment, here’s a hilarious thread on the “JS-vs-VBS” subject.  My favorite quote: “IF JScript was a movie, it’d be Citizen Kane, or The Shining. VBScript would be the Mariah Carey movie, or possibly ‘Sgt Pepper’s Lonely Hearts Club Band’ starring Peter Frampton and the Bee Gees.”

Update: added ternary/IIF note to chart ‘leftovers’.

My Code: InputLine function for WSH (Inputbox for CScript)

Now that I’m color-coded, I may start a regular feature here where I publish smallish code bits I’ve written…

For WSH scripters out there, here’s a handy one I wrote…

To explain, for GUI-type WSH scripts (usually run under the WScript engine), VBScript has a native Inputbox function, which prompts for user input via a dialog box.  Command-line-type scripts (running under CScript) have no command-line equivalent, though — yes Inputbox works, but a GUI dialog doesn’t really fit a command-line script.

So to fill that gap, I wrote this:

' Name:		InputLine
' Desc:		like Inputbox, but for use with cscript
' Author:	Rob Eberhardt, www.slingfive.com
' Params:	prompt as string, default value as string
' Returns:	user's answer
' History:
'		2005-06-13	added default param
'		2005-02-28	created original InputLine function
FUNCTION InputLine(p_strPrompt, p_strDefault)
	call Wscript.Echo(p_strPrompt & ":")
	IF p_strDefault<>"" THEN CreateObject("WScript.Shell").SendKeys(p_strDefault)
	DIM strInput
	Do While Not WScript.StdIn.AtEndOfLine
		strInput = strInput & WScript.StdIn.Read(1)
	Loop
	WScript.StdIn.skip(2)
	InputLine = strInput
END FUNCTION

Example usage:

DIM strChoice
strChoice = InputLine("Enter favorite color", "Red")
call WScript.Echo("You entered: " & strChoice)

…which would look like this from a command-line:

Enter favorite color:
Red
You entered: Red

For bonus points, you can detect if the current engine is CScript or WScript, and use InputLine or InputBox appropriately (like if you’re note sure what engine will run your code):

DIM strChoice

'detect CSCRIPT context & use InputLine
IF Instr(lcase(wscript.FullName), "cscript")>0 THEN	
	strChoice = InputLine("Enter favorite color", "Red")

ELSE	'detect WSCRIPT context & use native InputBox
	strChoice = InputBox("Enter favorite color", "Color?", "Red")

END IF

call WScript.Echo("You entered: " & strChoice)

Hope someone can use it.

Note: I would have absorbed this engine detection logic into a single smart InputLine-like function, if only Javascript supported Inputbox, or VBScript supported optional arguments.  But, InputBox’s optional 2nd “Caption” param makes no sense with InputLine, and unfortunately the languages leave no room to gracefully work around that.

The new Windows Update v6

Trying out the new Windows Update v6 (now called “Microsoft Update”).  Cool that they’ve finally integrated Office Update and other products (SQL Server for instance).


A few observations, though:


  • It took several ActiveX installs, plus closing and restarting IE for it to actually load fully.
  • Windows Update has been slooow for me lately (before this version even). Dunno why, but it still is. 
        Update: same slowness on sparkling fresh XPSP2 and SBS 2003 installs.  It ain’t me.
  • Still a ton of French Spell Checker updates?? (2 for Office, 1 for Visio, 1 for Project) I saw this a lot with Office Update too. I have no French anything on any machines, so what’s the deal?.


About time to reboot…

How do you decide?

My friend Mike Butler posted a thought-provoker about blog self-censorship and choosing topics.

I’ve struggled with that dilemma too.

One one hand, I want my family, friends, and strangers to be able to read my blog without being offended or bored.  On the other, I need to express myself freely.  I realized early with this blogging venture that I have a habit of putting on personas for each situation.  That bugged me since it seemed disingenuous, and it was making me second guess myself.  I think I settled on making my blog just For Me (at least as far as topics) — including the tech-geek, the father, the immature Jr. High dork, the business man, the music-fan, the navel-gazing philosopher, etc.

If a subject bores or bothers someone in real life, they have to grit their teeth.  Here at least they can ignore me without worrying about my feelings :>

I think my goal is no longer about avoiding boring/scaring people away, but rather trying to attract people by giving each of my facets a balanced representation.  For example, Me-the-father hasn’t really posted yet (mostly due to the sheer magnitude of the thoughts I want to distill into a post), so there’s a whole audience I’ve missed so far. 

Good food for thought.  Thanks Mike.