Native COBOL Compared to .NET COBOL

You can use Enterprise Developer for Visual Studio 2017 to create both native and .NET COBOL applications. Native COBOL applications compile as native COBOL code that runs in Enterprise Server. .NET COBOL applications compile for .NET (the .NET Framework or the .NET Core) and can interoperate with other .NET applications regardless of the programming language in which they are written.

Background to .NET Framework and .NET Core

Microsoft's .NET Framework is a language-independent programming model that simplifies the process of building distributed applications. Any programs written for .NET can interact with one another, regardless of the programming language in which the programs were written.

The .NET Framework has two core components:

  • The Common Language Runtime (CLR). The CLR is responsible for run-time code management, undertaking such tasks as memory and thread management, and security enforcement. Programs that are written to make use of the CLR are known as managed code. Programs that do not make use of the CLR are known as unmanaged code.
  • The .NET Framework class library. The class library is an object-oriented collection of types that are closely integrated with the CLR. By inheriting functionality defined in the .NET Framework class library, you can reduce the amount of code you need to write.

.NET Core is a newer offering of Microsoft, a successor of the .NET Framework. It's an open-source development platform that supports multiple operating systems. As such, when you develop a COBOL application and publish it to .NET Core, you can deploy the published application to any operating system for which Micro Focus provides .NET Core support - currently, on Windows and Linux.

.NET Core includes a subset of the functionality of the .NET Framework - the .NET Framework Base Class Library and the CoreCLR which is a subset of the .NET Framework CLR.

For more information on .NET, go to the Microsoft .NET Web site:

Extra information in our docs also available:

.NET code

.NET code compiles to Microsoft Intermediate Language (MSIL or IL). The IL is stored in an assembly, along with meta data that describes the classes, methods, and attributes (such as security requirements) of the code you've created.

.NET code runs in the Microsoft Common Language Runtime (CLR) or the CoreCLR. The CLR does Just In Time (JIT) compilation. That is, when you load an assembly, the CLR JITs the assembly code the first time it is executed. There is a small performance penalty as an application loads, but because the CLR compiles your code, it doesn't do it again (until next time you restart it).

The CLR is responsible for managing your application code at run time, and provides security, memory management and so on.

Native COBOL Compared with .NET COBOL

Native COBOL and .NET COBOL differ in how they compile and how the run-time management services, such as security, threading and memory management are provided.

Native COBOL:

Procedural COBOL is regular COBOL without syntax features which take advantage of the .NET CLR. Procedural COBOL is still actively supported today and is being enhanced. Since the days of Net Express, Server Express, and Mainframe Express, it now supports inline local declarations (as in DECLARE). It also supports new syntax such as XML PARSE, JSON GENERATE, UTF-8, and more.

You can compile to native or (in most cases) .NET COBOL. The core COBOL syntax is supported in .NET COBOL. However, there are some features that are not supported (for example Panels V2, Dialog System and ACUCOBOL-GT). This means that you can take most existing COBOL applications and recompile to create .NET COBOL applications.

.NET COBOL:

.NET COBOL is COBOL with extensions to support the .NET Framework and .NET Core. It offers OO syntax support and syntax to allow access to the available class libraries.

When you compile .NET COBOL, the Compiler generates .NET code: .il for the .NET framework and the .NET Core.

.NET COBOL on the .NET platform compiles to Microsoft Intermediate Language (IL), and native COBOL compiles to machine code. Both .NET COBOL and native COBOL can run on any supported Windows platform when compiled.

Developing Native and .NET COBOL Applications

You can use Visual Studio to develop, compile and debug your applications, for both native and .NET COBOL.

You can write new COBOL code or you can recompile existing COBOL as either .NET COBOL or native code, potentially without any code changes.

Compilation

.NET COBOL:

You can compile your COBOL program to .NET COBOL code using the ILGEN compiler directive. If using Visual Studio, this happens automatically if you are using a .NET COBOL project.

The compiler creates an .exe or a .dll file that contains an intermediate language (.il). COBOL and all other .NET languages (for example C# and VB) compile to this format, which makes mixed language applications easy to write.

Native COBOL:

You can also create native code applications. In Visual Studio, there are native COBOL project templates.

The compiler generates .exe or .dll files as a result of a native compilation.

Deployment and Run Time

Native COBOL:

You can deploy and further debug the native application under the run-time system provided by Enterprise Server. The management services are provided by the COBOL Run-Time System via CBL_APIs.

.NET COBOL:

.NET COBOL applications are deployed to Windows platforms running the .NET Framework or on Windows or Linux if the applications target the .NET Core.

For .NET COBOL applications created by projects targeting the .NET Framework, the management services are provided by the Microsoft Common Language Runtime (CLR). The CLR provides management services such as exception handling, garbage collection, and thread management.

The intermediate language (.exe or .dll files) can be deployed to a Windows platform running Microsoft's Common Language Runtime (CLR) for execution.

All programs written for the .NET Framework are executed by the Microsoft's Common Language Runtime (CLR) which makes mixed language application programming seamless.

The CLR's just-in-time (JIT) compiler compiles the IL code into code native to the operating system. The CLR provides additional services including memory management, exception handling, garbage collection and thread management.

For applications targeting .NET Core, the management services are provided by the CoreCLR. The .NET Core libraries and run-time files must be made available either in side the deployed application ( a self-contained deployment (SCD), or on the system onto which you deploy your application (a framework-dependent deployment (FDD).

Native OO COBOL and .NET COBOL considerations

Certain technologies supported in native OO COBOL are not supported in .NET COBOL. In such scenarios, you might need to continue using native OO COBOL code - for example:

  • Native COBOL applications use COM technology
  • Native COBOL applications that call JAVA.
  • If you need to extend your existing Dialog System applications.
  • Your applications use the GUI/OLE class library and automation.
  • Your applications use the Microsoft transition server (MTS via COM services).