|
With that
support, Fujitsu Software enhances the productivity of organizations
that use COBOL. Not only will COBOL programmers have access
to a wide variety of new technologies, including .NET class
libraries and ASP.NET, they will be able to work seamlessly
with developers of code in other languages, such as C++ and
Visual Basic. Instead of having a development organization
with a schism between COBOL programmers and other programmers,
the new environment allows programmers to bridge the barriers
using common interfaces and programming tools.
This article
discusses some of the important applications of this technology
for COBOL and what it takes for a programming language vendor,
such as Fujitsu Software, to deliver on the new vision.
COBOL
on the Web
With an increasing amount of business being conducted on the
Web, organizations everywhere are asking themselves how to
best take advantage of the enormous new business opportunities.
Businesses with lots of COBOL are even more concerned, since
most of their applications were built long before the Web
became the business phenomenon that it is today. These businesses
find that retraining their workforce to use other programming
languages as well as retooling their applications for the
Web is a daunting task. COBOL vendors, including Fujitsu,
have been selling a variety of solutions for migrating COBOL
applications to the Web. Fujitsu's support for the .NET Framework
builds on that position and takes several steps forward, allowing
COBOL programmers to program directly to the Web and to easily
use their existing legacy code.
ASP.NET
(language="COBOL")
ASP.NET is Microsoft's successor to Active Server Pages (ASP),
which was 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.
Fujitsu
COBOL is taking advantage of this important benefit by allowing
COBOL programmers to embed COBOL code in ASP.NET pages. The
following is a sample ASP.NET page written using COBOL that
displays "Welcome to ASP.NET (now in COBOL!)" in
increasing font sizes:


The <form> tag block surrounds the set of Web Forms
controls used in the page. The runat="server"
attribute indicates to ASP.NET that the behavior of the control
is implemented using code running on
the server. This example has four Web Forms controls, whose
names are specified using the "id" attribute:
- A select
control called "FruitList" that displays the list
of five fruits to choose from.
- An
unnamed input button. The "OnServerClick" attribute
specifies that the button has a programmed event associated
with clicking it. The value of the attribute gives the name
of the method that is the event handler-in this case "FruitList-Click."
- An
image control called "FruitImage" that is used
to display the image of the selected fruit.
- A
span control called "FruitName" that displays
the name of the selected fruit alongside the image.
.
This technology
enhances the programmability of Web pages and helps to overcome
limitations of static HTML technology. With this technology
you can imagine constructing sophisticated Web systems, including
applications like electronic storefronts, inventory management
systems, shipping management, and much more. Best of all,
these applications can be programmed using COBOL if that is
what your workforce is trained to use.
Web
Services: Programming the Web
While ASP.NET allows programmers to package dynamic content
onto server-side Web pages, Web Services go a step further.
They provide the opportunity to expose programming interfaces
to the Web for use by clients to package in any way they see
fit. This allows businesses to truly componentize their product
offerings in ways that end-users can customize to suit their
own applications.
The following
is an example of a very simple Web Service written in COBOL:
The example
is just a COBOL class definition with a method called "AddMe"
that adds two numbers together. The "WebService"
directive at the beginning tells the .NET Framework that we
want to expose methods as Web Services and identifies the
programming language in which the methods are written. (In
future versions, users will also use additional syntax to
specify the WebMethod custom attribute on those methods that
are to be exposed as Web Services.)
As simple
as this seems, a number of technologies all have to work together
for Web Services to function. For example, SOAP is a protocol
that is used for marshaling data using XML. SOAP is needed
for clients and servers to communicate their arguments and
results in a format that can ultimately be transmitted over
HTTP. Web Services Description Language (WSDL) is also needed
to describe the interfaces of the services being exposed and
DISCO provides clients the mechanism through which they can
discover those services.
Web Services
open up new opportunities for application deployment. Instead
of packaging business logic applications with wrappers that
predetermine the Web presentation style and content, companies
can expose their business logic as a Web Service to be customized
for use by their customers.
Frameworks
and Language Interoperability
The Microsoft .NET Framework SDK comes with frameworks that
implement a wide variety of operations, such as I/O, data
type manipulation, and graphical application development.
Because Fujitsu COBOL is targeting the .NET Framework, the
language in which these libraries are implemented is immaterial.
COBOL programs can use these features as if they were written
in COBOL. The infrastructure for this language interoperability
is a common language runtime.
The previous
ASP.NET fruit list example has already demonstrated some of
the uses of .NET frameworks. The COBOL method "FruitList-Click
" was embedded in a class that inherited from classes
in the .NET frameworks. This allowed direct access to inherited
properties. The "StringBuilder" class is another
example of a class from the .NET base class library. The following
sample shows the use of the Win Forms framework that allows
developers to construct Win32-based GUI applications:


This very
simple application brings up a frame window with the title
"Hello COBOL world!" It demonstrates inheritance
from the Win Forms "Form" class and use of methods
and properties in the Win Forms class library.
Migrating
COBOL Code to the Microsoft .NET Framework
The Microsoft .NET Framework provides interoperability between
code targeted for the Common Language Runtime, also known
as managed code, and existing native code and COM applications.
This means that developers can write new managed code that
makes calls to their existing code. In the case of existing
COM applications, this is as simple as using a type library
import tool (TLBIMP) that makes COM interfaces visible to
managed code. For other native code, users simply need to
provide a COBOL prototype declaration for the code they want
to call. To call from native code to managed code, developers
can use a type library exporter (TLBEXP) and an assembly registration
tool (REGASM) to export their managed code as COM objects.
Eventually,
users will also have the option of compiling their existing
code with the new compiler to run completely using the Common
Language Runtime. While Fujitsu Software is committed to enabling
this scenario, early releases of the compiler are likely to
not support all of COBOL's features.
Delivering
on the Vision
As the only COBOL vendor to currently target the new Microsoft
environment, Fujitsu Software has a commitment to a vision
of seamless interoperability and powerful programming tools.
The price of this commitment is the development of an enhanced
COBOL compiler with language extensions to support the new
platform, a completely new code generator targeting Microsoft's
Intermediate Language (IL), and ASP.NET support code for COBOL,
among other things.
Code samples
shown in this article are based on the implementation found
in the preview release of the compiler. The precise syntax
of COBOL language extensions shown here is subject to change
in released versions.
Language
Extensions
The Common Language Runtime is based heavily on an object-oriented
programming model. This does not mean that all programs that
run in the environment have to be object-oriented, but object-oriented
language constructs are needed to use some features of the
environment. The Fujitsu COBOL implementation will base much
of its object-oriented syntax on the current COBOL draft standard,
but will also introduce extensions to make it easier for COBOL
programmers to make effective use of the .NET Framework. This
includes extensions for .NET features, such as delegates and
custom attributes that do not have counterparts in the COBOL
draft standard.
Code
Generation
The Common Language Runtime achieves its goals of interoperability,
security, and robustness by operating on MSIL instead of native
code. This means that compilers that target the environment
have to develop new code generators that generate MSIL instead
of native code. The Common Language Runtime uses just-in-time
(JIT) compilation strategies to ultimately translate code
for the platform into fast native code.
Enhanced
interoperability also means that applications with code written
in different programming languages can also be seamlessly
debugged. This is an important productivity benefit, particularly
since most current development environments for COBOL (with
the exception of Fujitsu COBOL) make debugging cross-language
applications quite cumbersome.
ASP.NET
Support
In addition to a new compiler, language-specific support is
also required for the new ASP.NET infrastructure. Because
ASP.NET compiles its pages, it has to be able to generate
code to represent the HTML and ASP.NET content in the language
in which the page is written. For example, the "Welcome
to ASP.NET (now in COBOL!)" ASP.NET sample shown earlier
results in generated code that includes the following fragment:
The Future of COBOL
The long-term benefits of integration with the Microsoft .NET
Framework are that COBOL will more easily adapt to new technologies.
New frameworks that are developed for the .NET Framework (in
any programming language) immediately become accessible to
COBOL programmers. Fujitsu Software has always been committed
to ensuring that COBOL programmers have the tools they need
to develop applications using the latest technologies. Support
for the .NET Framework lends assurances to that commitment.
|