Appendix A
Programming Languages
This appendix contains brief introductions to three programming languages that are used in the textbook: Java, C, and JavaScript. You should be very familiar with at least one of the three languages before reading this textbook. The three languages have something in common, so that knowing one will make it easier to learn the others. You should also be at least somewhat familiar with classes, objects, and object-oriented programming.
The appendix is meant to help you get started with the languages that you don't already know. Only some basic information about each language is given—but hopefully enough to let you understand examples in the book and to write some programs that use the graphics techniques that are covered. You should at least be able to work with the sample programs that accompany this textbook.
Java is obligatory only for Section 2.5. For the material on OpenGL 1.1 in Chapter 3 and Chapter 4, either Java or C can be used. Or, if you prefer JavaScript, you can use my glsim.js (Subsection 3.6.3), a JavaScript library that simulates a large part of OpenGL 1.1. But in any case, you will need to be at least somewhat familiar with C to follow the discussion. The shader programming language that is used with WebGL is based on C, so some knowledge of C will also be useful there. (However, for writing WebGL shaders, you will not need to know one of the most confusing aspects of C, namely the details of how it uses pointers). JavaScript is essential for WebGL programming (Chapter 6 and Chapter 7), for programming with three.js (Chapter 5), and for WebGPU (Chapter 9). It is also used for HTML canvas graphics in Section 2.6.
Contents of Appendix A:
- Section 1: The Java Programming Language
- Section 2: The C Programming Language
- Section 3: The JavaScript Programming Language
- Section 4: JavaScript Promises and Async Functions