BETWEEN PROGRAMMING LANGUAGES Toward Solutions to Problems of Diversity
Total Page:16
File Type:pdf, Size:1020Kb
BETWEEN PROGRAMMING LANGUAGES Toward Solutions to Problems of Diversity A thesis submitted in partial fulfilment of the requirements for the Degree of Doctor of Philosophy in Computer Science in the University of Canterbury by Robert Lewis Biddle University of Canterbury 1987 PHYSICAL SCIENCES LIBRARY THESIS Preface I began this project with a great deal of idealism, having decided that there wa~ a topic in Computer Science that interested me enough to spend considerable time in research. This topic, programming language diversity, has served me well- perhaps too well for the scope of the project. The aspects that interest me most have lead me away from programming languages, to the contexts of wider language and art. In those contexts, the problems of programming language diversity do not admit any straightforward solution, perhaps not any solution at all. This does not displease me, and I look forward to exploring this subject in general, free from concern with "solution". In practical computer programming, however, there do remain problems of incompatibility in the diversity of programming languages. Accordingly, I have studied the practical methods that have addressed these problems, and concluded that while most methods are successful in limited ways, there is a more general approach suggested. This new approach, "interprogramming", is a collaboration between programming languages, relying on operating systems support. I have described how this collaboration could work, and investigated its possibilities and implications with several programming languages and operating systems. I think it's a good idea: not startlingly dramatic, but a helpful integration of techniques from several areas. I end the project with idealism still, but weary. I believe the topic is an important one, though little directly discussed, and hope my surveying and exploration worthwhile. More work does need to be done: more theory, more development, more practice. But the topic is very large, and the directions to pursue are themselves divergent. I feel my perspective has become rather lost, atid I look forward very much to finding a new one. I would like to express my appreciation to those in whose companionship I have worked on this project: my supervisor, Bruce McKenzie, and all the staff and students of the Computer Science department at the University of Canterbury. I'd particularly like to thank the postgraduate students of the department for many stimulating discussions and shared explorations of computing, and for their general enthusiasm and devotion to the subject: I wish them well. I am also very grateful to those responsible for U1e Commonwealth Scholarship that brought me to New Zealand, now my home. Projects like this are sometimes dedicated to those personally close, but I have always found that inappropriate. I dedicate this project to other naive students interested in pursuing the same topic: I hope my work maps out the area, shows where many directions lead, and helps them understand the difficulties and opportunities concealed. · To my family, to Anthea, I dedicate: new time, new energy, new life. Robert ABSTRACT The success of programming language design is so great and diverse that the resulting incompatibilities have become an important practical problem. This is a study of possible solutions. J:he first part is a consideration of reasoning to convergence. An operational model of programming language is used, and both implementation and application aspects are examined, in application encompassing approaches of linguistic precedent, mathematical theory, psychological principle, and empirical analysis. Some progress seems evident in looking at language implementation, but in language application the difficulty of understanding the human factor seriously impedes further reasoning. The second part is a survey of practical methods for coping with programming language diversity, limiting the diversity or limiting the effects of the problem. Two general approaches are explored, compromise in new design and cooperation in accepting existing design, each comprising a variety of techniques. While no one method was seen completely successful, all had specific advantages and some, particularly cooperative methods, seemed open to further development The third part is a proposal for a collaborative strategy here called "interprogramming". In this approach it is suggested that programming language design include facilities here called "context openings" for general connection and communication beyond the language. Supporting environments such as operating systems would need to provide facilities realising such connection and communication. At the programming language level, this requires precise control over input/output and related concerns. At the operating system level, this requires multitasking with memory protection and message passing, or similar capabilities. Exploration of the approach is made involving several programming languages and two operating systems, and some related new software is presented. Most programming languages seem accepting, and operating systems design capable. The strategy should be practical and portable, adaptable with existing design and helpful in new design. As far as programming language diversity is seen as an technical problem, the interprogramming strategy is seen as a general and promising approach to solution. CONTENTS PART: CHAPTER Page INTRODUCTION I INTRODUCTION 1 I PERSONAL MOTIVATION 1 ll PERSPECTIVE 2 Ill PLAN 4 ONE: CONVERGING 6 II CAN WE REASON TO CONVERGENCE? 7 I INIMPLEMENTATION 8 ll IN APPLICATION 10 1 Linguistic Precedence 11 2 Mathematical Approach 13 3 Psychological Ap.Proach 17 4 Empirical Analys1s 21 Ill CONTEXT 24 1 From Programming Language to Natural Language 24 2 From Natural Language 27 IV CONCLUSION 35 TWO: COPING 36 III COPING BY COMPROMISING 37 I STANDARDISATION 37 II MINIMISATION 41 Ill MULTIPLICATION 45 IV EXTENSION 49 V ABSTRACTION 55 VI CONCLUSION 59 IV COPING BY COOPERATING 60 I TRANSLATION 60 II INCLUSION 63 Ill FLEXIBLE DEFINITION 67 IV COMMON IMPLEMENTATION 69 V PROGRAMME COORDINATION 75 VI CONCLUSION 79 THREE: COLLABORATING 80 V COLLABORATION COOPERATION BY DESIGN 81 I INTERPROGRAMMING 81 II CONNECTION 84 III COMMUNICATION 91 IV CONTEXT OPENING 96 V CONCLUSION 100 VI INTERPROGRAMMING: INSIDE PROGRAMMING LANGUAGES 103 I FORTRAN 104 II PASCAL 109 III C 116 IV ICON 119 V PROLOG 123 VI guASI PROGRAMMING LANGUAGE 126 . VII ONCLUSION 131 VII INTERPROGRAMMING: OUTSIDE PROGRAMMING LANGUAGES 134 II PRIMOS 136 lli UNIX 142 III PROGRAMMINGLANGUAGES BETWEEN PROGRAMMING LANGUAGES 160 III CONCLUSION 170 CONCLUSION 172 VIII CONCLUSION 173 REFERENCES 183 References For Frequently Mentioned Languages And Systems 199 APPENDICES 200 LIST OF FIGURES Figure Title Page 1.1.1 An altemati ve in Pascal data stmcture notation. 2 1.2.1 Structural relationships in the tenninology used. 3 2.3.1 An example of matching words and images. 28 2.3.2 Apparant hierarchy in colour tenns across languages. 29 3.2.1 Orthogonality in Algol 68 data. 42 3.3.1 Programme illustrating PL/I's heritage. 46 3.4.1 C preprocessor used to create Algol68like disguise. 51 3.4.3 How a case statement can he added to Smalltalk. 53 3.5.1 Jackson Structured Programming diagram. 56 3.5.2 Programme fragment written in Guarded Commands. 58 3.6.1 Summary of advantages and disadvantages of compromise. 59 4.2.1 Bossi et al. 's decomposition of Ada into a language hierarchy. 64 4.3.1 An Algol68 program in two different representations. 67 4.4.1 Communication between common levels of implementation. 71 4.5.1 Fragment of JCL/360. 76 4.5.2 Control structures of the Unix (Bourne) Shell. 76 4.6.1 Summary of advantages and disadvantages of cooperation. 79 5.1.1 Interprogramming through "context openings". 82 5.2.1 Levels of parallelism for coordination. 85 5.2.2 Different models for coordination. 88 5.3.1 Programmes in different languages linked via a third. 94 5.4.1 Most common openings in programming language design. 97 6.1.1 Fortran Interprogramming: CALL-EXTRINSIC-ANSWER. 106 6.2.1 Pascal Interprogramming: program header and extrinsics. 113 6.3.1 C Interprogramming: fcall and ffunc. 117 6.4.1 Icon Interprogramming: call and answer. 121 6.5.1 Prolog Interprogramming: t:request and treply. 124 6.6.1 Doris Interprogramming: .req and .rep. 127 6.6.2 Chef Interprogramming: XCandQF. 129 7.1.1 Primos process stack structure showing command levels. 137 7.1.2 Primos outside-process interprogramme structure. 138 7.1.3 Primos interprogramming through a coordinated file. 140 7.2.1 Unix process operations. 142 7.2.2 Unix process structure. 143 7.2.3 Unix shell pipeline between programmes. 145 7.2.4 Using a Unix pipe to process serial data. 146 7.2.5 Representations of a hierarchy of communicating processes. 149 7.2.6 Simple implementation of Unix "tagged" pipes. 150 7.2.7 Using tagged pipes to build interprogramming connections. 152 7.2.8 Unix process openings . 154 . 7.2.9 Generality of openings imitated via intennediate programme. 155 7.3.1 Rap programme for automatic file transfer. 161 7.3.2 Structure of Mux directives. 163 7.3.3 Fragments of Mux files of interprogrammed Icon and Fortran 163 7.3.4 Mux file with multiplexed C and documentation. 164 7.3.5 Lys programme for simple data translation. 167 7.3.6 Mux prefix file for Lys. 168 1 CHAPTER I INTRODUCTION Programming language design is generally thought to have proven a useful and successful pursuit in support of practical computing. While apparently easing some problems, however, continuing design has itself worsened others. In practice, design requires implementation, and the continuing variety in computing facilities has thus lead to interest in portability, both in implementation and in design. But beyond ti1is concern is another, for the diversity of programming language design is itself a practical problem. Programming language diversity is a problem when one language alone is restrictive. There arc problems of availability: when a necessary or useful programme or programme component already exists - but in an incompatible language.