Some material on programming. Most of the free stuff I link to here comes from

This page is a very good introduction to programming with a lot of linked resources.

See also Chua Hock-Chuan’s programming notes:

Learn X in Y minutes:

The Hello World Collection:


Python and Java are popular and not so hard to learn. Also it’s good to know how web sites are put together.

Web Programming

HTML, CSS, JavaScript, PHP and MySQL: these are the five main languages used in making web sites. HTML describes the structure of the web page: headings, paragraphs, forms and widgets. HTML without CSS looks ‘raw’. CSS is the special sauce that makes HTML look presentable. JavaScript provides code for menus and special effects to make your web page interactive. PHP is the server side language for making dynamic websites, e.g. if you need to log in to a web site this is handled by PHP. MySQL is an open source database management system. See this question on Quora .

HTML, CSS and JavaScript are what are called ‘client side’ languages: they are interpreted by your web browser. PHP and MySQL are ‘server side’ languages: they ‘live’ on the server. If you want to set up a web server on your computer you will have to install what is called a LAMP stack (Linux, Apache, MySql, PHP) (WAMP/MAMP if you use Windows/macOS). Apache is open source web server software.

HTML Dog tutorials (covers HTML, CSS and JavaScript):

A HTML and CSS tutorial from Chua Hock-Chuan:

Links to HTML and CSS cheatsheets:

JavaScript cheat sheets: 1, 2, 3.

JavaScript from wikibooks:
JavaScript The Right Way:

A guide to installing a LAMP stack:

PHP cheat sheets: 1, 2.
PHP Programming from wikibooks:
PHP The Right Way:

A MySQL cheat sheet:
MySQL from wikibooks:

Some web programming books:
Julie C. Meloni, Jennifer Kyrnin, HTML, CSS and Javascript All in One, 3e
Marijn Haverbeke, Eloquent Javascript, 3e
Robin Nixon, Learning PHP, MySQL & JavaScript: With jQuery, CSS & HTML5, 5e


A beginner’s Python tutorial:

A Python cheatsheet:
A set of cheatsheets to go with the book Python Crash Course by Eric Matthes:
 (As a single PDF file: )
Another cheat sheet:

Some Python books:
Al Sweigart, Cracking Codes with Python
 Author website:
Dan Bader, Python Tricks: A Buffet of Awesome Python Features
 Author website:
Code the Classics – Volume 1. The code is available from the website and also comes with the Raspberry Pi OS.
Brett Slatkin, Effective Python, 2e
Luciano Ramalho, Fluent Python


Introduction to Java programming from Chua Hock-Chuan’s programming notes:

A Java programming cheatsheet:
 (As a PDF: )
A list of Java cheatsheets:

Some Java books:
Java Programming from wikibooks:
Rogers Cadenhead, Sams Teach Yourself Java in 24 Hours, 8e
Joshua Bloch, Effective Java, 3e


C and UNIX

Introduction to C from Programming Notes:

An introductory C tutorial fron LinuxConfig:

Another from


C for Python programmers:

A cheat sheet by J.H. Silverman:

Some C books:
C Programming from wikibooks:
Robert C. Seacord, Effective C: An Introduction to Professional C Programming
Brian Kernighan and Dennis Ritchie, The C Programming Language (2e, 1988) (‘K&R C’)
Jens Gustedt, Modern C

The ‘right-left rule’: help in deciphering those C declarations:

There is also a program called ‘cdecl’ that can translate C declarations into English:
I first came across a version of this program in the book Expert C Programming by Peter van der Linden.

More on pointers:
includes a demonstration program written as one single file, or as multiple files with a makefile.
A tutorial on pointers and arrays by Ted Jensen

Unlike interpreted languages like Python or Java, C is a compiled language. This means that you have to write a source file then run it through a compiler to create an executable, written in the machine language of whatever architecture you compiled it on. On Linux the C compiler is called gcc. The simplest way of compiling a program is to run gcc hello.c in the shell. This will produce an output file called a.out. You then run it by typing ./a.out in the shell and pressing enter. But if you have several C source files in a directory their output files can’t all be called ‘a.out’. You need to give each output file its own name using the ‘-o’ flag, like this:
gcc -o hello hello.c
gcc has a lot more options than that. See this page from Rapid Tables:

More complicated C projects, consisting of multiple source files, use a tool called make to automatically build programs and libraries from source code to derive the target program. Here is an example from github of an implementation of the HOC (‘Higher Order Calculator’) program from The UNIX Programmming Environment by Kernighan and Pike. Download the archive, unzip it into a directory. Open a terminal window in the directory and type make. The make program uses the makefile to compile all the C files and links them to form an executable. Now if you want to use it, in the terminal type
./hoc 〈ENTER〉
2 + 2 〈ENTER〉
2 ^ 4 〈ENTER〉

A gcc and make tutorial:

Core Utilities, the GNU implementation of the basic UNIX tool set, contains the C source files for programs such as cat, ls, rm:

Build Your Own Lisp (in C):

An introduction to Unix from wikibooks:
List of Linux cheat sheets:
A Linux command line reference:
The Unix Acronym List:
A bash cheat sheet:
Bash tutorial from linuxconfig:
Bash Scripting from wikibooks:
Bash guide from Greg’s Wiki:
See also Bash Pitfalls (a sort of ‘How Not to Write Bash Scripts’):
The Art of Command Line:

Unix comes with its own documentation in the form of man pages. You access them by typing ‘man’ and the name of a command or topic in a terminal e.g. man ascii, man hier (the file system), man printf, man gcc (that’s a long one), man bash, man grep, man sed, man awk; man man.

There are also info pages, which originated with the GNU project. They are often more detailed than man pages, e.g. info sed is much more detailed than man sed.

Some introductory Unix (Linux) books:
Daniel J. Barrett, Linux Pocket Guide, 3e
Scott Granneman, Linux Phrasebook, 2e
William E. Shotts Jr., The Linux Command Line, 2e
Brian Ward, How Linux Works, 3e

Mark G. Sobell, Matthew Helmke, A Practical Guide to Linux Commands, Editors, and Shell Programming, 4e

What these resources all have in common is that they all refer to the command line. UNIX and Linux systems make use of many GUIs (KDE, GNOME, Xfce, Cinnamon, Mate) but to really harness the power of the operating system you need to become proficient in command line. The program which handles the command line interface is called a command language interpreter or shell. One of the most popular shells for UNIX is bash (‘Bourne-Again SHell’). The shell is not just a command interpreter it is also a programming environment. You can write short programs called shell scripts that act like custom commands.

UNIX has a class of command line programs called filters, which operate on a data stream, producing another stream. Individually they usually do simple things, but they can be chained together in pipes to do clever things. See this example:

Some of the more powerful tools in UNIX’s box are grep, sed and AWK. Before you get into those, you should find out about regular expressions:
cheat sheet:

grep searches plain-text data for lines that match a regular expression. sed is the UNIX stream editor. It performs basic text transformations on an input stream. AWK is a special-purpose programming language designed for text processing and typically used as a data extraction and reporting tool.

An article by Matt Might covering regex, grep, sed and AWK:

grep tutorials:

Sed cheat sheets: 1, 2.
Eric Pement’s collection of sed one-liners:
And with commentary from Peteris Krumins:
Sed tutorials from sourceforge:

AWK cheat sheets: 1, 2.
AWK one-liners:
An AWK Primer from wikibooks:
AWK manual from GNU:

Dale Dougherty and Arnold Robbins, Sed & Awk, 2e
Jeffrey E.F. Friedl, Mastering Regular Expressions, 3e

Shell-scripting books:
Arnold Robbins, Nelson H.F. Beebe, Classic Shell Scripting
Steve Parker, Shell Scripting: Expert Recipes for Linux, Bash and More
Carl Albing, J.P. Vossen, bash Cookbook, 2e


Type perldoc perlintro in a terminal for an introduction. perldoc is Perl’s built-in documentation. It might not be installed by default on your Linux distro. Also available online: man perl or perldoc perl gives an overview of perldoc.

Cheat sheets: perldoc cheat, 2, 3, 4

Perl one-liners:

Perl books:
Perl programming from wikibooks:
Schwartz, foy, Phoenix, Learning Perl, 7e (‘The Llama Book’)
And the sequels, Intermediate Perl (‘The Alpaca’) and Mastering Perl (‘The Vicuña’).
Mark Jason Dominus, Higher Order Perl

The Editors: Vim, Emacs

Vim is a clone of the original UNIX vi editor. If you have Vim installed type vimtutor in a terminal for a tutorial introduction.

Cheat sheets: 1, 2, 3

Vim user manual:
(Also available from within vim if you type :help user-manual.)

Vim adventures:


Drew Neill, Practical Vim, 2e

Emacs ‘the extensible, customizable, self-documenting, real-time display editor’.
Emacs home page:
Cheat Sheet:

Which is better?

Some oldie but goodie UNIX books:
Kernighan/Pike, The UNIX Programming Environment
Maurice J. Bach, The Design of the UNIX Operating System

More advanced UNIX books:
Nemeth, Snyder, Hein, Whaley, Mackin, UNIX and Linux System Administration Handbook, 5e
W. Richard Stevens and Stephen A. Rago, Advanced Programming in the UNIX Environment (‘APUE’), 3e
Michael Kerrisk, The Linux Programming Interface



A website with analysis of algorithms, with implementations in the popular programming languages:

See also:

The Dictionary of Algorithms and Data Structures:

Some algorithm books:
Aditya Bhargava, Grokking Algorithms
George T. Heineman and Gary Pollice, Algorithms in a Nutshell
Robert Sedgewick, Algorithms in C
I got the 1990 edition of this book for cheap from Abebooks; The Definitive C Book Guide recommends the 1997 edition.

Matters Computational by Jörg Arndt:

More advanced algorithm books:
Cormen, Leiserson, Rivest, Stein, Introduction to Algorithms (‘CLRS’).
Donald E. Knuth, The Art of Computer Programming (4 vols) (‘TAOCP’)

The mathematical backround – some Discrete Mathematics books:
Oscar Levin, Discrete Mathematics: An Open Introduction
Seymour Lipschutz, Marc Lipson, Schaum’s Outline of Discrete Mathematics
Norman L. Biggs, Discrete Mathematics
Kenneth H. Rosen, Discrete Mathematics and Its Applications
Graham, Knuth, Patashnik, Concrete Mathematics (advanced)
Lehman, Leighton, Meyer, Mathematics for Computer Science

A cheat sheet from the TeX Showcase:

Think Stats: Probability and Statistics for Programmers


Close to the Machine* – Assembly Language and Computer Architecture

* title of a book by Ellen Ullman

Intel Assembly

Cheat sheets: 1, 2, 3

x86 Assembly Guide (32-bit):

Another version of the same, but re-written to use the AT&T syntax, which is more traditional on UNIX systems. However NASM on Linux uses the Intel syntax.

This page explains the main differences between AT&T and Intel syntax.

X86 Assembly from wikibooks:

Sample x86-64 Assembly programs using the Netwide Assembler (NASM):

When I tried these programs on my Linux system, I kept getting a segmentation fault whenever I tried to run them. This question on stackoverflow explains how to get round this. You have to add ‘-no-pie’ to the gcc line of the makefile:
gcc -no-pie -m64 -o hello_64 hello_64.o

Paul Carter’s book on PC Assembly Language. It uses 32-bit mode, but will still work on a 64-bit OS:

A free book by Ed Jorgensen on x86-64 Assembly programming with Ubuntu:

Ray Seyfarth, Introduction to 64 Bit Assembly Programming for Linux and OS X, 3e

ARM Assembly

Cheat sheets: 1, 2, 3, 4

ARM Assembly using Raspberry Pi:

A free book on ARM Assembly on the Raspbery Pi:

A book on Assembly Language programming with the Raspberry Pi:
Bruce Smith, Raspberry Pi Assembly Language RASPBIAN Beginners: Hands On Guide

Some low level books:
Henry S. Warren, Hacker's Delight, 2e
Igor Zhirkov, Low-Level Programming: C, Assembly, and Program Execution on Intel® 64 Architecture


A compiler translates code written in a high-level language into the machine code of whatever architecture it runs on. CPUs only understand machine code, so somewhere along the line whatever you want to run on the computer has to be translated into the machine language of that CPU.

Compiler Books:
Torben Mogensen, Basics of Compiler Design
Keith Cooper, Linda Torczon, Engineering a Compiler
Aho, Lams, Sethi, Ullman, Compilers: Principles, Techniques, and Tools (‘The Dragon Book’)


A primer of computer arithmetic and character encodings:

Logic circuits, adders, memory circuits:

Some introductory books:
Eben Upton, Jeffrey Duntemann et al., Learning Computer Architecture with Raspberry Pi
Jon Steinhart, The Secret Life of Programs

Computer Architecture books by David A. Patterson and John L. Hennessy:
Computer Organization and Design: The Hardware/Software Interface (‘Patterson and Hennessy’)
More advanced:
Computer Architecture: A Quantitative Approach (‘Hennessy and Patterson’)

The Hennessy/Patterson books are written for people who design computer systems. For a treatment written more from the point of view of a programmer see:
Computer Systems: A Programmer’s Perspective by Randal E. Bryant, David R. O’Hallaron