Mumps Language

MUMPS is a multi-user, strongly imperative language designed to manipulate and control massive databases. It is used in the high availability, high reliability niche of the computer market, such as banking and hospitals. It provides a simple abstraction that all data values are strings of characters, and that all data can be structured as multiple dimensional arrays. MUMPS data structures are sparse, using strings of characters as subscripts.

MUMPS has been available since 1967, and was standardized as an ANSI standard first in 1977. Every few years since then, a new version of the standard has been released. (1984, 1990, 1995, Millennium)

The programming model for MUMPS is strongly imperative, because every operation is viewed as an command that changes program state. This model is taken to the extreme that the IF and ELSE are considered to be commands that control the program execution model, by modifying a control variable named $TEST. Another aspect of the imperative model is that each command modifies one part of the execution model, and only that command is used to modify that aspect.

I/O in MUMPS is very high level with magnetic tape and terminal i/o implemented as part of the language system. Low level control is not generally programmed by application code.

Disk I/O is implicit for database storage, and mapped to variable access by the syntax.


I 've been working with Mumps on DigitalEquipmentCorporation systems (PDP, VAX, ALpha) since '75: when it became standardized in ANSI the product name was changed: the DEC Mumps became DSM (Digital STd Mumps). Later the name of the language changed from Mumps to M, to take some distance from the its medical origins. See http://burks.brighton.ac.uk/burks/foldoc/97/75.htm

The most important point to mention is the performance of M, both for development and for exploitation (it took big clients from Sybase, see http://www.intersystems.com/testimonials/success/bernstory.html); see also http://www.intersystems.com/testimonials/index.html.

The product is now mostly sold by Intersystems under the name Caché: it's an OO M.

Despite its strong performance, the product is not known, may be due to bad marketing in the past (and also because a lot of successful little software shops were not wild to reveal their recipe ;-)

I'am working the last two years in C++ and Java for the security on the web (SSL, crypto, smart cards...), but stay an M junkie as far as a database is concerned (when the model is not known in advance, or when the db contains a huge amount of optional data). MichelVn


Perhaps the most unique aspect of the M language is the notion that the database is accessed through variables, rather than queries or retrievals. This means that accessing volatile memory and non-volatile storage use the same basic syntax, and even this can be obfuscated so that a function can work on either local (volatile) or global (non-volatile) variables. -- RichStone


No, the unique aspect of M is the syntax itself. I'm sure it's easy to read and fast to type if you are an expert, but...

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 contest such as the International Obfuscated C Code Contest for MUMPS, 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

--from WikiPedia, Here: http://en.wikipedia.org/wiki/MUMPS.

Here's another example from good old WikiPedia:

    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
That's the "less-criptic" version. Ok. Let's see the idiomatic version:

    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))
I am quite glad I don't have to maintain that.

Counterpoint: Well, maybe that's idiomatic if it's 1980. The 'less-cryptic' one is what I tend to see more of, unless I'm looking at really old code.


CategoryProgrammingLanguage


EditText of this page (last edited March 10, 2013) or FindPage with title or text search