Belbinson Toby
Logica Pvt Ltd
Stockholm, Sweden
May 2010
Summary: Discusses why COBOL and .NET are strong partners and explains how Fujitsu COBOL has been integrated into the .NET Framework. (12 printed pages)
Contents
Introduction
Why COBOL for .NET Makes Sense
What COBOL for .NET Looks Like
Migrating COBOL Code to the .NET Framework
How COBOL for .NET is Implemented
Getting Started with COBOL for .NET
Introduction
Microsoft’s .NET Framework not only enables the vision of companies sharing Web Services but also establishes a whole new development and execution environment for applications – whether on or off the Web. With components winning awards even before their full release, .NET is truly the latest and greatest happening in the application development world. COBOL, on the other hand, has been around almost from the beginning of business applications on computers and is unlikely to be mentioned by anyone talking about the “latest and greatest”. Why, then, have Microsoft and Fujitsu Software expended considerable effort in bringing these two technologies together? Has it been possible to integrate the “old” and “new” in a worthwhile manner? Does this combination of COBOL and .NET have anything to offer you, and how easy is it going to be for you to take advantage of those benefits?
This paper aims to answer these questions for you firstly by laying out why the .NET Framework is attractive to business applications and COBOL programmers, and what COBOL has to offer to .NET. It will then give you a feel for COBOL for .NET by showing you what it looks like in different .NET technologies such as ASP.NET, Web Services and class sharing, explaining how you might use COBOL in each of these areas. It will give you an insight into what was done to make COBOL work in the .NET environment and conclude by describing how you can experience COBOL for .NET yourself.
Why COBOL for .NET Makes Sense
To understand why COBOL and .NET come together well, it is best to start with what COBOL has to offer. The reasons that COBOL runs over 70% of the world’s production business applications are that it has always provided:
•Record-oriented data structures
•Built-in business-oriented data types: alphanumeric, alphanumeric-edited, decimal, numeric-edited, and packed-decimal.
•Simple control flow constructs
•Readable and maintainable code
Although often put down by speedy programmers, COBOL’s verbosity has been a big part of it providing readable and maintainable code. Maintainable code is a critical feature for business applications that can have life spans of many decades. Consider if you are in the position of committing your company’s core business processes to a programming language – do you want to select the “in” language of the moment which history has shown will be “out” in 10 years’ time, or do you want to select a language that has a 40 year track record, and which any programmer can understand?
Another factor in favor of using COBOL for business logic, is that COBOL programmers typically have a lot of experience in supporting business needs. Their focus tends to be more on implementing the business functions rather than getting into the latest technology (just because it’s the latest).
However, businesses still need to take advantage of the latest technology as this can often give them their competitive advantage or ensure that they aren’t disadvantaged relative to the competition. This, if anything, has been COBOL’ s weakness in the last decade – it has not always been able to take advantage of the latest technologies as the interfaces or architectures have not been accessible to COBOL.
The .NET Framework changes all this. Web applications need a secure, managed environment in which to operate. In providing this Microsoft decided not just to create an environment that supported a single programming language, but to create an environment that was capable of supporting all programming languages, and to extend it so that it could support console, Windows GUI, and Web HTML styles of applications as well as the typically interface-less Web services. Figure 1 gives an overview of what the .NET Framework provides.
This figure shows how Visual Studio .NET provides a common development environment for programming. Any language, such as COBOL, which is enabled for that development environment, can be developed with language-sensitive features including highlighting of text, project building and debugging. Then the code is compiled into a standard intermediate language called Microsoft Intermediate Language (MSIL) that is executed by the Common Language Run-time (CLR) in a secure, managed environment. MSIL is platform independent and is compiled to native code by the part of the run-time loading software.
One big benefit of the common execution environment is that its design is such that classes can be inherited from one language to another. .NET includes several frameworks, or libraries of classes, that any .NET language can use, including COBOL.
The net result is that .NET offers an environment in which you develop in the language that makes most sense for the task.
Now it should be obvious how COBOL can benefit from being a full player in the .NET framework. COBOL gets:
•An award winning development environment (Visual Studio .NET) that is designed for creating .NET applications.
•The ability to inherit the latest technologies from the framework classes.
•The option to invoke code written in other languages in a seamless manner, whenever that code provides useful functionality.
•The ability to support application needs wherever MSIL is supported - such as in ASP.NET pages and Web services.
.NET benefits too by gaining:
•The language that is best for many business logic implementations
•The ability to execute the valuable business logic contained in around 200 billion lines of COBOL code worldwide (Gartner Group estimate)
•The business expertise of hundreds of thousands of COBOL programmers
Thus COBOL and .NET make a strong partnership; one that is worth exploring to see how you can exploit it to your company's advantage.
What COBOL for .NET Looks Like
To show you what COBOL looks like in the .NET Framework this paper presents three examples of COBOL code in different .NET areas:
•Within an ASP.NET page, illustrating the provision of dynamic Web content using COBOL
•As a Web Service, demonstrating how simple it can be to package existing modules as Web services.
•Within the GUI Framework, showing how COBOL can inherit from other languages and how OO COBOL has been adapted to fit the object oriented .NET architecture.
ASP.NET (language="COBOL")
ASP.NET is the Microsoft successor to Active Server Pages (ASP), which were designed to deliver dynamic Web content. ASP faced a number of weaknesses in the areas of performance and programmability, and ASP.NET makes substantial improvements in those areas. Instead of being interpreted like ASP, ASP.NET compiles pages to native code. This change results in enormous performance benefits, with only a one-time cost to compile the page when it is first deployed. The other important side effect of the design choice (to compile instead of interpret) is that it opens the door for compiled languages to provide code in ASP.NET pages.
ASP.NET Example 1
The following is a sample ASP.NET page written using COBOL that displays "Welcome to ASP.NET (now in COBOL!)" in increasing font sizes:
<%@ page language="COBOL" %>
<script runat="server">
OBJECT.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 Font-Size PIC S9(9) COMP-5.
END OBJECT.
</script>
<% PERFORM VARYING Font-Size FROM 1 BY 1 UNTIL Font-Size > 7 %>
<font size="<%=Font-Size%>"> Welcome to ASP.NET (now in COBOL!) </font>
<br>
<% END-PERFORM. %>
The "<%@" characters introduce the directive that allow us to set the programming language for the page to COBOL. The <script> block allows us to introduce COBOL code that declares the FONT-SIZE variable and the characters "<%" allow us to introduce inline COBOL code to loop over the HTML that displays "Welcome to ASP.NET (now in COBOL!)"
Fujitsu COBOL takes advantage of this important benefit by allowing COBOL programmers to embed COBOL code in ASP.NET pages.

0 Response to "COBOL for Microsoft .NET Framework"
Post a Comment