Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.



Host Image
Host ID: 197

episodes: 7

hpr1593 :: Why C++?

Released on 2014-09-10 under a CC-BY-SA license.

In this episode, Garjola presents the C++ programming language by introducing its main features for object orientation, generic programming and functional style.

hpr1330 :: Programming languages 3 - C

Released on 2013-09-06 under a CC-BY-SA license.
Hi, my name is Garjola and you are listening to a contribution to
HPR. This is episode 3 of my programming language series and is entitled
"Getting started with the C programming language"

I am not going to teach you C, but just whet your appetite.

1 Intro

  • What C is useful for
    • Systems programming
    • Number crunching
    • Graphics
    • Embedded systems
      • Arduino
  • Advantages
    • speed
    • fine grained control of the memory management
    • close to the metal
    • the portable assembly language
  • Drawbacks
    • fine grained control of the memory management
    • close to the metal
    • the portable assembly language

2 History of the language

  • developed by Ken Thompson and Dennis Ritchie between 1969 and 1973
    at AT&T Bell Labs.
  • The origin of C is closely tied to the development of the Unix
    operating system, originally implemented in assembly language on a
    PDP-7 by Ritchie and Thompson, incorporating several ideas from
    colleagues. Eventually they decided to port the operating system to
    a PDP-11. B's inability to take advantage of some of the PDP-11's
    features, notably byte addressability, led to the development of an
    early version of C.

3 Uses

  C is often used for "system programming", including implementing
  operating systems and embedded system applications, due to a
  combination of desirable characteristics such as code portability and
  efficiency, ability to access specific hardware addresses, ability to
  pun types to match externally imposed data access requirements, and
  low run-time demand on system resources. C can also be used for
  website programming using CGI as a "gateway" for information between
  the Web application, the server, and the browser. Some reasons for
  choosing C over interpreted languages are its speed, stability, and
  near-universal availability.

  One consequence of C's wide availability and efficiency is that
  compilers, libraries, and interpreters of other programming languages
  are often implemented in C. The primary implementations of Python
  (CPython), Perl 5, and PHP are all written in C.

  Due to its thin layer of abstraction and low overhead, C allows
  efficient implementations of algorithms and data structures, which is
  useful for programs that perform a lot of computations.

  C is sometimes used as an intermediate language by implementations of
  other languages. This approach may be used for portability or
  convenience; by using C as an intermediate language, it is not
  necessary to develop machine-specific code generators.

  C has also been widely used to implement end-user applications, but
  much of that development has shifted to newer languages.

4 Characteristics of the language

  • imperative, compiled, static, weakly typed
  • structured programming
    • Uses functions but it is not functional, but rather procedural
    • control flow if/else, for, while
    • curly braces, semi-colons
  • all parameters are passed by value and references are simulated
    using pointers
  • A program is a function called main

5 Tooling and environment

  • editor
  • compiler
    • makefiles for convenience, although higher level tools such as
      autoconf/automake or cmake exist
  • debugger
  • IDEs
  • gnu tools for everything
    • emacs, pico, gedit, vi
    • gcc, clang
    • gnumake
    • gdb, xgdb, ddd
    • kdevelop

6 Hello World

  #include <stdio.h>

  int main(void) { printf("hello, world\n"); return 0; }

7 How to make a C program

  • Write your main function into a file called myprogram.c
  • compile your program
    • gcc -o myprogram myprogram.c
  • if you use other libraries than C's standard library, you will need
    to use a linker, like ld

  Examples taken from An Introduction to GCC
  by Brian J. Gough, foreword by Richard M. Stallman

  The classic example program for the C language is Hello World. Here is
  the source code for our version of the program:

  #include <stdio.h>

  int main (void) { printf ("Hello, world!\n"); return 0; }

  We will assume that the source code is stored in a file called
  ‘hello.c’. To compile the file ‘hello.c’ with gcc, use the following

  $ gcc -Wall hello.c -o hello

  To run the program, type the path name of the executable like this:

  $ ./hello
  Hello, world!

8 Pointers!

  C supports the use of pointers, a type of reference that records the
  address or location of an object or function in memory. Pointers can
  be dereferenced to access data stored at the address pointed to, or to
  invoke a pointed-to function. Pointers can be manipulated using
  assignment or pointer arithmetic.  The run-time representation of a
  pointer value is typically a raw memory address (perhaps augmented by
  an offset-within-word field), but since a pointer's type includes the
  type of the thing pointed to, expressions including pointers can be
  type-checked at compile time.

9 The standard library

  • just use man!
  On Unix-like systems, the authoritative documentation of the actually
  implemented API is provided in form of man pages. On most systems, man
  pages on standard library functions are in section 3; section 7 may
  contain some more generic pages on underlying concepts (e.g. man 7
  math_error in Linux).

  apropos sqrt |grep \(3\) man 3 sqrt

  man 3 qsort history

  • the not-so-standard libraries
    • gsl
    • gtk
    • X

10 Languages of the C family

  • C++, ObjectiveC, Java, C#, Go

11 Resources

  • [] : Learning GNU C by Ciaran

hpr1255 :: A life in a software project

Released on 2013-05-24 under a CC-BY-SA license.

A friend of mine wrote a blog post the day of his 40th birthday. The title was "Version 4.0 is out!". I found it very interesting, as he told the history of his life as if it was a software project with a major x.0 release every 10th birthday.

hpr1187 :: I live in GNU/Emacs

Released on 2013-02-19 under a CC-BY-SA license.
I live in GNU/Emacs

1 Emacs on HPR 
Klaatu's 3 part series
- ep0852
- ep0856
- ep0861

2 EmacsWiki 
- Ultimate source of information for GNU/Emacs
- []

3 Appearance 
- no menus nor scroll bars
- black background on a tiling window, full screen (no decorations)
  - people often think that I am on the console (no X)

4 Daemon 
- []
- so that clients can connect (org protocol)
- use the same emacs from the consoles
  - if x crashes, for instance

5 Editing code 
- c++
- with repls
  - lisp/scheme/clojure/elisp (slime and geiser)
  - python
  - octave
- compilation
- latex

6 Org 
- []
- Note taking
- GTD, agenda, spreadsheet
- Reports, papers, slides, blog
- export to mobile org

7 Gnus 
- []
- Mails
- RSS and mailing lists via gwene
- store links into and open from org-mode

8 w3m 
- []
- search and more and more navigation

9 Conkeror (in/out) 
- []
- only when javascript is required
- org protocol for vzpturing links
- org open link to open pages

10 ERC for IRC 
- []

11 Small utilities 
- Info reader
  - []
- Calendar
  - []
- Scratch buffer as calculator
  - Evaluating expressions
  - []
- Dired
  - []
- Docview
  - []
- Version control
  - []

hpr1138 :: Programming languages 2 - Python

Released on 2012-12-12 under a CC-BY-SA license.

Programming languages 2 - Getting started with Python

Python is a very interesting language in the sense that it covers a very wide range of use cases.
  1. It can be useful for simple scripting tasks, that is automating repetitive tasks that you usually do by hand.
  2. It can also be useful for text file processing, like parsing log files or specific formats like XML.
  3. You can use use it as a glue language, that is a mix of system calls to command-line programs, like in scripting, but also by calling foreing language libraries which provide Python bindings.
  4. You can use Python as a first language in a Computer Science curriculum, since it is simple to learn and supports different programming paradigms (Object Oriented, Procedural, Functional).
  5. You can it also as an extension language, since a Python interpreter can be embedded in C/C++ programs.
  6. Python being a very rich language with a very rich standard library, you can use it to build very complex applications. There are many ways of using it to build complex Graphical User Interfaces, since many graphical libraries provide Python bindings (, GTK, etc.). Python also provides a default library for GUIs, which is called Tkinter and is based on Tcl/Tk.
  7. You can also use Python for web development, either by using the standard library utilities or by using one of the very popular web frameworks like Zope, Plone or Django.
  8. Finally, Python is also extensively used in scientific computing, since projects like SciPy, Numpy or Matplotlib provide a set of tools which allow Python to be as powerful as languages like Matlab or IDL with the advantage of being a full fledged language with a very rich standard library.

2 Installation

There are 2 current versions of Python: version 2 and version 3. Version 3 is not fully compatible with version 2, so if you are starting with Python, I think is is wise to go with version 3, but be aware that most existing applications and Open Source projects use version 2.

If you are using a GNU based system, chances are that Python is already installed in you system. Otherwise, it will be available in your distribution repositories. As far as I know, Python is also available on the Mac via the terminal. On widows, you will have to download a Python distribution from On this page you will also find links for downloading Python for Linux, MacOS, etc.

If you go to this site, you will notice that they mention alternative implementations of Python. The implementation I will be talking about here is the one done in C.

To install Python, you also can download the source code and compile it yourself.

3 Syntax and semantics

Have a look at this link

Python is intended to be a highly readable language. It is designed to have an uncluttered visual layout, frequently using English keywords where other languages use punctuation. Python requires less boilerplate than traditional manifestly typed structured languages such as C or Pascal, and has a smaller number of syntactic exceptions and special cases than either of these.

The simplicity of Python is demonstrated by its version of the classic "Hello world" program:

print("Hello world")


Python uses whitespace indentation, rather than curly braces or keywords, to delimit blocks; a feature also termed the off-side rule. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.

Statements and control flow

Python's statements include (among others):

The if statement, which conditionally executes a block of code, along with else and elif (a contraction of else-if).

The for statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block.

The while statement, which executes a block of code as long as its condition is true.

The class statement, which executes a block of code and attaches its local namespace to a class, for use in object-oriented programming.

The def statement, which defines a function or method.

The import statement, which is used to import modules whose functions or variables can be used in the current program.

Each statement has its own semantics: for example, the def statement does not execute its block immediately, unlike most other statements.


Python expressions are similar to languages such as C and Java.

In Python, == compares by value, in contrast to Java, where it compares by reference. (Value comparisons in Java use the equals() method.) Python's is operator may be used to compare object identities (comparison by reference). Comparisons may be chained, for example a <= b <= c.

Python uses the words and, or, not for its boolean operators rather than the symbolic &&, ||, ! used in Java and C.

Conditional expressions in Python are written as x if c else y (different in order of operands from the ?: operator common to many other languages).


Methods on objects are functions attached to the object's class; the syntax instance.method(argument) is, for normal methods and functions, syntactic sugar for Class.method(instance, argument). Python methods have an explicit self parameter to access instance data, in contrast to the implicit self in some other object-oriented programming languages (for example, Java, C++ or Ruby).


Python uses duck typing and has typed objects but untyped variable names. Type constraints are not checked at compile time; rather, operations on an object may fail, signifying that the given object is not of a suitable type. Despite being dynamically typed, Python is strongly typed, forbidding operations that are not well-defined (for example, adding a number to a string) rather than silently attempting to make sense of them.

Python allows programmers to define their own types using classes, which are most often used for object-oriented programming. New instances of classes are constructed by calling the class (for example, SpamClass() or EggsClass()), and the classes themselves are instances of the metaclass type (itself an instance of itself), allowing metaprogramming and reflection.

4 Interpreter

The section 3 of the python tutorial (An informal introduction to Python) gives a very good overview of the use of the interactive interpreter.

Of course, if you are going to write long programs, you will want to save them to files which can then be passed to the interpreter for execution.

5 Standard library

Python has a very rich standard library, that is a set of modules which are part of the standard Python installation and which provide many interesting functions which in many other languages are only provided by 3rd party libraries :

  • Operating System Interface
  • Command Line Arguments
  • Error Output Redirection and Program Termination
  • String Pattern Matching
  • Mathematics
  • Internet Access
  • Dates and Times
  • Data Compression
  • Performance Measurement
  • Output Formatting
  • Working with Binary Data Record Layouts
  • Multi-threading
  • Logging
  • Decimal Floating Point Arithmetic

6 Documentation and tutorials

The main reference is the Python documentation page at . There you will find a very useful tutorial (this is the place to start), the standard library reference, and many other interesting information.

hpr0932 :: Programming languages 1 - Introduction

Released on 2012-02-27 under a CC-BY-SA license.

This is the first episode on a series about computer programming languages. In this episode, I will start by discussing why you may want to learn a programming language, then I will give an introduction about what programming languages are, which are the different types of programming languages, their history, and I will also give some pointers to resources which can be useful to get you started with programming.

Eric Raymond's "How to become a hacker" essay, available at

1 Wikipedia sources:

2 Resources for learning to program

2.1 Easy

2.1.1 List of resources on Wikipedia

2.1.2 The Python tutorial

2.2 Intermediate

2.2.1 Structure and interpretation of computer programs

hpr0900 :: Episode 000 - Introduction

Released on 2012-01-13 under a CC-BY-SA license.

In this episode, the first of a hopefully long series, Garjola introduces himself and explains how he got into computers, programming and free software. You can get in touch with Garjola by e-mail at

Become a Correspondent