This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. (March 2008) |
Paradigm | Procedural |
---|---|
Designed by | Neil Pappalardo |
First appeared | 1966 |
Stable release | ANSI X11.1-1995
/ December 8, 1995 |
Typing discipline | dynamic |
OS | Cross-platform |
Influenced by | |
JOSS | |
Influenced | |
PSL, Caché ObjectScript |
MUMPS (Massachusetts General Hospital Utility Multi-Programming System), or alternatively M, is a programming language created in the late 1960s, originally for use in the healthcare industry. It was designed to make writing database-driven applications easy while simultaneously making efficient use of computing resources. It was adopted as the language-of-choice for many healthcare and financial information systems/databases (especially ones developed in the 1970s and early 1980s) and continues to be used by many of the same clients today. It is currently used by the world's largest electronic health record systems as well as by multiple banking networks and online trading/investment services.
Because it predates C and most other popular languages in current usage, it has very different syntax and terminology. It offers a number of features unavailable in other languages, including some rarely used programming and database concepts. Variations of MUMPS are available which have extended the language to include object orientation and even use of SQL statements.
History
editMUMPS was developed by Neil Pappalardo and colleagues in Dr Octo Barnett's animal lab at Massachusetts General Hospital (MGH) in Boston during 1966 and 1967. The original MUMPS system was, like Unix a few years later, built on a spare DEC PDP-7.
Octo Barnett and Neil Pappalardo were also involved with MGH's planning for a Hospital Information System, obtained a reverse-compatible PDP-9, and began using MUMPS in the admissions cycle and laboratory test reporting. MUMPS was then an interpreted language and incorporated a hierarchical database file system to standardize interaction with the data. Some aspects of MUMPS can be traced from Rand Corporation's JOSS through BBN's TELCOMP and STRINGCOMP. The MUMPS team deliberately chose to include portability between machines as a design goal. Another feature, not widely supported for machines of the era, in operating systems or in hardware, was multitasking, which was also built into the language itself.
The portability was soon useful as MUMPS was shortly adapted to a DEC PDP-15 where it lived for some time. MUMPS was developed with the support of a government research grant, and so MUMPS was released to the public domain (no longer a requirement for grants), and was soon ported to a number of other systems including the popular DEC PDP-8, the Data General Nova and the DEC PDP-11. Word about MUMPS spread mostly through the medical community, and by the early 1970s was in widespread use, often being locally modified for their own needs.
By the early 1970s, there were many and varied implementations of MUMPS on a range of hardware platforms. The most widespread was DEC's MUMPS-11 on the PDP-11, and Meditech's MIIS. In 1972, many MUMPS users attended a conference which standardized the now fractured language, and created the MUMPS Users Group and MUMPS Development Committee (MDC) to do so. These efforts proved successful; a standard was complete by 1974, and was approved, on September 15, 1977, as ANSI standard, X11.1-1977. At about the same time DEC launched DSM-11 (Digital Standard MUMPS) for the PDP-11. This quickly dominated the market, and became the reference implementation of the time.
During the early 1980s several vendors brought MUMPS-based platforms that met the ANSI standard to market. The most significant were Digital Equipment Corporation with DSM (Digital Standard MUMPS), and InterSystems with their ISM (InterSystems M) on VMS and UNIX, and M/11+ on the PDP-11 platform. Other companies who developed important MUMPS implementations were:
- Greystone Technology Corporation with a compiled version called GT.M,
- DataTree Inc. with an Intel PC based product called DTM,
- Micronetics Design Corporation with a product line called MSM for UNIX and Intel PC platforms (later ported to IBM's VM operating system), and
- M-Global with MGM, a Mac OS based product.
M-Global MUMPS was the first commercial MUMPS for the PC and the only Mac implementation. DSM-11 was superseded by VAX/DSM for the VAX/VMS platform, and that was ported to the Alpha in two variants: DSM for OpenVMS, and as DSM for Ultrix.
This period also saw considerable MDC activity. The second revision of the ANSI standard for MUMPS (X11.1-1984) was approved on November 15, 1984. On November 11, 1990 the third revision of the ANSI standard (X11.1-1990) was approved. In 1992 the same standard was also adopted as ISO standard 11756-1992. Use of M as an alternative name for the language was approved around the same time. On December 8, 1995 the fourth revision of the standard (X11.1-1995) was approved by ANSI, and by ISO in 1999 as ISO 11756-1999. The MDC finalized a further revision to the standard in 1998 but this has not been presented to ANSI for approval. On 6 January 2005, ISO re-affirmed its MUMPS-related standards: ISO/IEC 11756:1999, language standard, ISO/IEC 15851:1999, Open MUMPS Interconnect and ISO/IEC 15852:1999, MUMPS Windowing Application Programmers Interface.
By 2000, the middleware vendor InterSystems had become the dominant player in the MUMPS market with the purchase of several other vendors. Initially they acquired DataTree Inc. in the early 1990s. And, on December 30, 1995, Intersystems acquired the DSM product line from DEC.[1] InterSystems consolidated these products into a single product line, branding them, on several hardware platforms, as OpenM. In 1997, InterSystems essentially completed this consolidation by launching a unified successor named Caché. This was based on their ISM product, but with influences from the other implementations. Micronetics Design Corporation assets were also acquired by InterSystems on June 21, 1998. Intersystems remains today (2007) the dominant MUMPS vendor, selling Caché to MUMPS developers who write applications for a variety of operating systems.
Greystone Technology Corporation's GT.M implementation was sold to Sanchez Computer Associates Inc. (now part of Fidelity National Financial Inc.) in the mid 1990s. On November 7, 2000 Sanchez made GT.M for Linux available under the GPL license[2] and on October 28, 2005 GT.M for OpenVMS and Tru64 UNIX were also made available under the GPL license. GT.M continues to be available on other UNIX platforms under a traditional license.
The newest implementation of MUMPS, released in April 2002, is an MSM derivative called M21 from the Real Software Company of Rugby, UK.
There are also several open source implementations of MUMPS, including some research projects. The most notable of these is Professor Kevin O'Kane's (and students') project, now at the University of Northern Iowa.
One of the original creators of the MUMPS language, Neil Pappalardo, early founded a company called Meditech. They extended and built on the MUMPS language, naming the new language MIIS (and later, MAGIC). Unlike Intersystems, Meditech no longer sells middleware, so MIIS and MAGIC are only used internally at Meditech.
Current users of MUMPS applications
editThe US Veteran's Administration was one of the earliest major adopters of the MUMPS language. Their development work (and subsequent contributions to the free MUMPS application codebase) was an influence on many medical users worldwide. In 1995, the Veterans Administration's patient Admission/Tracking/Discharge system, Decentralized Hospital Computer Program (DHCP) was the recipient of the Computerworld Smithsonian Award for best use of Information Technology in Medicine. A decade later (July, 2006), the Department of Veterans Affairs (VA) / Veterans Health Administration (VHA) was the recipient of the Innovations in American Government Award presented by the Ash Institute of the John F. Kennedy School of Government at Harvard University for its extension of DHCP into VistA in July, 2006. Nearly the entire VA hospital system in the United States and the Indian Health Service, as well as major parts of the Department of Defense CHCS hospital system all run systems using MUMPS databases for clinical data tracking.
Large companies currently using MUMPS include AmeriPath (now part of Quest Diagnostics), Care Centric, Team Health, Epic Systems Corporation, EMIS, Partners HealthCare, Meditech, and GE Healthcare (formerly IDX Systems and Centricity). Many reference laboratories, such as Quest Diagnostics and Dynacare, use MUMPS software written or based on by Antrim Corporation code. Antrim, and its parent Sunquest, was acquired by Misys in 2001.[3]
Coventry Healthcare and Massachusetts Hospital have also been reported to use MUMPS.
MUMPS is also widely used in financial applications. MUMPS gained an early following in the financial sector, and MUMPS applications are in use at many banks and credit unions. It is used by Ameritrade, the largest online trading service in the US with over 12 billion transactions per day, as well as by the Bank of England and Barclays Bank, among others.[4]
As of 2005 most use of M is either in the form of GT.M or InterSystems Caché. The latter is being aggressively marketed by InterSystems and has had success in penetrating new markets, such as telecommunications, in addition to existing markets.
Overview
editMUMPS is a language intended for and designed to build database applications. Secondary language features were included to help programmers make applications using minimal computing resources. The original implementations were interpreted, though modern implementations may be fully or partially compiled.
The most outstanding, and unusual, design feature of MUMPS is that database interaction is transparently built into the language. The MUMPS language assumes the presence of a MUMPS hierarchical database, which is implicitly "opened" for every application. All variable names prefixed with the caret character ("^") use permanent (instead of RAM) storage, will maintain their values after the application ends, and will be visible to (and modifiable by) other running applications. Variables using permanent storage are called Globals in MUMPS, though this is not meant in the usual sense of unscoped variables.
Additionally, all variables (both RAM and disk-based) are hierarchical. They can all have child nodes (called subscripts in MUMPS terminology). Thus, the variable 'Car' can have subscripts "Door", "Steering Wheel" and "Engine", each of which can contain a value and have subscripts of their own. Thus, you could say
SET ^Car("Door","Color")="BLUE"
to modify a nested child node of ^Car. In MUMPS terminology, "Color" is the 2nd subscript of the variable ^Car (both the names of the child-nodes and the child-nodes themselves are called subscripts). Hierarchical variables are similar to objects with properties in Object Oriented languages. Additionally, all subscripts of variables are automatically kept in sorted order. Numeric subscripts (including floating-point numbers) are stored from lowest to highest. All non-numeric subscripts are stored in alphabetical order following the numbers. In MUMPS terminology, this is canonical order. By using only non-negative integer subscripts, the MUMPS programmer can emulate the Arrays data type from other languages. Although MUMPS does not natively offer a full set of DBMS features, several DBMS systems have been built on top of it that provide application developers with flat-file, relational and network database features.
As a secondary language feature, you can abbreviate nearly all commands and native functions to a single character to save space; this was a common feature of languages designed in this period (eg, early BASICs). Additionally, there are built-in operators which treat a delimited string (eg, comma-separated values) as an array. Early MUMPS programmers would often store a structure of related information as a delimited string, parsing it after it was read in; this saved disk access time and offered considerable speed advantages on some hardware.
MUMPS has no data types. Numbers can be treated as strings of digits, or strings can be treated as numbers by numeric operators (coerced, in MUMPS terminology). Coercion can have some odd side effects, however. For example, when a string is coerced, the parser turns as much of the string (starting from the left) into a number as it can, then discards the rest (Also known as Weak typing). Thus the statement IF 20<"30 DUCKS"
is evaluated as TRUE
in MUMPS.
Other features of the language are intended to help MUMPS applications interact with each other in a multi-user environment. Database locks, process identifiers, and atomicity of database update transactions are all required of standard MUMPS implementations.
In contrast to languages in the C or Wirth traditions, some space characters between MUMPS statements are significant. A single space separates a command from its argument, and a space, or newline, separates each argument from the next MUMPS token. Commands which take no arguments (eg, ELSE
) require two following spaces. The concept is that one space separates the command from the (nonexistent) argument, the next separates the "argument" from the next command. Newlines are also significant; an IF
, ELSE
or FOR
command processes (or skips) everything else til the end-of-line. To make those statements control multiple lines, you must use the DO
command to create a code block.
"Hello, World!" in MUMPS
editA simple Hello world program in MUMPS might be:
hello()
write "Hello, World!",!
quit
and would be run from the MUMPS command line with the command 'do ^hello()
'. Since MUMPS allows commands to be strung together on the same line, and since commands can be abbreviated to a single letter, this routine could be even more compact:
hello() w "Hello, World!",! q
The ',!
' after the text generates a newline. The 'quit
' is not strictly necessary at the end of a function like this, but is good programming practice in case other functions are added below 'hello()
' later.
Summary of key language features
editThe following summary seeks to give programmers familiar with other languages a feeling for what MUMPS is like. This is not a formal language specification, and many features and qualifiers have been omitted for brevity. ANSI X11.1-1995 gives a complete, formal description of the language; an annotated version of this standard is available online.[5]
Data types: There is one universal datatype, automatically interpreted/converted to string, integer, or floating-point number as context requires.
Booleans: In IF statements and other conditional statements, any numeric, nonzero value is treated as True. a<b
yields 1 if a is less than b, 0 otherwise.
Declarations: None. All variables are dynamically created on first reference.
Lines: are important syntactic entities, unlike their status in languages patterned on C or Pascal. Multiple statements per line are allowed and are common. The scope of IF and FOR is "the remainder of current line."
Case sensitivity: Commands and intrinsic functions are case-insensitive. In contrast, variable names and labels are case-sensitive. There is no special meaning for upper vs. lower-case and few widely followed conventions. The percent sign (%) is legal as first character of variables and labels.
Postconditionals: SET:N<10 A="FOO"
sets A to "FOO" if N is less than 10; DO:N>100 PRINTERR,
performs PRINTERR if N is greater than 100. This construct provides a conditional whose scope is less than a full line.
Abbreviation: You can abbreviate nearly all commands and native functions to one or two characters.
Reserved words: None. Since MUMPS interprets source code by context, there is no need for reserved words. You may use the names of language commands as variables. There has been no obfuscated MUMPS contest as in C, despite the potential of examples such as the following, perfectly legal, MUMPS code:
GREPTHIS()
NEW SET,NEW,THEN,IF,KILL,QUIT SET IF="KILL",SET="11",KILL="l1",QUIT="RETURN",THEN="KILL"
IF IF=THEN DO THEN
QUIT:$QUIT QUIT QUIT ; (quit)
THEN IF IF,SET&KILL SET SET=SET+KILL QUIT
Arrays: are created dynamically, stored as B-trees, use almost no space for missing nodes, can use any number of subscripts, and subscripts can be strings or numeric (including floating point). Arrays are always automatically stored in sorted order, so there is never any occasion to sort, pack, reorder, or otherwise reorganize the database. $ORDER, $ZPREVIOUS, and $QUERY functions provide efficient traversal of the fundamental array structure, on disk or in memory.
for i=10000:1:12345 set sqtable(i)=i*i
set address("Smith","Daniel")="dpbsmith@world.std.com"
Local arrays: variable names not beginning with caret are stored in memory by process, are private to the creating process, expire when the creating process terminates. The available storage depends on partition size, but is typically small (32K). Efficient memory allocation means that this was little practical impediment in former, memory starved, times and is still less an issue today.
Global arrays: ^abc, ^def
. These are stored on disk, are available to all processes, and are persistent when the creating process terminates. Very large globals (eg, hundreds of megabytes) are practical and efficient in most implementations. This is MUMPS' main "database" mechanism. It is used instead of calling on the operating system to create, write, and read files.
Indirection: in many contexts, @VBL
can be used, and effectively substitutes the contents of VBL into another MUMPS statement. SET XYZ="ABC" SET @XYZ=123
sets the variable ABC to 123. SET SUBROU="REPORT" DO @SUBROU
performs the subroutine named REPORT. This is effectively the operational equivalent of "pointers" in other languages.
Piece function: This breaks variables into pieces guided by a user specified separator character. Those who know awk will find this familiar. $PIECE(STRINGVAR,"^",3)
means the "third caret-separated piece of STRINGVAR." It can appear as an assignment target. After
SET X="dpbsmith@world.std.com"
$PIECE("world.std.com",".",2)
yields "std" SET $P(X,"@",1)="office"
causes X to become "office@world.std.com" (note that $P is equivalent to $PIECE and could be written as such).
Order function
Set stuff(6)="xyz",stuff(10)=26,stuff(15)=""
$Order(stuff(""))
yields 6, $Order(stuff(6))
yields 10, $Order(stuff(8))
yields 10, $Order(stuff(10))
yields 15, $Order(stuff(15))
yields "".
Set i="" For Set i=$O(stuff(i)) Quit:i="" Write !,i,10,stuff(i)
Here, the argument-less For repeats until stopped by a terminating Quit. This line prints a table of i and stuff(i) where i is successively 6, 10, and 15.
Multi-User/Multi-Tasking/Multi-Processor: MUMPS supports multiple simultaneous users and processes even when the underlying operating system does not (Eg. MS-DOS). Additionally, by specifying a machine name in a variable (as in SET ^|"DENVER"|A(1000)="Foo"
), you can access data on remote machines.
For a thorough listing of the rest of the MUMPS commands, operators, functions and special variables, see these online resources:
- MUMPS by Example, or the (out of print) book of the same name by Ed de Moel. Much of the language syntax is detailed there, with examples of usage.
- The Annotated MUMPS Language Standard, showing the evolution of the language and differences between versions of the ANSI standard.
"MUMPS" vs. "M"
editWhile of little interest to those outside the MUMPS/M community, this topic has been contentious there.
All of the following positions can, and have been, supported by knowledgeable people at various times:
- The language's name became M in 1993 when the M Technology Association adopted it.
- The name became M on December 8 1995 with the approval of ANSI X11.1-1995
- Both M and MUMPS are officially accepted names.
- M is only an "alternate name" or "nickname" for the language, and MUMPS is still the official name.
Some of the contention arose in response to strong M advocacy on the part of one commercial interest, InterSystems, whose chief executive disliked the name MUMPS and felt that it represented a serious marketing obstacle. Thus, favoring M to some extent became identified as alignment with InterSystems. The dispute also reflected rivalry between organizations (the M Technology Association, the MUMPS Development Committee, the ANSI and ISO Standards Committees) as to who determines the "official" name of the language. Some writers have attempted to defuse the issue by referring to the language as M[UMPS], square brackets being the customary notation for optional syntax elements.
The most recent standard (ISO/IEC 11756:1999, re-affirmed on 6 January 2005), still mentions both M and MUMPS as officially accepted names.
Recently Microsoft announced development plans for a new XML-based programming language M. [6] This marks the second name similarity of a recent Microsoft product with an established computing technology of Department of Veterans Affairs (the other being VistA).
The MUMPS epoch
editIn MUMPS, the current date and time is contained in a special system variable, $H (short for "HOROLOG"). The format is a pair of integers separated by a comma, e.g. "54321,12345" The first number is the number of days since December 31, 1840, i.e. day number 1 is January 1, 1841; the second is the number of seconds since midnight.
The reason for this not very obvious choice of epoch is a bit of MUMPS trivia. James M. Poitras has written that he chose this epoch for the date and time routines in a package developed by his group at MGH in 1969:
“ | I remembered reading of the oldest (one of the oldest?) U.S. citizen, a Civil War veteran, who was 121 years old at the time. Since I wanted to be able to represent dates in a Julian-type form so that age could be easily calculated and to be able to represent any birth date in the numeric range selected, I decided that a starting date in the early 1840s would be 'safe.' Since my algorithm worked most logically when every fourth year was a leap year, the first year was taken as 1841. The zero point was then December 31, 1840.... I wasn't party to the MDC negotiations, but I did explain the logic of my choice to members of the Committee. | ” |
(More colorful versions have circulated in the folklore, suggesting, for example, that December 31 1840 was the exact date of the first entry in the MGH records, but these seem to be urban legends.)
A piece of MUMPS trivia: $HOROLOG hit 60000 on April 10, 2005; will be 70000 on August 26, 2032; 80000 on January 12, 2060; 90000 on May 30, 2087; and 100000 on October 16, 2114.
Sample programs
editAn example of "traditional" M coding style, from the Fileman system written for the US Government Veterans' Administration. This fragment uses statement abbreviations and cryptic routine and variable names, extensively. In an era in which disks were small, memory smaller, and I/O often limited to 300 baud, this made some sense. Modern MUMPS code typically uses helpful variable names and would avoid statement abbreviations if possible. There is still a line length limit in most MUMPS implementations, however.
%DTC
%DTC ; SF/XAK - DATE/TIME OPERATIONS ;1/16/92 11:36 AM
;;19.0;VA FileMan;;Jul 14, 1992
D I 'X1!'X2 S X="" Q
S X=X1 D H S X1=%H,X=X2,X2=%Y+1 D H S X=X1-%H,%Y=%Y+1&X2
K %H,X1,X2 Q
;
C S X=X1 Q:'X D H S %H=%H+X2 D YMD S:$P(X1,".",2) X=X_"."_$P(X1,".",2) K X1,X2 Q
S S %=%#60/100+(%#3600\60)/100+(%\3600)/100 Q
;
H I X<1410000 S %H=0,%Y=-1 Q
S %Y=$E(X,1,3),%M=$E(X,4,5),%D=$E(X,6,7)
S %T=$E(X_0,9,10)*60+$E(X_"000",11,12)*60+$E(X_"00000",13,14)
TOH S %H=%M>2&'(%Y#4)+$P("^31^59^90^120^151^181^212^243^273^304^334","^",%M)+%D
S %='%M!'%D,%Y=%Y-141,%H=%H+(%Y*365)+(%Y\4)-(%Y>59)+%,%Y=$S(%:-1,1:%H+4#7)
K %M,%D,% Q
;
DOW D H S Y=%Y K %H,%Y Q
DW D H S Y=%Y,X=$P("SUN^MON^TUES^WEDNES^THURS^FRI^SATUR","^",Y+1)_"DAY"
S:Y<0 X="" Q
7 S %=%H>21608+%H-.1,%Y=%\365.25+141,%=%#365.25\1
S %D=%+306#(%Y#4=0+365)#153#61#31+1,%M=%-%D\29+1
S X=%Y_"00"+%M_"00"+%D Q
;
YX D YMD S Y=X_% G DD^%DT
YMD D 7 S %=$P(%H,",",2) D S K %D,%M,%Y Q
T F %=1:1 S Y=$E(X,%) Q:"+-"[Y G 1^%DT:$E("TODAY",%)'=Y
S X=$E(X,%+1,99) G PM:Y="" I +X'=X D DMW S X=%
G:'X 1^%DT
PM S @("%H=$H"_Y_X) D TT G 1^%DT:%I(3)'?3N,D^%DT
N F %=2:1 S Y=$E(X,%) Q:"+-"[Y G 1^%DT:$E("NOW",%)'=Y
I Y="" S %H=$H G RT
S X=$E(X,%+1,99)
I X?1.N1"H" S X=X*3600,%H=$H,@("X=$P(%H,"","",2)"_Y_X),%=$S(X<0:-1,1:0)+(X\86400),X=X#86400,%H=$P(%H,",")+%_","_X G RT
D DMW G 1^%DT:'% S @("%H=$H"_Y_%),%H=%H_","_$P($H,",",2)
RT D TT S %=$P(%H,",",2) D S S %=X_% I %DT'["S" S %=+$E(%,1,12)
Q:'$D(%(0)) S Y=% G E^%DT
PF S %H=$H D YMD S %(9)=X,X=%DT["F"*2-1 I @("%I(1)*100+%I(2)"_$E("> <",X+2)_"$E(%(9),4,7)") S %I(3)=%I(3)+X
Q
TT D 7 S %I(1)=%M,%I(2)=%D,%I(3)=%Y K %M,%D,%Y Q
NOW S %H=$H,%H=$S($P(%H,",",2):%H,1:%H-1)
D TT S %=$P(%H,",",2) D S S %=X_$S(%:%,1:.24) Q
DMW S %=$S(X?1.N1"D":+X,X?1.N1"W":X*7,X?1.N1"M":X*30,+X=X:X,1:0)
Q
COMMA ;
S %D=X<0 S:%D X=-X S %=$S($D(X2):+X2,1:2),X=$J(X,1,%),%=$L(X)-3-$E(23456789,%),%L=$S($D(X3):X3,1:12)
F %=%:-3 Q:$E(X,%)="" S X=$E(X,1,%)_","_$E(X,%+1,99)
S:$D(X2) X=$E("$",X2["$")_X S X=$J($E("(",%D)_X_$E(" )",%D+1),%L) K %,%D,%L
Q
HELP S DDH=$S($D(DDH):DDH,1:0),A1="Examples of Valid Dates:" D %
S A1=" JAN 20 1957 or 20 JAN 57 or 1/20/57"_$S(%DT'["N":" or 012057",1:"") D %
S A1=" T (for TODAY), T+1 (for TOMORROW), T+2, T+7, etc." D %
S A1=" T-1 (for YESTERDAY), T-3W (for 3 WEEKS AGO), etc." D %
S A1="If the year is omitted, the computer "_$S(%DT["P":"assumes a date in the PAST.",1:"uses the CURRENT YEAR.") D %
I %DT'["X" S A1="You may omit the precise day, as: JAN, 1957" D %
I %DT'["T",%DT'["R" G 0
S A1="If the date is omitted, the current date is assumed." D %
S A1="Follow the date with a time, such as JAN 20@10, T@10AM, 10:30, etc." D %
S A1="You may enter a time, such as NOON, MIDNIGHT or NOW." D %
I %DT["S" S A1="Seconds may be entered as 10:30:30 or 103030AM." D %
I %DT["R" S A1="Time is REQUIRED in this response." D %
0 Q:'$D(%DT(0))
S A1=" " D % S A1="Enter a date which is "_$S(%DT(0)["-":"less",1:"greater")_" than or equal to " D %
S Y=$S(%DT(0)["-":$P(%DT(0),"-",2),1:%DT(0)) D DD^%DT:Y'["NOW"
I '$D(DDS) W Y,"." K A1 Q
S DDH(DDH,"T")=DDH(DDH,"T")_Y_"." K A1 Q
;
% I '$D(DDS) W !," ",A1 Q
S DDH=DDH+1,DDH(DDH,"T")=" "_A1 Q
The following code is a complete implementation of ROT13, a trivially breakable cipher used for various purposes on the Net, none high security. It illustrates the compact nature of MUMPS code and is rather less cryptic than the sample above.
ST ; ROT13 ; Gunter Rensch ; 2000-01-03 ; Encrypt/Decrypt ROT13
Q ; no direct execution
;
; call from your program with
; S A="String"
; S A=$$ROT^ROT13(.A)
;
ROT(R) ;
S S1="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S S2="NOPQRSTUVWXYZABCDEFGHIJKLM"
S s1="abcdefghijklmnopqrstuvwxyz"
S s2="nopqrstuvwxyzabcdefghijklm"
S R=$TR(R,S1_s1,S2_s2)
Q R
A second implementation is below, which illustrates the possibilities of concision in MUMPS. In many respects, like pattern matching, it is comparable to later languages like Perl
s A="String" F i=1:1:$L(A) W $c($S($A($E(A,i))<91:$A($E(A,i))-52#26+65,1:$A($E(A,i))-84#26+97))
Finally, one of the shortest programs ever written in a high language, demonstrating the extreme concision of which MUMPS is capable.
s x="x x" x x
The same algorithm using expanded variable and command names
Set X="Xecute X" Xecute X
This program sets a value of "x x" to a variable named x, and then launches an infinite recursive execution of x, resulting in stack overflow. At 13 characters, including spaces and an end-of-line mark, the first variant demonstrates that it can be as compact and obscure as such languages as Perl.
See also
edit- PSL an extension to MUMPS
- Caché ObjectScript an object oriented extension to MUMPS from a prominent MUMPS vendor
- EsiObjects an Open Source Object Oriented extension to MUMPS
References
edit- ^ http://groups.google.com/group/comp.lang.mumps/msg/d4509328a7930487
- ^ Fidelity Information Services: Banking Solutions
- ^ SEC Info: Misys Purchase of Sunquest
- ^ "Welcome to M21 -- the database for the 21st Century".
- ^ http://207.192.157.194/Demo/AnnoStd?Frame=Main&Page=a100002&Edition=1995
- ^ "Microsoft to open up 'M' language – InfoWorld, October 27, 2008".
Further reading
edit- Walters, Richard (1989). "ABCs of MUMPS. 1989: Butterworth-Heinemann, ISBN 1-55558-017-3.
- Walters, Richard (1997). M Programming: A Comprehensive Guide. Digital Press. ISBN 1-55558-167-6.
- Lewkowicz, John. The Complete MUMPS : An Introduction and Reference Manual for the MUMPS Programming Language. ISBN 0-13-162125-4
- Kirsten, Wolfgang, et al. (2003) Object-Oriented Application Development Using the Caché Postrelational Database ISBN 3-540-00960-4
- Martínez de Carvajal Hedrich, Ernesto (1993). "El Lenguaje MUMPS". Completa obra en castellano sobre el lenguaje Mumps. ISBN 84-477-0125-5. Distribuido exclusivamente por su autor (ecarvajal@hedrich.es)
- O'Kane, K.C.; A language for implementing information retrieval software, Online Review, Vol 16, No 3, pp 127-137 (1992).
- O'Kane, K.C.; and McColligan, E. E., A case study of a Mumps intranet patient record, Journal of the Healthcare Information and Management Systems Society, Vol 11, No 3, pp 81-95 (1997).
- O'Kane, K.C.; and McColligan, E.E., A Web Based Mumps Virtual Machine, Proceedings of the American Medical Informatics Association 1997
External links
edit- M Technology and MUMPS Language FAQ (1999) General source; also specific source for the Poitras quote re the origin of the 1840 epoch.
- Open Source (GPL/LGPL), Kevin O'Kane Univ Northern Iowa
- Information Retrieval in Mumps (book)
- C++ Mumps Toolkit
- MDC - MUMPS Development Committee
- The Annotated M{UMPS} Standards
- Cache & MUMPS Technology Association of UK & Ireland
- GT.M Open Source MUMPS System - Fidelity/Sanchez/Greystone
- MUMPS Systems - Source Forge index
- Globals: a primer for Relational Programmers
- The M Technology Resource Center
- M Links at Hardhats.org
- A case of MUMPS A MUMPS story at The Daily WTF
- M21 - An ANSI M(UMPS) Implementation
- EsiObjects An Object Oriented extension of MUMPS
[[Category:Domain-specific programming languages]] [[Category:MUMPS programming language family]] [[Category:MUMPS programming language]] [[Category:Dynamically-typed programming languages]] [[Category:Scripting languages]] [[Category:PDP-11]] [[Category:ISO standards]] [[Category:IEC standards]] [[de:Mumps (Programmiersystem)]] [[it:MUMPS]] [[nl:MUMPS]] [[ja:MUMPS]] [[pl:MUMPS]] [[pt:MUMPS]] [[ru:MUMPS]]