MUMPS (Massachusetts General Hospital Utility Multi-Programming System)

From Bauman National Library
This page was last modified on 2 June 2016, at 08:34.
Paradigm Procedural
Designed by Neil Pappalardo
First appeared 1966
Typing discipline Typeless
OS Cross-platform
Website {{#property:P856}}
Influenced by
PSL, Caché ObjectScript

MUMPS (Massachusetts General Hospital Utility Multi-Programming System), also known as M. is a programming language created by Neil Pappalardo and colleague Dr. Octo Barnett, in an animal lab at Massachusetts General Hospital in Boston throughout 1966 and 1967. At first, MUMPS was developed to make writing database driven applications easier, but it did not get widely recognized until it was introduced in the admissions cycle and laboratory test reporting. It predates C and most other popular programming languages of today, yet is still used in many different institutions in different fields. Over the years it has been modified and adapted by different medical communities according to their needs. Not only do hospitals and medical organizations such as the US Veteran’s Administration use MUMPS, but it is also used by large companies like Meditech and GE Healthcare. MUMPS is also widely used in financial applications by many banks and credit unions, making the language truly versatile.


Determination MUMPS as programming language is contingently, because it was developing during the crystallization of programming languages, and its scope of work ranges from medical equipment to operational databases and expert systems (eg, VA VistA). MUMPS was born in a specific medical environment of Cardiology (Octo Barnett). Originally designed to facilitate writing database applications, while making maximum use of computer resources. It is often used in hospitals and for the financial information systems and databases (particularly developed in the 1970s and early 1980s), and continues to be used for a number of clients. Now MUMPS is the basic language systems DSM, MSM, M3-LITE, GT.M, Caché. Global arrays in MUMPS systems are used for building and managing databases. The structure of the global arrays - a unique feature of the language MUMPS. These arrays are automatically recorded on the disc, without the need for redundancy and address space to write, are the hierarchical structures and sparse by nature. The arrays can contain any number of levels of the hierarchy, with data can be stored at any level of the array. The index of the array can be any valid expression of MUMPS, the result of evaluation which can be a number or string of characters. The free version of MUMPS GT.M optimized for the transaction may be the development platform, the compiler is compliant with ANSI / ISO. It is used in various industries, above all in the finance and health care.


Making the database design and building process easier for programmers and using minimal computer resources. Helping the different organizations save time and money. Many of todays users include: Ameritrade, Bank of England, Barclays Bank, Beijing Medical University, British Gas, British Petroleum, Budgens, Carphone Warehouse, Chase Manhattan Bank, Coca Cola and Schweppes, Cornhill Insurance, Department of Health & Social Security UK (DHSS), Digital Equipment Corporation (DEC), Domestic & General, Dow Chemicals, English Tourist Board, Equity & Law, Esso, Games Workshop, General Motors, Grecian Holidays, Hamburg Ports Authority, Helsinki University Hospital, Hoffman La Roche, Hoverspeed, ICI, Indian Health Service, Istel, Jewson, Koor Foods, Israel, KPMG, Legal & General Insurance, Lloyds Bank, Meyer International, Ministry of Defence (UK), National Health Service, National Westminster Bank, Nederlandse Aardolie Maatschappij, New York Stock Exchange, Psychiatric Institutes of America, Reed Information Services, RIPAS Hospital, Brunei, Shell, Smithsonian Institute, Soviet Parliament, Swiss Parliament, Tottenham Hotspurs FC, Trinity College, University of Adelaide, University of Cologne, US Department of Defense, Waterford Crystal, West Ham United FC.

"Hello, World!" example

A simple Hello world program in MUMPS might be:
hello()  write "Hello, World!",!


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 made 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

ANSI X11.1-1995 gives a complete, formal description of the language; an annotated version of this standard is available online. Data types: There is one universal datatype, which is implicitly coerced to string, integer, or floating-point datatypes as context requires.

Booleans (called truthvalues in MUMPS): In IF commands and other syntax that has expressions evaluated as conditions, any string value is evaluated as a numeric value, and if that is a nonzero value, then it is interpreted as True. a<b yields 1 if a is less than b, 0 otherwise.

Declarations: None. All variables are dynamically created at the first time a value is assigned.

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 any IF, ELSE, and FOR command 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: execution of almost all commands can be controlled by following it with a colon and a truthvalue expression. 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, two, or three 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 contest such as the International Obfuscated C Code Contest for MUMPS, despite the potential of examples such as the following, perfectly legal, MUMPS code:

       QUIT:$QUIT QUIT QUIT ; (quit)

MUMPS can be made more obfuscated by using the contracted operator syntax, as shown in this terse example derived from the example above:

       N S,N,T,I,K,Q S I="K",S="11",K="l1",Q="R",T="K"
       I I=T D T
       Q:$Q Q Q
T  I I,S&amp;K S S=S+K Q

Arrays: are created dynamically, stored as B-trees, are sparse (i.e. 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. Built in functions such as $DATA, $ORDER, $NEXT(deprecated) and $QUERY functions provide efficient examination and 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")=""

Local arrays: variable names not beginning with caret (i.e. "^") are stored in memory by process, are private to the creating process, expire when the creating process terminates. The available storage depends on implementation. For those implementations using partitions, it is limited to the partition size, (A small partition might be 32K). For other implementations, it may be several megabytes.

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 (for example, hundreds of gigabytes) 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 substitution allows for lazy evaluation and late binding as well as effectively the operational equivalent of "pointers" in other languages.

Piece function: This breaks variables into segmented pieces guided by a user specified separator string (sometimes called a "delimiter"). Those who know awk will find this familiar. $PIECE(STRINGVAR,"^",3) means the "third caret-separated piece of STRINGVAR." The piece function can also appear as an assignment (SET command) target.

$PIECE("",".",2) yields "std".


SET X=""

SET $P(X,"@",1)="office" causes X to become "" (note that $P is equivalent to $PIECE and could be written as such).

Order function: This function treats its input as a structure, and finds the next index that exists which has the same structure except for the last subscript. It returns the sorted value that is ordered after the one given as input. (This treats the array reference as a content-addressable data rather than an address of a value)

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.

For iterating the database, the Order function returns the next key to use.

GTM>S n=""
GTM>S n=$order(^nodex(n))
GTM>zwr n
n=" building"
GTM>S n=$order(^nodex(n))
GTM>zwr n
n=" name:gd"
GTM>S n=$order(^nodex(n))
GTM>zwr n

Multi-User/Multi-Tasking/Multi-Processor: MUMPS supports multiple simultaneous users and processes even when the underlying operating system does not (e.g., MS-DOS). Additionally, there is the ability to specify an environment for a variable, such as by specifying a machine name in a variable (as in SET ^|"DENVER"|A(1000)="Foo"), which can allow you to access data on remote machines.


Even in publications MUMPS supporters argued that this technology is unpopular and not widespread, and the new database applications often are created using SQL and popular programming languages. Critics called MUMPS just the technology outdated and point to weaknesses of the MUMPS such as:

  • no typing (all data is stored as a string);
  • low level of abstraction;
  • unreadable syntax, especially when using abbreviations.

Critics call MUMPS a provoking errors language because:

  • there is no mandatory declaration (declaration) variables;
  • not supported priorities usual arithmetic operations (for example, the expression 2 + 3 × 10 MUMPS gives a value of 50);
  • extra space or line break can completely change the meaning of syntax;
  • language keywords are not reserved and can be widely used as identifiers.


  • 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 author (
  • 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
  • O'Kane, K.C., The Mumps Programming Language, Createspace, ISBN 1-4382-4338-3, 120 pages (2010).

External links