SlideShare a Scribd company logo
1 of 18
Object Oriented Programming
        with COBOL
          Robert Sales
        Technical Architect
What is COBOL?

• ANS85 COBOL
   – Remains the current standard for structure procedural COBOL
     programming.
   – Some features rarely used (nested programs?), but widely
     accepted and respected as an industry standard


• Mainframe variants
• Micro Focus, ACU, RM, Realia etc. etc.
• ISO2002




                  2
What is COBOL’s future?

• Accept that COBOL is essentially a procedural
  programming language
• Embrace modern platforms and modern programming
  practices and make it easy for COBOL to participate.




                         3
Option 1: COBOL as procedural language

• Widely used
• Portable (except for the plethora of different dialects)
• Efficient
• BUT
• MUCH less efficient development environment than
  those offered by modern platforms such as .NET and
  Java
• Dwindling numbers of COBOL programmers




                            4
Option 2: embrace modern platforms

• Far greater programming productivity
• Seamless integration into modern programming
  platforms
• BUT...
• Can mean that programs are completely tied down to a
  single platform




                         5
So where do we go from here?

• Two current major development platforms
   – .NET
   – Java/JVM



   – Allow fullest possible use of all features of target framework...
   – But at the same time allow for the greatest possible degree of
     portability.




                                6
Accessing .NET/JVM classes

• To access a .NET or JVM type (i.e. a class, interface, enum etc.),
  use the TYPE keyword followed by the name of the type.
• To access members of a type, use :: following the name of a type or
  an instance.

•   So, to define a data item to be an instance of a type:
•   01 fred type System.String value “Hello world”.
•   Accessing instance method:
•   Display fred::Replace(“world”, “Dallas”)
•   Accessing instance property:
•   Display fred::Length
•   Accessing static method:
•   Display type System.String::Concat(fred, “ Texas”)




                                  7
Non-portable example

01 s1 type System.String value “Hello world”.
display s1::Substring(4) *> .NET System.String methods
display s1::Substring(6, 5)
display string::Concat (s1, “ and goodbye”)

01 s1 type java.lang.String value “Hello world”.
display s1::substring(4) *> Java java.lang.String methods
display s1::substring(6, 11)
display s1::concat (“ and goodbye”)



                          8
Portable example

• 01 s1 string value “Hello world”.
  display s1(5:)       *> using reference modification
  display s1(7:5)
  display s1 & “ and goodbye” *> using concatenation




                          9
New in 2.0 - Portable syntax for accessing lists and
dictionaries
• Uses i-o verbs WRITE, READ, REWRITE AND DELETE
  to make it possible to write code using these collection
  classes, which is portable between .NET and JVM.
• LIST and DICTIONARY become predefined types (in a
  similar way to STRING and DECIMAL), which allow the
  compiler to map implicitly onto the appropriate .NET or
  JVM type.
• Specialized iteration syntax to normalize iteration
  through dictionaries




                          10
New in 2.0 – inline declaration of local variables

• Can now declare local variables within the body of a method’s
  (or procedural COBOL’s) procedure division
• Method-id m.
• Procedure division.
• declare i1 as binary-long = 3
• display i1
• perform varying i2 as binary-long from 1 by 1 until i2 = 8
•    display i2
• end-perform
• perform varying s as string through string-collection
•    display s
• end-perform


                            11
New in 2.0 – access to indexers

• In .NET, an indexer is a kind of property, except that
  unlike a normal property it has parameters.
• It has a fixed name, and the idea is that you can access
  the indexer using subscript-like syntax on a type
  instance. We use square brackets to access indexers.

01 myList list[string].
01 myDict Dictionary[string string].
   display myList[0] *> use indexer to access 1st element
   display myDict[“Max”] *> access value with key “Max”


                          12
New in 2.0 – zero based subscripting using [...]

• For consistency with the use of [...] to access indexers,
  we also allow the use of square brackets to do standard
  table access but zero based as opposed to one based.
• 01 myArray string occurs 10.
• 01 myList list[string].
•   display myArray[0] *> first element of array
• equivalent to...
•   display myArray(1)

•    display myList[0]    *> first list element (via indexer)


                          13
New in 2.0 – declaring properties and indexers

•   PROPERTY-ID typespecifier
•   PROCEDURE DIVISION.
•   GETTER.
•   ...
•   SETTER.
•   ...
•   END PROPERTY.




                         14
New in 2.0 – declaring indexers

•   INDEXER-ID typespecifier
•   PROCEDURE DIVISION USING BY VALUE ...
•   GETTER.
•   ...
•   SETTER.
•   ...
•   END INDEXER.




                       15
In progress for 2.1 – simplified syntax for delegate
creation.
• Instead of:
• 01 d type MyDelegate.
•     set d to new MyDelegate(self::m)
• ...the method can be converted directly to a suitable
  delegate type:
•     set d to method self::m
• Similarly for anonymous methods:
•     set d to delegate display “Hello world” end-delegate
• ...instead of:
• set d to new MyDelegate(delegate display “Hello world”
  end-delegate)


                          16
In progress for 2.1 – delegates and events on JVM

• Unlike .NET, JVM has no direct support for delegates (or
  events, which are based on delegates).
• We hope to make further progress on the goal of
  portable language by enabling use of delegates in JVM,
  but details of implementation are not yet tied down.




                          17
Object Oriented Programming with COBOL

More Related Content

What's hot

2017: Kotlin - now more than ever
2017: Kotlin - now more than ever2017: Kotlin - now more than ever
2017: Kotlin - now more than everKai Koenig
 
C++ to java
C++ to javaC++ to java
C++ to javaAjmal Ak
 
Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Chicago Hadoop Users Group
 
Messages from Perl
Messages from PerlMessages from Perl
Messages from PerlHanae Aoki
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivitynklmish
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++PRINCE KUMAR
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java introkabirmahlotra
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyHaim Yadid
 
web programming Unit VI PPT by Bhavsingh Maloth
web programming Unit VI PPT  by Bhavsingh Malothweb programming Unit VI PPT  by Bhavsingh Maloth
web programming Unit VI PPT by Bhavsingh MalothBhavsingh Maloth
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Sanjit Shaw
 
Coding for Android on steroids with Kotlin
Coding for Android on steroids with KotlinCoding for Android on steroids with Kotlin
Coding for Android on steroids with KotlinKai Koenig
 
Binding Objective-C Libraries, Miguel de Icaza
Binding Objective-C Libraries, Miguel de IcazaBinding Objective-C Libraries, Miguel de Icaza
Binding Objective-C Libraries, Miguel de IcazaXamarin
 
Apache Avro and Messaging at Scale in LivePerson
Apache Avro and Messaging at Scale in LivePersonApache Avro and Messaging at Scale in LivePerson
Apache Avro and Messaging at Scale in LivePersonLivePerson
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++Rabin BK
 
F# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformF# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformHoward Mansell
 
S1 DML Syntax and Invocation
S1 DML Syntax and InvocationS1 DML Syntax and Invocation
S1 DML Syntax and InvocationArvind Surve
 

What's hot (18)

2017: Kotlin - now more than ever
2017: Kotlin - now more than ever2017: Kotlin - now more than ever
2017: Kotlin - now more than ever
 
C++ to java
C++ to javaC++ to java
C++ to java
 
Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416
 
C++vs java
C++vs javaC++vs java
C++vs java
 
Messages from Perl
Messages from PerlMessages from Perl
Messages from Perl
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java intro
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
web programming Unit VI PPT by Bhavsingh Maloth
web programming Unit VI PPT  by Bhavsingh Malothweb programming Unit VI PPT  by Bhavsingh Maloth
web programming Unit VI PPT by Bhavsingh Maloth
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
Coding for Android on steroids with Kotlin
Coding for Android on steroids with KotlinCoding for Android on steroids with Kotlin
Coding for Android on steroids with Kotlin
 
Binding Objective-C Libraries, Miguel de Icaza
Binding Objective-C Libraries, Miguel de IcazaBinding Objective-C Libraries, Miguel de Icaza
Binding Objective-C Libraries, Miguel de Icaza
 
Apache Avro and Messaging at Scale in LivePerson
Apache Avro and Messaging at Scale in LivePersonApache Avro and Messaging at Scale in LivePerson
Apache Avro and Messaging at Scale in LivePerson
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
 
F# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformF# Type Provider for R Statistical Platform
F# Type Provider for R Statistical Platform
 
S1 DML Syntax and Invocation
S1 DML Syntax and InvocationS1 DML Syntax and Invocation
S1 DML Syntax and Invocation
 

Similar to Object Oriented Programming with COBOL

Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryPray Desai
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternNitin Bhide
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageAzilen Technologies Pvt. Ltd.
 
Introduction to .NET
Introduction to .NETIntroduction to .NET
Introduction to .NETJoni
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovypaulbowler
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)lennartkats
 
OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Foundation
 
CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)Dilawar Khan
 
.Net programming with C#
.Net programming with C#.Net programming with C#
.Net programming with C#NguynSang29
 
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...AboutYouGmbH
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologiesprakashk453625
 
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a serviceCOMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a serviceAntonio García-Domínguez
 

Similar to Object Oriented Programming with COBOL (20)

Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design pattern
 
Comp102 lec 3
Comp102   lec 3Comp102   lec 3
Comp102 lec 3
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming language
 
Objc
ObjcObjc
Objc
 
Introduction to .NET
Introduction to .NETIntroduction to .NET
Introduction to .NET
 
Stoop 305-reflective programming5
Stoop 305-reflective programming5Stoop 305-reflective programming5
Stoop 305-reflective programming5
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovy
 
Kubernetes @ meetic
Kubernetes @ meeticKubernetes @ meetic
Kubernetes @ meetic
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
 
OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Csharp
CsharpCsharp
Csharp
 
CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)
 
.Net programming with C#
.Net programming with C#.Net programming with C#
.Net programming with C#
 
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
 
Objective-C
Objective-CObjective-C
Objective-C
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
 
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a serviceCOMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
 

More from Micro Focus

North America Strategic Modernization Exec Forum
North America Strategic Modernization Exec Forum North America Strategic Modernization Exec Forum
North America Strategic Modernization Exec Forum Micro Focus
 
Tech Channel COBOL ebook
Tech Channel COBOL ebookTech Channel COBOL ebook
Tech Channel COBOL ebookMicro Focus
 
Unlocking COBOL Business Value
Unlocking COBOL Business ValueUnlocking COBOL Business Value
Unlocking COBOL Business ValueMicro Focus
 
Quietly confident, enduringly competent - COBOL.
Quietly confident, enduringly competent - COBOL. Quietly confident, enduringly competent - COBOL.
Quietly confident, enduringly competent - COBOL. Micro Focus
 
5 key capabilitie for a smart service desk solution infographic
5 key capabilitie for a smart service desk solution infographic5 key capabilitie for a smart service desk solution infographic
5 key capabilitie for a smart service desk solution infographicMicro Focus
 
SAP Fortify by Micro Focus.
SAP Fortify by Micro Focus. SAP Fortify by Micro Focus.
SAP Fortify by Micro Focus. Micro Focus
 
Digital Transformation pillars 2020
Digital Transformation pillars 2020Digital Transformation pillars 2020
Digital Transformation pillars 2020Micro Focus
 
Whats new in Enterprise 5.0 Product Suite
Whats new in Enterprise 5.0 Product SuiteWhats new in Enterprise 5.0 Product Suite
Whats new in Enterprise 5.0 Product SuiteMicro Focus
 
Micro Focus Corporate Overview
Micro Focus Corporate OverviewMicro Focus Corporate Overview
Micro Focus Corporate OverviewMicro Focus
 
Why attend the application modernization & connectivity track at Micro Focus ...
Why attend the application modernization & connectivity track at Micro Focus ...Why attend the application modernization & connectivity track at Micro Focus ...
Why attend the application modernization & connectivity track at Micro Focus ...Micro Focus
 
Micro Focus #DevDay50 - Atlanta
Micro Focus #DevDay50 - AtlantaMicro Focus #DevDay50 - Atlanta
Micro Focus #DevDay50 - AtlantaMicro Focus
 
Growth of Internet Data - 2017
Growth of Internet Data - 2017Growth of Internet Data - 2017
Growth of Internet Data - 2017Micro Focus
 
Easily Create Scalable Automation using Selenium
Easily Create Scalable Automation using SeleniumEasily Create Scalable Automation using Selenium
Easily Create Scalable Automation using SeleniumMicro Focus
 
The Journey to Mainframe DevOps
The Journey to Mainframe DevOpsThe Journey to Mainframe DevOps
The Journey to Mainframe DevOpsMicro Focus
 
Micro Focus extend 10 and 10.1 with AcuToWeb
Micro Focus extend 10 and 10.1 with AcuToWebMicro Focus extend 10 and 10.1 with AcuToWeb
Micro Focus extend 10 and 10.1 with AcuToWebMicro Focus
 
The COBOL Story by Wim Ebbinkhuijsen
The COBOL Story by Wim EbbinkhuijsenThe COBOL Story by Wim Ebbinkhuijsen
The COBOL Story by Wim EbbinkhuijsenMicro Focus
 
DevDay Copenhagen - Micro Focus overview and introduction
DevDay Copenhagen - Micro Focus overview and introductionDevDay Copenhagen - Micro Focus overview and introduction
DevDay Copenhagen - Micro Focus overview and introductionMicro Focus
 
The DevOps Journey
The DevOps JourneyThe DevOps Journey
The DevOps JourneyMicro Focus
 
ACUCOBOL - Product Strategy and Roadmap
ACUCOBOL - Product Strategy and RoadmapACUCOBOL - Product Strategy and Roadmap
ACUCOBOL - Product Strategy and RoadmapMicro Focus
 
#DevDay Copenhagen - Bluegarden Presentation
#DevDay Copenhagen - Bluegarden Presentation #DevDay Copenhagen - Bluegarden Presentation
#DevDay Copenhagen - Bluegarden Presentation Micro Focus
 

More from Micro Focus (20)

North America Strategic Modernization Exec Forum
North America Strategic Modernization Exec Forum North America Strategic Modernization Exec Forum
North America Strategic Modernization Exec Forum
 
Tech Channel COBOL ebook
Tech Channel COBOL ebookTech Channel COBOL ebook
Tech Channel COBOL ebook
 
Unlocking COBOL Business Value
Unlocking COBOL Business ValueUnlocking COBOL Business Value
Unlocking COBOL Business Value
 
Quietly confident, enduringly competent - COBOL.
Quietly confident, enduringly competent - COBOL. Quietly confident, enduringly competent - COBOL.
Quietly confident, enduringly competent - COBOL.
 
5 key capabilitie for a smart service desk solution infographic
5 key capabilitie for a smart service desk solution infographic5 key capabilitie for a smart service desk solution infographic
5 key capabilitie for a smart service desk solution infographic
 
SAP Fortify by Micro Focus.
SAP Fortify by Micro Focus. SAP Fortify by Micro Focus.
SAP Fortify by Micro Focus.
 
Digital Transformation pillars 2020
Digital Transformation pillars 2020Digital Transformation pillars 2020
Digital Transformation pillars 2020
 
Whats new in Enterprise 5.0 Product Suite
Whats new in Enterprise 5.0 Product SuiteWhats new in Enterprise 5.0 Product Suite
Whats new in Enterprise 5.0 Product Suite
 
Micro Focus Corporate Overview
Micro Focus Corporate OverviewMicro Focus Corporate Overview
Micro Focus Corporate Overview
 
Why attend the application modernization & connectivity track at Micro Focus ...
Why attend the application modernization & connectivity track at Micro Focus ...Why attend the application modernization & connectivity track at Micro Focus ...
Why attend the application modernization & connectivity track at Micro Focus ...
 
Micro Focus #DevDay50 - Atlanta
Micro Focus #DevDay50 - AtlantaMicro Focus #DevDay50 - Atlanta
Micro Focus #DevDay50 - Atlanta
 
Growth of Internet Data - 2017
Growth of Internet Data - 2017Growth of Internet Data - 2017
Growth of Internet Data - 2017
 
Easily Create Scalable Automation using Selenium
Easily Create Scalable Automation using SeleniumEasily Create Scalable Automation using Selenium
Easily Create Scalable Automation using Selenium
 
The Journey to Mainframe DevOps
The Journey to Mainframe DevOpsThe Journey to Mainframe DevOps
The Journey to Mainframe DevOps
 
Micro Focus extend 10 and 10.1 with AcuToWeb
Micro Focus extend 10 and 10.1 with AcuToWebMicro Focus extend 10 and 10.1 with AcuToWeb
Micro Focus extend 10 and 10.1 with AcuToWeb
 
The COBOL Story by Wim Ebbinkhuijsen
The COBOL Story by Wim EbbinkhuijsenThe COBOL Story by Wim Ebbinkhuijsen
The COBOL Story by Wim Ebbinkhuijsen
 
DevDay Copenhagen - Micro Focus overview and introduction
DevDay Copenhagen - Micro Focus overview and introductionDevDay Copenhagen - Micro Focus overview and introduction
DevDay Copenhagen - Micro Focus overview and introduction
 
The DevOps Journey
The DevOps JourneyThe DevOps Journey
The DevOps Journey
 
ACUCOBOL - Product Strategy and Roadmap
ACUCOBOL - Product Strategy and RoadmapACUCOBOL - Product Strategy and Roadmap
ACUCOBOL - Product Strategy and Roadmap
 
#DevDay Copenhagen - Bluegarden Presentation
#DevDay Copenhagen - Bluegarden Presentation #DevDay Copenhagen - Bluegarden Presentation
#DevDay Copenhagen - Bluegarden Presentation
 

Object Oriented Programming with COBOL

  • 1. Object Oriented Programming with COBOL Robert Sales Technical Architect
  • 2. What is COBOL? • ANS85 COBOL – Remains the current standard for structure procedural COBOL programming. – Some features rarely used (nested programs?), but widely accepted and respected as an industry standard • Mainframe variants • Micro Focus, ACU, RM, Realia etc. etc. • ISO2002 2
  • 3. What is COBOL’s future? • Accept that COBOL is essentially a procedural programming language • Embrace modern platforms and modern programming practices and make it easy for COBOL to participate. 3
  • 4. Option 1: COBOL as procedural language • Widely used • Portable (except for the plethora of different dialects) • Efficient • BUT • MUCH less efficient development environment than those offered by modern platforms such as .NET and Java • Dwindling numbers of COBOL programmers 4
  • 5. Option 2: embrace modern platforms • Far greater programming productivity • Seamless integration into modern programming platforms • BUT... • Can mean that programs are completely tied down to a single platform 5
  • 6. So where do we go from here? • Two current major development platforms – .NET – Java/JVM – Allow fullest possible use of all features of target framework... – But at the same time allow for the greatest possible degree of portability. 6
  • 7. Accessing .NET/JVM classes • To access a .NET or JVM type (i.e. a class, interface, enum etc.), use the TYPE keyword followed by the name of the type. • To access members of a type, use :: following the name of a type or an instance. • So, to define a data item to be an instance of a type: • 01 fred type System.String value “Hello world”. • Accessing instance method: • Display fred::Replace(“world”, “Dallas”) • Accessing instance property: • Display fred::Length • Accessing static method: • Display type System.String::Concat(fred, “ Texas”) 7
  • 8. Non-portable example 01 s1 type System.String value “Hello world”. display s1::Substring(4) *> .NET System.String methods display s1::Substring(6, 5) display string::Concat (s1, “ and goodbye”) 01 s1 type java.lang.String value “Hello world”. display s1::substring(4) *> Java java.lang.String methods display s1::substring(6, 11) display s1::concat (“ and goodbye”) 8
  • 9. Portable example • 01 s1 string value “Hello world”. display s1(5:) *> using reference modification display s1(7:5) display s1 & “ and goodbye” *> using concatenation 9
  • 10. New in 2.0 - Portable syntax for accessing lists and dictionaries • Uses i-o verbs WRITE, READ, REWRITE AND DELETE to make it possible to write code using these collection classes, which is portable between .NET and JVM. • LIST and DICTIONARY become predefined types (in a similar way to STRING and DECIMAL), which allow the compiler to map implicitly onto the appropriate .NET or JVM type. • Specialized iteration syntax to normalize iteration through dictionaries 10
  • 11. New in 2.0 – inline declaration of local variables • Can now declare local variables within the body of a method’s (or procedural COBOL’s) procedure division • Method-id m. • Procedure division. • declare i1 as binary-long = 3 • display i1 • perform varying i2 as binary-long from 1 by 1 until i2 = 8 • display i2 • end-perform • perform varying s as string through string-collection • display s • end-perform 11
  • 12. New in 2.0 – access to indexers • In .NET, an indexer is a kind of property, except that unlike a normal property it has parameters. • It has a fixed name, and the idea is that you can access the indexer using subscript-like syntax on a type instance. We use square brackets to access indexers. 01 myList list[string]. 01 myDict Dictionary[string string]. display myList[0] *> use indexer to access 1st element display myDict[“Max”] *> access value with key “Max” 12
  • 13. New in 2.0 – zero based subscripting using [...] • For consistency with the use of [...] to access indexers, we also allow the use of square brackets to do standard table access but zero based as opposed to one based. • 01 myArray string occurs 10. • 01 myList list[string]. • display myArray[0] *> first element of array • equivalent to... • display myArray(1) • display myList[0] *> first list element (via indexer) 13
  • 14. New in 2.0 – declaring properties and indexers • PROPERTY-ID typespecifier • PROCEDURE DIVISION. • GETTER. • ... • SETTER. • ... • END PROPERTY. 14
  • 15. New in 2.0 – declaring indexers • INDEXER-ID typespecifier • PROCEDURE DIVISION USING BY VALUE ... • GETTER. • ... • SETTER. • ... • END INDEXER. 15
  • 16. In progress for 2.1 – simplified syntax for delegate creation. • Instead of: • 01 d type MyDelegate. • set d to new MyDelegate(self::m) • ...the method can be converted directly to a suitable delegate type: • set d to method self::m • Similarly for anonymous methods: • set d to delegate display “Hello world” end-delegate • ...instead of: • set d to new MyDelegate(delegate display “Hello world” end-delegate) 16
  • 17. In progress for 2.1 – delegates and events on JVM • Unlike .NET, JVM has no direct support for delegates (or events, which are based on delegates). • We hope to make further progress on the goal of portable language by enabling use of delegates in JVM, but details of implementation are not yet tied down. 17