Perl Runs Sweden's Pension System
by Ed Stephenson
A Fallback Application Built in Six Months Earns the Prime Role
By the spring of 2000, Swedish government officials were pretty nervous. The delivery date on a major computer application was already a year late, causing a highly publicized delay in the start of the nation's new money-market pension system. With the legal deadline approaching for the system's launch, the government gave PPM--the agency in charge--six months to develop a fallback application, just in case the main commercial program hit another snag.
"Those were the days when stocks only went up," remarks Henrik Sandell, appraising the government's anxious mood at the time. PPM hired Sandell, an independent consultant, and Henrik Johnson from GlobeCom AB, an information technology services company in Stockholm, to design the back-up application for Sweden's Premium Pension System, with the simple directive that they provide something usable very quickly. "In the beginning PPM didn't much care what we used to develop our system, since they were fairly convinced it would never be put in production."
Given the time crunch, Sandell and Johnson's team built the application (known as Pluto) with Perl, using an Oracle database. Not only did they deliver the application on time, but when the commercial system proved difficult to customize and install--despite two years of modification by numerous developers--Pluto demanded a serious look. "An evaluation indicated that our system was faster and more likely to succeed than the original application," Sandell points out, at a fraction of the cost. PPM was convinced, and Pluto became the Premium Pension System's application of choice.
Any doubt that a Perl-based application would be robust enough to handle a large, mission-critical, financial-batch system has been dispelled by Pluto's performance with the Swedish national pension since its launch in the fall of 2000. More than 5 million customers take part in the system, representing every working person in Sweden born in 1938 and after. (The country's population is roughly 9 million.) A portion of every individual's employment tax, equal to 2.5 percent of his or her declared income, is set aside specifically for pension investment, and each person can choose up to 5 mutual funds from a list of 450 commercial funds approved by PPM. Combined, individual accounts exceed 6 billion in U.S. dollars.
Perl Wins the Comparison
Sandell has worked with GlobeCom's Henrik Johnson on several projects over the years, using Perl for system administration and Web development since 1994. They immediately considered using Perl for Pluto as well, mainly because the language facilitates rapid development. But the complexity of the pension application demanded they also look at other alternatives.
The new PPM agency needed a system that would help it manage individual accounts, aggregate the orders, buy the mutual funds, keep track of how many fund-parts each individual owns, and pay dividends to fund holders, among many other functions. Calculations had to be absolutely correct, with multiple layers of check programs, and in order for PPM to run batches in a reasonable amount of time, the system needed to process a large number of accounts per minute. "Traceability" was also a big concern. "We had to be able to examine calculations afterwards in order to answer questions such as, 'Why did customer A buy fund B on the 4th of March?'" Sandell explains.
Good database connectivity gave Perl the nod over C++, and since Sandell and Johnson received project text files in various formats, Perl's ability to parse text with regular expressions was much better than COBOL or Oracle's PL/SQL. And Perl 5's relative longevity provided the stability they required. The only question was performance, given that the processing speed of interpreted languages such as Perl is much slower than that of compiled languages like C++.
"That was an issue all along," Sandell notes, "and we made tests with large volumes from the start. The application seldom spends more than 20 percent of the time executing Perl code, while the database API and the database itself uses the other 80 percent. Even if we had an infinitely fast programming language, the overall performance would be only marginally better."
Convinced that processing speed wasn't a factor, Sandell and Johnson decided that Perl was best for the application. The toughest part was finding enough experienced developers in Sweden who knew Perl. The team sent requests to IT consulting firms (approved by PPM) throughout the country, and came up with a couple of good candidates, but they didn't get as many qualified programmers as they wanted.
So, although Pluto is written primarily in Perl, the team was forced to rely on other languages for various functions. They wrote the Web applications in Jscript, and other parts of the system in Visual Basic. Some functions were written in PL/SQL so they could be accessible from other languages using the system. "If we did the project again, we would probably strive to make more of it in Perl," Sandell concedes. But with so little time, they couldn't ask team members to learn a new language.
Learning Perl, 3rd Edition, has been updated to cover Perl Version 5.6 and rewritten to reflect the needs of programmers learning Perl today.
Ensuring a Smooth Transition
When it came to Perl, the team of four to six developers worked efficiently, programming on a Linux system and conducting peer reviews throughout the process. "One person would write the code and a second developer would check it," Sandell explains. "If the second developer could not understand the code, it was by definition incorrect and had to be improved, either through comments or, more often, through a rewrite since code that is hard to understand is often buggy."
The team--which included three project managers, three testers, two actuarials, and a lawyer to make sure the application was consistent with Swedish pension law--also had weekly deliveries of code for internal testing. Though these deliveries contained only part of the functionality, they had to be bug-free.
The testers would run the code through its paces and report whether any issues had been resolved from previous deliveries. "Perl proved to be a great language for doing the development," Sandell comments, adding that the interpreted language not only reduced development time, but it also avoided problems with different sources and binaries. "The one thing we missed in Perl was a numeric data type with high precision. Since we worked with billions of dollars and wanted to keep track of cents, we needed to have at least 13 digits for amounts. We ended up using scaled integers--storing $1.23 as 123--which worked fine, but having a data type like Oracle's Number (12,6) would have saved a lot of effort."
When PPM approved Pluto for the new pension system, the team moved the application from the Linux box to the Hewlett-Packard UX V2600 production machine, and with Perl's portability, the transition was smooth. Despite the accomplishment, Sandell is not completely satisfied with Pluto's performance overall.
"We would like the system to run about ten times faster," he insists. "We will try to achieve that using parallel batches in a future version. The limiting factor is not Perl, but Oracle." With Pluto in production more than six months, Sandell and Johnson are gradually turning over the maintenance to PPM's IT team. Now that they have proven Perl's worth in large and complex financial applications, they're looking to other countries that are considering market-based pension systems. The stock market may not be what it once was, but the investment made in this particular pension application has already paid tremendous dividends.
Learn how large and small companies are putting Perl to work by reading other Perl Success Stories.