Concept Programming in XL the Art of Turning Ideas Into Programs
Total Page:16
File Type:pdf, Size:1020Kb
Concept Programming in XL The Art of Turning Ideas into Programs TM Concept Programming 1 2 Concept Programming Chapter 1— Introduction . 13 1.1. Why another language? . 14 1.2. Who should read this book?. 16 1.3. A quick tour of XL . 16 1.4. Contents Overview. 17 Chapter 2— Simple Examples . 19 2.1. Hello World . 20 2.2. Factorial Function . 21 2.3. Computing a Maximum . 24 2.4. Symbolic Differentiation . 26 Part I — Concept Programming . 31 Chapter 3— Concepts? . 33 3.1. Programming Philosophy. 34 3.2. Translating concepts. 37 3.3. Pseudo-Metrics. 45 3.4. Concept Mismatch . 48 3.5. In Conclusion . 51 Chapter 4— The Trouble with Programming . 53 4.1. Scale Complexity and Moore s Law . 54 4.2. Domain Complexity . 57 4.3. Artificial complexity . 58 4.4. Business Complexity . 64 4.5. The Grim State of Software Quality . 68 Chapter 5— From Concepts to Code . 71 5.1. Turning Ideas into Code. 72 Concept Programming 3 5.2. Abstractions . 77 5.3. Abstractions in Programs . 84 Part II —Core Language . .93 Chapter 6— Compiling XL . 95 6.1. Representing Programs . 96 6.2. Understanding Programs . 98 6.3. Compiling XL . 102 Chapter 7— Syntax . 105 7.1. Source Text. 106 7.2. Tokens . 107 7.3. Parse Tree . 112 7.4. Practical Considerations. 121 7.5. Beyond the Syntax . 126 Chapter 8— Declarations . 127 8.1. Variables. 128 8.2. Subroutines. 134 8.3. Types . 143 8.4. Constants . 143 Chapter 9— Control Flow . 145 9.1. Tests . 145 9.2. Loops . 145 9.3. Extensions . 146 Chapter 10—Generic Programming . 147 10.1. Generic Types. 148 10.2. Generic Functions . 148 4 Concept Programming 10.3. Defining Usable Notations. 148 Chapter 11—Objects. 149 11.1. Object-Oriented Programming. 149 11.2. Encapsulation . 150 11.3. Construction and Destruction. 150 11.4. Inheritance . 150 11.5. Dynamic Dispatch . 150 Chapter 12—Programming in the Large . 151 12.1. Design By Contract . 152 12.2. Modules . 152 12.3. Compiling Multiple Files . 152 Chapter 13—The Preprocessor. 153 Part III —Extensibility . 155 Chapter 14—Compiler Plug-ins. 157 14.1. Declaration and Invokation . 158 14.2. Tree Transformations . 158 14.3. Useful Techniques . 158 14.4. Active Libraries . 159 Chapter 15—Optimizations . 161 15.1. Why Add Optimizations?. 162 15.2. When Should Optimizations Run?. 162 Chapter 16—Syntax Configuration . 163 16.1. Why Alter the Syntax? . 164 16.2. Syntax File Description . 164 16.3. Rendering Styles . 164 Concept Programming 5 16.4. Impact of Syntax Changes . 164 Chapter 17—Compiled Code Configuration . 167 17.1. Why Configure the Bytecode? . 167 17.2. Bytecode File Format. 168 17.3. Retargetting the Compiler . 168 17.4. Customizing the Output . 168 17.5. Generating Other Kinds of Output. 168 Part IV —Standard Library . 171 Chapter 18—Runtime Models and Portability . 173 18.1. Machine Models. 174 18.2. Object Models . 174 18.3. Error Reporting . 175 18.4. Environment Model . 175 18.5. How Portable is Your Code? . 176 Chapter 19—Core Functionality . 177 19.1. Integer Arithmetic . 177 19.2. Floating-Point Arithmetic. 177 19.3. Comparisons and Boolean Logic . 177 19.4. Loop Control . 177 Chapter 20—Memory Management . 179 20.1. Pointer Types . 180 20.2. Memory Allocation . 180 Chapter 21—Collections . 181 21.1. Arrays. 182 21.2. Strings. 182 6 Concept Programming 21.3. Lists . 182 21.4. Maps. 182 21.5. Collection Algorithms . 182 Chapter 22—Mathematics. 183 22.1. Numeric Types . 183 22.2. Transcendental Functions. 184 22.3. Numeric Algorithms. 184 22.4. Symbolic Code Manipulations. 184 Chapter 23—External Storage . 185 23.1. Streaming Objects . 185 23.2. Storage Management . 186 23.3. Database Access . 186 Chapter 24—Text Formatting . 187 24.1. Text Formatting . 188 24.2. Text Output. 188 24.3. Text Input . 188 Chapter 25—Concurrency. 189 25.1. Forms of Concurrency . 190 25.2. Communication . 190 25.3. Synchronization . 190 Chapter 26—Graphics. 193 Chapter 27—Sound. 195 Chapter 28—User Interfaces. ..