Introducing COBOLOG the Common Business-Oriented Logic-Programming Language
Total Page:16
File Type:pdf, Size:1020Kb
Introducing COBOLOG The Common Business-Oriented Logic-programming language Michael Coulombe Electrical Engineering and Computer Science Department Massachusetts Institute of Technology 32 Vasser Street, Cambridge, MA [email protected] Abstract In addition to the organizations listed above, the following other orga- nizations participated in the work of the Maintenance Group: We introduce COBOLOG, a new cross-paradigm programming lan- guage. Inspired by two popular languages, COBOL and PROLOG, • Allstate Insurance Company we finally bring logic programming to the business community. • Bendix Corporation, Computer Division • 1. Introduction Control Data Corporation • Dupont Corporation COBOL, the Common Business Oriented Language, was released • General Electric Company in 1961 to much excitement as “COBOL 61” [17]. After a French grad student named Alain Colmerauer was tasked to write a syntax- • General Motors Corporation directed error detector for COBOL programs, he fled to Canada and • Lockheed Aircraft Corporation created PROLOG, “PROgrammation en LOGique” [7]. Computer • scientists have been split between academia and industry ever since. National Cash Register Company We celebrate the 60th anniversery of COBOL 61 by reunifying • Philco Corporation these two great languages, combining the best of the business- • Standard Oil Company (N. J.) oriented and logic-oriented programming paradigms for the first • United States Steel Corporation time in COBOLOG. In this paper, we will detail our new language and document the current progress on its implementation. This COBOL-61 manual is the result of contributions made by all of the above-mentioned organizations. No warranty, expressed or implied, is made 1.1 Mandatory COBOL Acknowledgements by any contributor or by the committee as to the accuracy and functioning of the programing system and language. Moreover, no responsibility is This publication is based on the COBOL System developed in 1959 by a committee composed of government users and computer manufacturers. assumed by any contributor, or by the cominittee, in connection therewith. The organizations participating in the original development were: It is reasonable to assume that a number of improvements and additions will be made to COBOL. Every effort will be made to insure that the • Air Materiel Command, United States Air Force improvements and corrections will be made in an orderly fashion, with due • National Bureau of Standards, U. S. Department of Commerce recognition of existing users’ investments in programing. However, t h i s protection can be positively assured only by individual implementors. • Burroughs Corporation Procedures have been established for the maintenance of COBOL. In- • David Taylor Model Basin, Bureau of Ships, U. S. Navy quiries concerning the procedures and the methods for proposing changes should be directed to the Executive Committee of the Conference on Data • Electronic Data Processing Division, Minneapolis-Hoimywell Regula- Systems Languages. tor Company The authors and copyright holders of the copyrighted material used • International Business Machines Corporation herein: FLOW-MATIC (Trade-mark of Sperry-Rand Corporation), Pro- graming for the UNIVAC® I and II, Data Automation Systems© 1958, • Radio Corporation of America 1959, Sperry-Rand Corporation; IBM Commercial Translator, Form No. • Sylvania Electric Products, Inc. F28-8013, copyrighted 1959 by IBM; FACT, DSI 27A5260-2760, copy- righted 1960 by Minneapolis-Honeywell, have specifically authorized the • Univac Division of Sperry-Rand Corporation use of this material, in whole or in part, in the COBOL specifications. Such authorization extends to the reproduction and use of COBOL specifications in programing manuals or similar publications. Any organization interested in reproducing the COBOL report and ini- Permission to make digital or hard copies of part or all of this work for personal or tial specifications in whole or in part, using ideas taken from this report classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation or utilizing this report as the basis for an instruction manual or any other on the first page. Copyrights for components of this work owned by others than purpose is free to do so. However, all such organizations are requested to ACM must be honored. Abstracting with credit is permitted. To copy otherwise, to reproduce this section as part of the introduction to the document. Those us- republish, to post on servers, or to redistribute to lists, contact the Owner/Author. ing a short passage, as in a book review, are requested to mention “COBOL” Request permissions from [email protected] or Publications Dept., ACM, Inc., fax +1 (212) 869-0481. Copyright held by Owner/Author. Publication Rights Licensed in acknowledgment of the source, but need not quote this entire section. to ACM. 1.2 Background Copyright © ACM [to be supplied]. $15.00 DOI: http://dx.doi.org/10.1145/(to come) COBOL was known as a difficult language from its inception, and even today mere mortals have trouble distinguishing their percep- In the wake of a world-wide pandemic, we believe time is ripe tions from the reality hiding behind their terminal [5]. Declassi- to loop back and disrupt the computer science community, giving fied documents show that in the 80’s, even DoD researchers could 110% for all the stakeholders by leveraging our core competency: only semi-automatically translate a subset of business programs creating new programming languages. into human-understandable language [10]. Some say COBOL was prophesized in 1928 by Hewlett-Packard Lovecraft before he 2. The COBOLOG Language started his successful technology company, which went on to de- velop its own COBOL compiler [19]: COBOLOG, short for the Common Business-Oriented Logic- programming language, combines a variety of aspects from COBOL The most merciful thing in the world, I think, is the inability and PROLOG, mixed with a tablespoon of modern innovations. of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas 2.1 Syntax of infinity, and it was not meant that we should voyage ACOBOLOG program is a collection of logical predicates on terms far. The sciences, each straining in its own direction, have and relations between them. Relations are defined by a set of hitherto harmed us little; but some day the piecing together clauses, typed like Pred :- Goal, which states that proving of dissociated knowledge will open up such terrifying vistas Goal is true is one way to prove Pred is true. A term is one of: of reality, and of our frightful position therein, that we shall either go mad from the revelation or flee from the deadly • Compound, a bunch of words each starting with lower-case light into the peace and safety of a new dark age. letters and possibly interspersed with other terms — HP Lovecraft, The Call of COBOL [14] • Variable, a bunch of words starting with upper-case letters Despite the success of COBOL, it was unable to stop the rise • Integer, written as contiguous base 10 digits of PROLOG. Its first interpretor was written for the sake of porta- • Operator expression, either nullary, prefix, infix, or postfix bility in FORTRAN, a unfortunate necessity of the time [7]. 80’s researchers could see the value in this language, but experiments • List, including finite ([4,2,0]), cyclical (L is [go|L]), and [ | ] with concurrently teaching PROLOG and PASCAL to “Business In- list prefixes with non-list tails ( A,B 666 ) formation Systems” majors in universities [12] just confused the • Indented block, each line containing a goal (predicate term) poor students greatly and left them unprepared for COBOL on the job. Here in the middle of the page is an example COBOLOG program: 1 main :- % this predicate is the one your computer will start trying to prove 2 the sum of [1,2,3,4] is The Sum % performs the predicate defined below 3 display The Sum % prints the sum, which is10, just like in COBOL 4 the sum of [] is0 % an empty list has sum zero 5 the sum of [The First Element|The Rest Of The List] is The Sum :- %a non-empty list is harder to check 6 the sum of The Rest Of The List is The Sum Of The Rest % performs this predicate recursively 7 add The First Element to The Sum Of The Rest giving The Sum % adds two numbers, like in COBOL So we are all on the same page (page2), below is an enterprise The above business-ready, game-changing COBOLOG program next-gen COBOL program for rockstars that computes the sum. proves that the list [1,2,3,4] has a sum then prints it to the screen for customer-centric convenience. It uses recursion, a feature not 1 *>**************************** present in COBOL 61 that we will cover in Section3. 2 *> Ph’nglui mglw’nafh COBOL ** We adopt a holistic approach with modern preferences ala 3 *>R’lyeh wgah’nagl fhtagn ** 4 *>**************************** PYTHON and others by writing the conjunction of goals in indented 5 IDENTIFICATION DIVISION. blocks (spaces only, of course) without line- or block-ending de- 6 PROGRAM-ID.SUM. limeters. We can start a line with the “\” character to continue the 7 DATA DIVISION. previous goal in the same block. 8 WORKING-STORAGE SECTION. Next, here is a premium free trial sneak peak of the conditional 9 01 LIST PIC9 OCCURS4 TIMES. predicate ifC thenT elseF . Currently, in COBOLOG, nested 10 01 LIST-LENGTH PIC9 VALUE4. goals must be written in a block to empower your computer to prove 11 01 CUR-SUM PIC99 VALUE0. them, helping you keep your ducks in a row. 12 01 CUR-POS PIC9 VALUE1. 13 PROCEDURE DIVISION. 1 % The Law of Identity(this is not legal advice) 14 000-MAIN SECTION. 2 A equalsA 15 MOVE1TO LIST(1).