ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  VBScript or Perl?
Subject:   More considerations
Date:   2003-11-24 14:30:54
From:   brianiac
VBScript Strengths
[Formatting Functions]
FormatCurrency(), FormatDateTime(), FormatNumber(), and FormatPercent() not only make short work of tedious formatting tasks, but also use locale-specific formatting rules.
[Data Conversion]
CBool(), CByte(), CCur(), CDate(), CDbl(), CInt(), CLng(), CSng(), CStr(), CBool() all tend to overreact to unconvertable data, but are nicely complemented by VarType(), IsDate(), IsEmpty(), IsNull(), IsNumeric(), and IsObject(). Hex() and Oct() allow converting numbers to non-decimal strings. DateValue() and TimeValue() allow returning just the parsed date or time values, respectively.
[Date/Time Support]
Along with the usual functions for individual date fields, Day(), Hour(), Minute(), Month(), MonthName(), Second(), Timer(), Weekday(), WeekdayName(), Year(), and the more generic DatePart(), there are some more granular functions for current info: Now(), Date(), Time(). The DateSerial() and TimeSerial() functions allow for complex date arithmetic, as do DateAdd(), DateDiff(). Date literals are supported, using # as the delimiter: #datestring#.


VBScript Weaknesses
[Unforgivably Bad Array Support]
While standard functions like Filter(), Join(), and Split() are supplied; no sort, slice, splice, or concatenation functions exist. The stack and queue functions: push, pop, shift, and unshift are also missing.
[Clumsy Exception Handling]
Automatic exception handling has two modes: on (all errors and warnings are fatal), and off.
[Unreasonably Strong Typing]
Objects are not first-class objects; assignment, for example, is handled completely differently from built-in datatypes. This precludes, among other things, programs from passing functions as arguments. Adding to this difficulty, naught is expressed in many distinct (and confusing) terms: Nothing is an invalid object variable, Null adds the database-style complexity of three-valued logic (not true, not false), and Empty is the value in an uninitialized variable. Numeric values can be interpreted as booleans, as can some string values (but only if they are numeric or boolean strings).


JScript Strengths
[Strong Array Support]
A reasonable complement of expected array functions is supported: sort(), split(), join(), slice(), splice(), concat(), push(), pop(), shift(), unshift(), and reverse(). No grep/filter, search, or membership-test function exist.
[Native Associative Arrays (hashes)]
Actually, all JScript arrays are hashes: an array with numeric keys can have string keys added, and all keys can be iterated via the for...in loop. As Perl programmers already know, native hash support allows arbitrarily complex data structures to be built quite easily.
[Structured Exception Handling]
Using try...catch, errors can be handled much more readably, maintainably, and conveniently.


JScript Weaknesses
[NO Formatting Abilities]
All languages should have some kind of formatting ability: C's (and Perl's) printf, C++'s iomanip.h library, Python's % operator, etc. JScript does not. Doing something as simple as including exactly two digits after the decimal when converting a number to a string, or commafiying a number, is incredibly tedious.
[Limited Data Conversion Support]
Dates and non-decimal numbers are not always converted easily. No native currency type is supported.
[Date/Time Support]
No functions exist specifically for date/time arithmetic, and there is an inadequate granularity for parsing control. No date literal is supported.


1 to 3 of 3
  1. Function Pointers
    2004-05-11 20:14:46  tby@yehl.us [View]

  2. More considerations
    2003-12-31 02:08:28  anonymous2 [View]

    • More considerations
      2004-01-06 08:14:11  brianiac [View]

  3. More considerations
    2003-11-30 12:03:53  anonymous2 [View]

1 to 3 of 3