Dear reader, these notes were taken while reading How to Think Like a Computer Scientist, by by Allen Downey, Jeffrey Elkner and Chris Meyers. I was reading through it as part of MIT OpenCourseWare’s 6.00 Introduction to Computer Science and Programming. My notes are just a snapshot of this chapter with some of my commentary. I highly recommend reading the chapter in its entirety. In fact, if you are new to programming, you should probably read the whole book.
C, C++, Perl, and Java are high-level languages. For whatever reason, I never think of C as a high-level language.
Low-level languages are sometimes referred to as "machine languages" or "assembly languages".
Benefits of writing in high-level languages:
- much easier to program
- take less time to write
- shorter and easier to read
- more likely to be correct
Two kinds of programs that process high-level languages:
- Interpreters – Alternates between reading a line of a high-level program and executing it.
- examples – Python, Lisp, Ruby, Perl
- Many interpreted languages are first compiled to some form of virtual machine code, which is either interpreted or compiled at runtime to native code (aka machine language). (via Wikipedia)
- examples – .NET Framework languages (C#, VB.NET, etc.), Java, Lua
- Compilers – Reads the program and translates it completely before the program starts.
- source code – high-level program
- object code (aka executable) – translated program
- examples – C, C++, BASIC
Three kinds of errors can occur in a program:
- Syntax errors – refers to errors in the structure of the code.
- Runtime errors – does not appear until you “run” the program.
- Semantic errors – you program runs successfully and does not generate any errors; but, it doesn’t do the right thing.
“remember that formal languages are more much more dense than natural languages, so it takes longer to read them”
The above statement reminds me of Joel Spolsky’s article, Things You Should Never Do, Part I:
“The reason that they think the old code is a mess is because of a cardinal, fundamental law of programming:
It’s harder to read code than to write it.”