Join the M revolution

No readers like this yet.
MUMPS, M and R programming languages

Opensource.com

Are you a geek?

If so, driving the future of healthcare is now within your grasp.

What do you have to do?

Learn the M programming language, and teach it to others.

What’s the M programming language?

The M programming language is also known as MUMPS. Which stands for Massachusetts General Hospital Utility Multi-Programming System.

M 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—which includes banking and hospitals. It provides simple data abstractions, in which all data values are strings of characters, and all data can be structured as multiple dimensional arrays. M data structures are sparse, using strings of characters as subscripts. M is itself a language combined with a database engine.

Is M difficult to learn?

Here is the common Hello World program, written in M:

MYLABEL ; This is a comment
 WRITE !,”Hello World”
 QUIT

White spaces are significant in M. Commands typically start in the second column. Arguments are separated from commands by a single space.

Is M boring?

Not at all, M starts easy, and rapidly becomes interesting.

Here is one of the coolest features of M, the sparse indexed array:

SET ClientAddresses(“Main Street”,”1056”,”Apt 23”)=”John Doe”
SET ClientAddresses(“Main Street”,”1056”,”Apt 23”,”August 15”)=”Mary Poppins”

In this example, the strings “Main Street”, “1056”, “Apt 23” and “August 15” are all used as indexes in the sparse array “ClientAddresses.”

Sparse arrays are one of the features that make M uniquely well-suited for healthcare applications, because it matches the natural sparseness of data resulting from the series of unlikely events that compose a health record.

And here is the Fibonnaci series, computed in M:

FIBONACCI ; compute the Fibonacci series
 SET (A,B)=1
 FOR I=1:1 SET S=A+B WRITE !,S SET A=B SET B=S QUIT:S>100
 WRITE !,"Result= ",S

Would programming in M help me get a job?

  1. More than 80 percent of hospitals in the US do not have electronic health records (EHRs). Instead, they still run on paper forms [1].
  2. Hospitals are being given monetary incentives for adopting EHRs in the next few years. Some will also be subject to penalties if they do not adopt EHRs by certain dates [5].
  3. The largest EHR systems currently deployed in the US are written in M, including VistA (Veterans Health Information Systems and Technology Architecture). VistA is the system that currently manages all hospitals and ambulatory care facilities run by the Department of Veterans Affairs [6].
  4. Deploying EHRs in hospitals will require of tens  of thousands of developers over the next few years.

Institutions using M include: AmeriPath (now part of Quest Diagnostics), Care Centric, Epic Systems Corporation, EMIS, Partners HealthCare, MEDITECH, GE Healthcare (formerly IDX Systems and Centricity), Hospitals of the Department of Veterans Affairs, the Department of Defense and the Indian Health Service.  Among the financial users are: 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.

Why have I never heard of M (or MUMPS)?

The application field of M is very specific to high demand and high performance databases that require support for sparse data. Most M developers have been working for many years in the specific niches of high performance healthcare and financial applications.
The initiative of deploying EHRs in all US hospitals, now brings M programming into the mainstream where thousands of developers would be needed to maintain and support all those installations.

Is M cool? Can I write mobile apps with it?

Yes and yes.

Once you have learned the basic techniques of M programming, you can check EWD, the Enterprise Web Development environment, and start interacting with M database applications from mobile devices, including both iOS and Android [2].

I’m into NoSQL databases. Why should I care about M?

Because M is a NoSQL database. M is indeed a language that has integrated a database engine to store data persistently. M existed well before SQL was around. And M is also a highly scalable and reliable database system.

It is quite likely that your payroll and your bank account are being managed by an M database.

How do I setup an M programming environment?

You can get a virtual machine with an M programming environment already set up on it here:

Or you can follow the instructions on this page to create your own:

In both cases you will be using an Open Source implementation of M, called GT.M [3], developed and maintained by Fisglobal [4].

Where can I learn more about M?

This article is intended to be the first in a series. In our next installment, we will cover M 101—a basic introduction to M programming, including the basics of flow control and routines.

If you have any specific questions of topics that you would like to see discussed, please post them in the comments, and I will address them in subsequent posts.

You may also find useful to look at the following books:

  1. M Programming by Richard F. Walters
  2. The Complete MUMPS by John Lewkowicz

References

[1] Use of Electronic Health Records in U.S. Hospitals,  New England Journal of Medicine,  2009 (http://www.nejm.org/doi/full/10.1056/NEJMsa0900592)
[2] Enterprise Web Development (EWD) (http://gradvs1.mgateway.com/main/)
[3] http://sourceforge.net/projects/fis-gtm/
[4] http://www.fisglobal.com/
[5] http://www.cms.gov/ehrincentiveprograms/
[6] http://www.va.gov/vista_monograph/

User profile image.
Luis Ibáñez works as Senior Software Engineer at Google Inc in Chicago.

31 Comments

Why would the future of healthcare be written in MUMPS?

Healthcare is an industry that is at least 10 years behind in technology, don't you think that promoting MUMPS instead of promoting the use of newer technology (programming languages in this case) in Health IT goes against driving healthcare to 'the future'?

Healthcare, and specially new people getting into health IT, should take advantage of all the new discoveries that have been made since MUPS was created more than 50 years ago, instead of adopting all the bad habits the industry already has.

Thanks for sharing the post anyway and for paying attention the the health IT industry!

As a long time user of M, I get frustrated when everyone talks about the 'M language'. The strength of M is not the language (not that it is bad, but it is fairly dated), but the database. The 'M language' is great of managing that database, and a great deal of the behind the scenes business logic. It isn't equipped to deal with modern user interfaces however. We use HTML, Javascript, Ajax, node.js, Adobe flex, and others for our 'front end' work. There is no reason you can't use any language or development tool to do that portion. Trying to squeeze healthcare data into SQL tables is a much worse thing to do....

but the only problem is that very few people in the IT world know about M Technology, and when you start you need to know the basic commands for which we need to learn MUMPs. no doubt the database thing but to suddenly try and learn a language without any help available

but the only problem is that very few people in the IT world know about M Technology, and when you start you need to know the basic commands for which we need to learn MUMPs. no doubt the database thing but to suddenly try and learn a language without any help available

Apparently people say that VistA software is much faster with mumps rather than any other modern programming language and none of the IT companies are interested in experimenting these days......

You bring a good point.
Your are right, the future doesn't necessarily have to be written in M.

However, the reality in the ground and in the present, is that the best EHRs, and those that have the largest deployments in the US are written in M, both the proprietary ones and the open source ones. This represents tens of millions of lines of code that are currently working in thousands of health care facilities. This body of software requires a vibrant community to support it.

The argument that "a language is old" is not valid in itself. That is, languages do not expire. The real problem is when the language is not spoken by enough people, which is the challenge that this series of posts is intended to address.

The point here is not that "M is the only option", but that "M is a really important option", and that a new generation of developers are needed in this space.

Should others still choose to program in C++, Python or Java ?... Sure why not.

But that doesn't change the current reality, where there are tens of millions of lines of M code running in health care facilities, that will require a large community to maintain them. These are proven systems, that are currently saving lives on a daily basis and reducing the cost of health care delivery.

For young developers looking to engage in meaningful projects, M is an excellent option.

You are right. Languages do not expire.

And yes, if a programmer wants to go work for some of the companies that you mention, then definitely M is the option for them.

But, in my opinion, those companies and their solutions are not changing healthcare. They are old and expensive solutions.

My point is, why try to move people to a language no one speaks, instead of moving an industry to the current trends everyone likes all around - I'm not saying to change the codebase of the companies/solutions that you mention, but instead, to create new products under newer and sexier architectures that everyone is looking for.

My bet is that if more companies in healthcare were programming with node.js, rails, NoSQL (not M...), python/django, etc. more programmers would be attracted to join the industry. Wat do you think?

Thanks for answering!

JL,

Yes, I agree with you in that other newer technologies also have an important role to play in the healthcare space.

In particular, I'm glad that you mentioned node.js, since this brings us to talk about EWD (http://gradvs1.mgateway.com/main/) the "Enterprise Web Development", an Ajax framework that facilitates writing databased-driven applications. EWD integrates a secure session model into a real-time web framework based on Node.js and a Javascript. On the server side, EWD interfaces to an M database. This is an example of how new and old (proven) technologies can be combined successfully to satisfy users needs. On the front end, we get a model graphical user interface that can be deployed in iPads and Android devices, while on the server side we get the reliability, scalability and speed of an M database.

We will actually be using EWD and M in our current Open Source class at RPI, (http://public.kitware.com/OpenSourceSoftwarePractice/index.php/Spring2012/Main_Page) to do class projects combining mobile devices that connect to installations of VistA.

You also mentioned python and django, which is interesting as well. Students in our class will also be working of projects related to Indivo (http://indivohealth.org/) using python and django.

Your point is well taken, that M is not the only way towards the future applications in healthcare, and that many different technologies will have a combined role to play in this space. Just as with other fields of applications, it is important to use the right tools for each one of the different components of a system.

Having seen this system at work, it is a very powerful system that smokes just about any other distributed system that can be created with newer tech. Before you chastise me, I'm an old C, Unix, Java, JEE developer architect. The M language should be thought of as a Domain Specific Language (DSL) in this space. Sure you can write any of the apps that are used in VistA with other languages, but the level of effort and the expressiveness of the languages isn't going to match what M developers can do; at least not without significant effort. Anyone that thinks that's BS clearly hasn't examined the language or the DB. Sure there are shortcomings with the DB related to transactions, but its designed to be adaptable to the needs of the hospitals and medical taxonomies in general. As such a lot of flexibility is required and that's what has made the VistA design so robust. It allows dynamic changes and doesn't require a schema to be developed ahead of time. The medical field is dynamic, unlike a lot of other businesses. There's a ton of rules and domain specific information that would make any relational DB trying to do similiar things completely fail; I have witness this first hand btw.
I've seen the new tech arguments before, and used to be on that wagon, but in this case M is the correct language and DB for this solution. Extending its capabilities using RESTful APIs and things of that nature is certainly a wonderful thing and clearly should be done. But don't throw the baby out with the bath water.

Great article. I've worked with M for over 2 decades in various healthcare institutions. It's amazing how it has supported multi-user systems from 286's to minicomputers (remember them?) to IBM mainframes to today's servers. In one large company we had the same application running on OpenVMS, Unixware, Linux and Windows. While there are domains in which it is not appropriate, for storing and accessing large amounts of indexed data, it is hard to beat.

And the syntax of the base language does not pose the barrier of entry that some more modern languages might.

Steve

Thanks for the Great Article! I've been programming in M for 20 years in both the Healthcare and Banking Industries.

I understand the author is from an Open Souce background, but is is really unfair to talk about M without mentioning InterSystems, specially when all cited organizations (except MEDITECH) are long term Caché/Ensemble customers, <b>NOT GT.M´s</b>.

Yes, thanks for pointing this out.

I'm intentionally sticking to GT.M. ( http://www.fisglobal.com/products-technologyplatforms-gtm ) because it is what I plan to use for the subsequent tutorial posts, and of course, as you pointed out, because it is open source.

But you make a good point, that Intersystems Cache (http://www.intersystems.com) is of great importance for the M community.

Thirty plus years ago I began using MUMPS and the then-current VA File Manager in an academic outpatient department to implement an appointment system and a lab result followup application. While the university hospital spent $4.5 million on a pretty, IBM-based HIS that never satisfied the medical staff and was discarded after a few years, we spent a few thousand and got something that served for over ten years! Today I still use MUMPS to manipulate data sets that others seem unable to deal with using sexy, "modern" tools. To be sure, the basic MUMPS terminal interface is not pretty or sexy, but the language has powerful string manipulation capability, and the database is wickedly fast, and because of the sparse arrays it occupies minimal space on disk. Thus I can carry around an entire large hospital database on a laptop! Try that with one of the "modern" RDBs.
I use both Caché and GT.M, and other than the fact that I have to pay for multiuser capacity on one of them but not the other, they both work fine. And both expose their data and string handling to graphical programming tools that do look modern and sexy - so we can make the users out there happy with appearance as well as performance.
"Modern and sexy" clearly apply to a new Porsche, but under the hood is an engine running on the Otto cycle, developed in 1876. Sure, there are newer alternatives like gas turbines and rotary engines, but the Otto cycle engine is in that Porsche, or Lamborghini - you name it - because it still works for the application at a (sometimes) reasonable price. That's why MUMPS is still the engine under the hood of so many high-performance data systems: it works outstandingly well, and at a cost that makes economic sense.

When you said "carry the entire hospital database around on a laptop" I couldn't help but think of all the news stories where such laptops were lost or left in taxis. I hope you at least encrypt the disk.

Thanks for the great article! I started using MUMPS 20 years ago (Epic Systems) and enjoyed it immensely.

In 2011 I began developing a Java Framework around MUMPS (focus on GT.M but should port to Caché fine). I love the flexibility of MUMPS data storage and indexing - but I like my web server and most business logic to be in Java.

My framework is still in the early phases of development. But anyone interested should check it out here http://www.divconq.com/ .

LOL - April fools day is next month guys.

This is an antique total timewaster that will merely soil your brain. Go learn "Perl" or something else useful, that really is used in Banks etc nowdays

(and yes - I work in a bank).

MUMPS is used in banks (GT.M targets that market) as well as credit unions. I believe Caché is used at TD Ameritrade.

Guess the healthcare industry is not useful enough.

Well done you "Unidentified " - you work in a bank and you know perl - which of course is one of those new generation languages and the banks love it for is ease of use and the way it can handle millions of customers data in a heartbeat....

Mumps still has it's place and for any one to disregard it based on its age clearly needs to go read some more brochures.

Rejecting something based on its age does injustice to our elders in a human sense and to other items in a DP sense:
. Unix and its descendants (Linux, BSD, etc)
. C++, C# and other descendants of C
. Lisp/Scheme/etc, which is still alive and kicking and whose traits are showing up in newer languages

eXist DB and native XML database may be an alternative. Markmail uses this and the performance using Xquery is worth reviewing. This would allow SOA and restful web services where other web based technologies could be used...

Wow! Blast from the past. I worked with all the biggies in the MUMPS world back in the day; InterSystems, DEC, and Greystone.

MUMPS has a lot of cool features that even today sound advanced, but the 1970's they were just unbelievable. e.g. it's typeless; everything is a string; we didn't call it that at the time, but it's almost object oriented, if A="1.2" and B="3.4" then A+B="4.6" but if you concatenate them (I forget the syntax) it's "1.23.4"

Also, a program's code was stored in the database, *and could be modified by itself*! Yes, code was data, and data could be code. a *lot* of MUMPS code out there forms a string of code and then executes it. Wild, wild stuff.

As for it looking old, yeah I guess it does. But look at "Pig" for Hadoop. It has a decidedly retro feel to it. MUMPS will fit right in!

I look forward to the rest of the articles!

-Matt Phelps

Seems like MUMPS is more of a scripting shell / environment pasted on top of an SQL server or similar, rather than a "language" as such. It seems like you could easily write a series of MUMPS scripts and call/control them from a BASH environment on a Linux host, or even via cgi/java scripts from an HTML server.

It's sweet spot would seem to be making it a bit easier to create and interface to an arbitrary-content relational database.

It actually doesn't seem too different to me from the icicle scripts we used to write to access our db at work.

Do not mistake maturity of a method with feebleness. I code in C and assembly often; there is power at the base of the pyramid.

"Seems like MUMPS is more of a scripting shell / environment pasted on top of an SQL server or similar," - could not be any further from the truth ! I started off writing for DEC PDP/11 and VAX/VMS where on the PDP MUMPS was the operating system (search for DEC DSM) !!! Its the language and the database with its storage being Hierarchical l as opposed to structured (SQL) - and later in life it got SQL layers to be compatible with more of the "Business objects" applications, but usually the data was still Hierarchical with data-mapping going on behind the SQL scenes (anyone remember EDA-SQL?). On VMS & Unix it even had direct interfaces to TCP/IP sockets where things got really interesting as it opening up a whole new world. Back in late 90's (according to the google groups post feb 1998) I had it running webservices straight from the database engine.

I can name banks, trading floors, solicitors, supermarkets, high street retailers, insurance brokers who all use it.

http://en.wikipedia.org/wiki/Hierarchical_database_model
http://groups.google.com/group/comp.lang.mumps/

Application Developer and very much interested in "M" would love to learn...

Application Developer and very much interested in 'M' would love to learn...

for CustomDesigned

You bet the disk was encrypted, with a very hard password. As were the files themselves.

And handcuffed to my ankle as well.

The point I was making, however, was just how compact on disk a MUMPS database is. I'm talking about 20 years of data for an 800 bed hospital. And not just the data, but all the routines that manipulate those data. Maybe compact is an understatement, but storage costs are obviously minimized.

I have been a MUMPS, M, CacheScript programmer since 1985, starting at the VA in Providence, RI work with Fileman on the DHCP software. Moved to Fileman and CHCS for the military, then Kaiser Permanente and MIIS'ised version of MUMPS, on to Fileman and RPMS with the Indian Health Service, now IDX and EPIC. A long road and all MUMPS or M or CacheScript. To say the language is not important is not accurate, I have seen it change over the years and when Intersystems finally broke the MDC gidlock I was very happy becase the language was modernised. Reading these comments shows me that some of you have no clue about the language or the database it works with. Without the language and the DB being integrated the way they are it would not have survied as long as it has, don't try to separate them it is the complete environment for doing the kind of systems it is used for. And it is fast, fast, fast. I am amased at how responsive it is from web sites I have developed (not using CSP but Cache side HTTP server routines).

Interesting Site I would like to see more.

Some 15 years ago i started my computer science studies, I was around 20 yrs then. I learned c,c++,java and some scripting like HTML,javascript etc and little introduction to Database concepts.But then I had lot of setbacks in life, during which i had to stop any computer science studies/work or usage.
Now, if I have to learn 'M' programming,MUMPS, to be able to implement it in organization, ---How long would it take me?--- plus i would need minimum 6 month to brush up my previously learned comuter skills.
I think,given my situation, any programmer guide would suggest me to just forget about programming. What you people suggest?

I used to teach web development at a local tech college (and I've used M quite a lot), so I've fielded questions like this often.

Assuming you did well with programming 15 years ago, your challenge will not be brushing up your skills so much as finding a job. If you do want a job in software development you'll probably face a lot of competition from people with recent experience.

One of the best ways to subvert this is to find a niche and learn it. Just for example, learn WorldVistA (http://www.worldvista.org/) which includes MUMPS and some new fun stuff like nodeJS. I'm not sure what the market is like for WorldVistA at the moment - so don't take it too literally - just try to find a niche that is not over populated and become good at it.

Another approach would be to take on little web development projects. It can be hard to make good money - especially without a portfolio - but there are plenty of web design firms out there that need a hand in the site coding (probably PHP and MySQL though, not so much MUMPS).

Having just a language skill alone (just Java, just MUMPS, etc) without a niche or a portfolio is hard to sell. a) how do they know you are good, b) many other people have language skills but not the knowledge of a specific area.

If programming comes naturally to you, then MUMPS itself is quite easy to learn. It is unlike many databases, so there is a hump, but once you understand globals and what $o, $d and $q do then you have what it takes. You may consider my intro - 4 posts on M at http://www.divconq.com/home/getting-started/ - but there are plenty of other intros out there too.

I just got this message from Laurent Parenteau, who kindly has prepared a patch to get github to recognize M code and not misclassify it as Objective-C. (Currently, M-language projects in github are classified as written in Objective-C).

Please help us promote this fix by posting a comment with a "+1" in support of Laurent's patch.

<quote>
"...I have submitted a patch to fix this, but from what I have read, it would help and improve the speed at which they will integrate it if some people "+1" my changes.

Since I think you may be interested in seeing this fixed in GitHub, I thought I could ask you to go to to my pull request (https://github.com/github/linguist/pull/148)) and simply add a comment saying "+1". Also, feel free to forward this to other M and GitHub users who may be interested in this."
</quote>

Thanks a lot to Laurent for putting this patch together.

Luis

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.