Notes on “How to Think Like a Computer Scientist” Chapter 1

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.

Computer ScienceC, 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.

Published Friday, August 07, 2009 8:07 AM by Tod Birdsall
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Cheese said:

We need a book titled, "How to Write Like Charles Dickens".

October 29, 2009 4:27 PM
 

Tod Birdsall said:

Agreed.

October 30, 2009 6:29 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit
Picture of Tod Birdsall

Welcome!

This is the personal website of Tod Birdsall, a programmer, business analyst, and gamer. Not necessarily in that order. Learn more...

Subscribe

Be notified of my latest posts. Subscribe to my blog.