Welcome
Fertile Questions for the Languages chapter of “How to Learn Computer Science”.
Thank you for buying my book! This page discusses the content in the “x chapter and answers the “Fertile Questions” I asked there. There are no perfect answers, however: you may even disagree, but the point of a fertile question is to make you think.
Here are the questions, and my suggested answers. Do you agree?
If we can code in assembly language, with instructions like INP, STA and ADD, why do we need high-level languages?
Programming in assembly language, using the CPU’s own, low-level instructions, requires a detailed knowledge of the instruction set, memory, registers and buses.
“When you programmed a computer you had to be aware of where the thousands of bits of information were going from one instruction to the next, it was almost as if your mind had merged into the environment of the computer.”
“Hackers, Heroes of the Computer Revolution”, Steven Levy
Low-level programming is difficult and time-consuming. To add two numbers, instead of writing INP, STA 99, INP, ADD 99, OUT, we could just write something like INPUT A, INPUT B, PRINT A + B and let the compiler worry about where to store data!
Why are there so many programming languages?
Different languages are designed for different purposes. We say that the offer different abstractions: language constructs and data structures that are suited to different tasks.
COBOL was designed for number-crunching of big lists of data, which is needed in big business. FORTRAN was designed for science and maths. ALGOL was designed to allow structured programming which makes code easier to maintain as projects grew larger and larger in the 60s, and most modern languages are descended from ALGOL.
HTML, CSS, and JavaScript were designed specifically for the web, while C++ and C# are good for games and desktop apps.
Specialist languages have been developed for mobile applications, such as Swift for iOS and Java or Kotlin for Android. Each of these languages contains features specific to their environment.
Why do video games have a format, such as PC, Xbox, PlayStation?
The game, as sold on DVD or via download, is an executable file, it’s been compiled into object code specific for the type of system it’s going to run on. A PC, Xbox and PlayStation all have different hardware, so the compiled versions will contain different instructions.
Why did Java become so popular?
before 1995, you would need multiple compilers for multiple devices, creating separate object code executables for each machine. This is because each machine had its own low-level instruction set. Java turned this
concept upside down. Initially planned for the digital cable television industry, Java was perfect for the growing web application market in the late 1990s.
Named for designer James Gosling’s favourite coffee bean, Java is compiled only once, to an intermediate “bytecode”. This portable bytecode is then interpreted directly on the platform, by a Java virtual machine (JVM). The code itself is written just once, and compiled just once, but is runnable anywhere with the right JVM. This gave Java a portability advantage and it quickly became the language of choice for web apps, and later smartphone apps.
“How to Learn Computer Science” page 91
Can a spreadsheet full of formulas be considered a computer program?
Yes, it’s a functional program. Functional languages are different from imperative languages like C++ and Python. We define every operation as a function, and feed the result into another function, and so on.
Functional programming avoids side-effects. Each function always returns the same value for the same parameters passed to it, and nothing else changes. This makes behaviour highly predictable and less prone to error. Because functions are so versatile, there is always an elegant way to get the job done, meaning functional programs tend to be shorter, with the solution much closer to the problem (see above).
“How to Learn Computer Science” page 92
Every formula in a spreadsheet is really a function and the whole spreadsheet a functional program.
Why do interpreted languages run slower than compiled languages, and why does this matter less today?
Python is an interpreted language, which means each line is translated to machine code just before execution. Interpreted languages run slower than compiled languages, but by the late 1990s this didn’t matter much, as computers were so powerful. C++’s object code may be small and efficient but coding in Python is quicker. By the turn of the century, the cost of a programmer’s time was greater the cost of CPU time. And because Python is interpreted, with a free interpreter available for every platform, it is highly portable. Just like Java, Python is “code once, run anywhere”.
“How to Learn Computer Science” page 93


You must be logged in to post a comment.