views:

350

answers:

9

Dear Stackoverflow,
Once upon a time, a team of guys sat down and wrote an application in C, running on VMS on a VAX. It was a rather important undertaking and runs a reasonably important back-end operation at LargeCo. This whole shebang works so well that twenty-five years later it's still chugging along and doing it's thing.

Time passes and people retire and it so happens that the Last Man Standing has turned over the keys to a new generation who - we might imagine - are less than thrilled to find themselves caretakers of a system old enough to be their younger brother. Yet, as underwhelmed as they are by the idea of dealing with Ultra Legacy Systems, they can't justify the cost of replacing the venerable application.

LMS discovered that I habla unix and put this question to me. And since I habla unix but don't speak the C I shall summarize and put it to you. Long Story Short:

LMS wants to port LegacyApp, written in C. from VMS to unix. Resources? Any books he can read? People he can talk to?

+1  A: 

To learn C, you might as well drag it from the horse's mouth: "The C Programming Language" by its inventors, Kernighan and Ritchie.

I can recommend "The UNIX programming environment" by (again) Brian Kernighan; a more authoritative source you'll hardly find, and it teaches you both Unix/C idioms and a bit of C programming at the same time.

For more depth and detail on C, I heartily enjoyed a book by Peter van der Linden: "Expert C Programming - Deep C Secrets".

You'll also want to wrestle LMS for a library documentation of VMS-specific C functions with (of course) special emphasis on those actually used in the app. That's where your porting effort will be.

The job could be easy or difficult, depending on how much machine-specific cleverness and bit-twiddling is done, and how many VMS-specific system calls are used. It would be very good if word size was equal (in other words, if your VMS box has a word size of 32 bits, don't run the code on a 64 bit version of Unix!)

Carl Smotricz
+1 for deep c secrets a truly indispensable resource
ennuikiller
That is an excellent book and definitely recommend it! :)
tommieb75
I would also recommend a copy of "C in a Nutshell" from O'Reilly as a good desktop reference.
Joe Internet
+1  A: 

You have several choices.

  1. Get the OpenVMS source, and continue to maintain Open VMS as if it were a Linux distribution. Some folks don't mind keeping up with Linux distributions and OpenVMS distributions. It can be done.

  2. Try to recompile the VMS C into Linux. This can be trivial if the C used only standard libraries. This can be very, very difficult if the C used a lot of VMS libraries.

    Once you have facts at your fingertips, you can reevaluate this course of action. Since you didn't list a bunch of VMS library methods this program uses, it's impossible to tell how entangled it is with the OS.

    This may be trivial or impossible. It's difficult to tell without analysis of the source.

  3. Write bridge libraries from VMS to Linux. If your program only does a few VMS things, this isn't very difficult. If your program does extensive VMS things, this is craziness.

    The bridge -- in the long run -- is a terrible idea. Managers love it, however.

    An alternative is to replace the VMS library calls with proper, portable Linux calls rather than write bridges. This is better in the long run, because it excises the non-portable features of the program.

  4. Rewrite it from scratch in Python. That is usually simpler than trying to port the C code. It will be shorter, cleaner, simpler, and portable.

S.Lott
Mostly good advice, but I disagree with (4). Rewriting in Python will require you to re-visit every single line of code, understand and translate the logic and not screw up in the process. At least in terms of initial effort, this will likely be MUCH more costly than just migrating the VMS specific part of the old code.
Carl Smotricz
Depends what the old code did. If it simply took some input, did a bit of recalculating and generated a report, that might have been 50kloc of C on VMS but you could rewrite it using a few high level language modules in a single screen. Just because the original app was in C doesn't mean that is the best choice today.
Martin Beckett
@Carl Smotricz: That's exactly the thing to *avoid*. Don't transliterate C to Python. Junk the C. Start from first principles and write the correct program using new technology, doing it the right way.
S.Lott
If you reckon there's a spec extant other than the C source code, you're a less cynical man than I.
caf
The advantage of a spec written in C is that at least you know it's correct - or at least you get what the spec says !!!
Martin Beckett
Any specification for legacy code is incomplete and incorrect. No one maintains the documentation. Period. You have to reason out what the program is doing based on current use cases.
S.Lott
+5  A: 

Everything written on VMS uses lots of VMS specific stuff it was just so convenient.

There are a few companies that sell compatibility libs to make the port easier - they wont be cheap though, VMS tended to be used where reliability mattered more than cost.

The other option is to run openVMS on some modern hardware, possibly in a VM.

Martin Beckett
+1 for mentioning a VM.
Jonathan Leffler
Thanks for mentioning the VM: LMS thought this might be the easiest option, if not the most fun.
Brian Dunbar
A: 

Well u have a few options. if this code needs to be ported rather quickly, i would write a bridge library to emulate the vms libs. whener you get it back up and running on a *nix, then go through replacing the vms library calls with native/portable calls for *nix.

Also if there is a lot of optimizations in the code ie inline assembly and bit twiddling. then you will have to rewrite thi code, which will take an understanding of the VAX arch. also. be sure to check word size differences and endian differences

Earlz
A: 

Now?!?

Really?

The particle physics community made this move en masse about 15--20 years ago. It is likely that someone wrote up some guidelines, though I don't know where to point you. I'd also look for a compatibility library.

dmckee
Yeah, really. I don't know the particle physics community but some places in the private sector if a thing is working and supported, there is no reason to throw it out.At my own company we have an AS/400 in the basement. First bit of automation the company had, and years later accounting still uses it.If it didn't work, we'd replace it. But it does so the new system isn't critical and it's not funded.
Brian Dunbar
By all means, don't break what isn't broken (I saw a PDP11 running as a data acquisition computer at a lab that shall not be named in *1995*), but the supporting VMS and unix for users got to cost to much, so the VMS machines were discontinued over about 5 years in the early 1990s. There *must* be a repository of wisdom out there---physicist got to be pack rat like about putting things on the internet very early---I just don't know where.
dmckee
@Brian: the issue isn't whether the AS/400 continues to work; the issue is 'what happens when it does stop working'? Is the system mission critical? What is the fallback setup? When was it last tested?
Jonathan Leffler
+1  A: 

If you're willing to keep running VMS in a VM, you can look into CHARON-VAX ( http://www.charon-vax.com/ ). As previously mentioned, the ease of porting really depends a lot on how much of the VMS extensions were used; searching the source code for $ characters embedded in strings (usually with a 3-character leading substring, such as lib$gettime or dsc$descriptor or sys$foobar etc) will give you at least a basic idea of what VMS system functions are called and how likely they are to be portable, if the name is reasonably obvious.

Hellion
+3  A: 
  1. The first question I'd need to ask is why, and I'd be leading the conversation in the direction of "Do you really need to port it off of VMS". There are a number of things worth mentioning about VMS:

    -> VMS is still actively developed and maintained by HP. They just release V8.4 for Field Test last week (see http://h71000.www7.hp.com/openvmsft/).

    -> VMS is available on new hardware; specifically HP's Integrity servers based on the Itanium processor.

    -> VMS is also available on virtual platforms via the Charon Emulation products.

    -> Popular estimates are that there are about 300,000 VMS systems still in active use today. LMS may be the last man at LargeCo, but he's far from the last man standing worldwide.

    -> Lots of information out there, see openvms.org for example, to see lots of current information on VMS, all from current users.

  2. OK - you still want to port off of VMS. How do you do it? Well, it depends on lots of stuff.

    -> As others have said, how standard is the code? Chances are, not very. The more VMS-isms, the more difficult the job. 'nuff said.

    -> What is the database? If it's Oracle, probably not too tough to move to Oracle on some other platform. If it's some sort of custom DB based on RMS index files, then you've got more work to do, you'll need to re-create that pseudo DB, or, understand it enough to replace it with some relational DB.

    -> Besides C, what else is used to create the application? What's on the front end? DECforms? FMS? Is there a transaction engine, e.g. ACMS? RTR? These things will have a huge impact on the feasibility and effort required to port to UNIX.

    -> What other products are involved? Are there any 3rd party libraries being used? Are there 3rd party products in use that are critical to the application or functionality?

    -> Is this system clustered? If so why? You'll need to meet those same goals with the UNIX box.

    -> There are companies out there that will help you do it, and claim to have tools to make it easier, but my experience is that these companies tend to be selling you more services than products (i.e. you need to hire them to use the tools. It'll be expensive).

  3. The book UNIX for OpenVMS Users will give the VMS novice some help in understanding VMS, but, as the title says, the book is really intended for the opposite purpose.

Brad McCusker
Nice to hear from a VMS (ex?) engineer. I worked in ASV/CIFS team in India (mainly in the Samba porting).If your operating cost of VMS is not too high compared to porting it to Unix, leave it as it is...
hackworks
A: 

Depending on what languages you already know, C is not that hard to learn. I taught myself C in the course of learning C++ after finally prying myself loose from Pascal. (VAX Pascal, plus Rdb/VMS, plus DCL formed a combination that was hard to beat.)

If the software is typical C, you'll spend more time learning the library functions than learning the language.

It's pretty lightweight stuff, but I went through the online tutorials for C++ that Microsoft makes available in conjunction with the express edition of Visual Studio for C++.

Here's the beginner's tutorial:

http://msdn.microsoft.com/en-us/beginner/cc305129.aspx

Walter Mitty
A: 

Brian, I'm not sure if LMS specified/cared to port C-code or the WHOLE process. As too often people think of languages out of scope of systems.

If there're was a process built on VMS, most likely it used at least scheduling/batch facilities, which are often scripted in DCL (rather simple and clear language, unlike shell or perl scripting).

So the cost of porting the whole process may be higher than originally perceived by your LMS. Add here the reliability aspect, given your crunches with C, which is nothing impossible, of course, with enthusiasm and determination.

If you want simply give the C-code a try, as previously posted, search it for the "$" hits. Or just cc it with all headers present, the basics of compile-link command should be enough.

Alternatively, this looks like a consultant's call, as indeed such jobs were abundant at the "exodus" time. All said VMS remains quite a robust platform (24x7 is a norm!), unless the harware dies, then there're still tons of "exodus" spares. GOOD LUCK!

vmsnomad