by Robert A. Paauwe (www.ax38.org)
This post will teach you step-by-step how to install a C++ compiler on Windows 7/8. Hopefully this will be of any use for anyone not familiar with installing compilers. Take note; most of this I have discovered though trial-and-error, so there is probably some redundancy and error.
by Robert A. Paauwe (www.ax38.org)
I have a firm belief that many of the difficulties around programming arise from the stuff around programming, not necessarily programming itself. One of the most difficult things I have encountered so far, is installing and using a compiler. Compiling is the act of converting a program into machine language so a computer can execute the program. In layman’s terms; making an executable (.exe) of your program that you can run by double clicking. Nobody ever tells you how to to this though. Sure, integrated development environments (IDEs) such as Microsoft Visual Studio, Eclipse, or Apple’s Xcode might have built-in compile-and-execute functions, however these environments are aimed at the expert programmer, and are very cumbersome for beginners. This may seem a trivial topic for those well-versed in the world of computer science and programming, but it is actually never explained. At least not to me.
In this tutorial, I will explain how to install and use a C++ compiler on Windows 7/8 (tested on both), based on my own experiences. I do believe that this method is similar for installing other compilers (e.g., C, Java, Objective-C).
1. Install Notepad++
This is a basic IDE. I use Notepad++, because it supports compiling directly from within the IDE (see below), it has syntax highlighting for many programming languages, and has plenty of other nice features without being potentially bloated or confusing for novice programmers.
Install Notepad++ (download) and open it. Go to Plugins>Plugin Manager and install NppExec.
2. Install MinGW
This is actually what took me the most time to figure out. MinGW (short for Minimalist GNU for Windows) is an Open Source development environment for native Windows applications and helps with installing packages. MinGW allows you to easily install GCC, the GNU Compiler Collection, which is a collection of compilers and libraries that are free to use. When installing MinGW (download), make sure to also install support for the graphical user interface.
Open MingGW Installation Manager and in the left window navigate to All Packages>MinGW>MinGW Base System. In the right window, right click and ‘mark for installation’ the following packages:
mingw32-base bin (dependencies will also be marked)
Go to Installation>Apply changes. MinGW will now install these packages (including G++, the GNU C++ compiler). Once the installation is complete, close the dialogue window and the MinGW Installation Manager.
3. Add to path
As a final step, you have to point your computer in the right direction where to find the compiler. Right click on ‘My Computer’, go to Properties>Advanced System Settings>Environment Variables. Select the Path variable and click on edit. IMPORTANT! Do not change this line in anyway, only append the following to the end of the line:
;C<installation directiory of MinGW>\bin
If you installed MinGW in the default location, you should append:
4. Compiling in Notepad++
That’s it! The only thing that remains is actually compiling something! Let’s use a short C++ program to demonstrate how to compile and run your program. Write the following program in Notepad++ and save it as hello_world.cpp.
// Hello World
using namespace std;
cout « “Hello world!”;
To compile this into an executable, go to Plugins>NppExec>Execute (hotkey F6), and add the following line (on a single line):
cmd /K g++ “$(FULL_CURRENT_PATH)” -o “$(CURRENT_DIRECTORY)\$(NAME_PART).exe”
You should save it as ‘C++ compile’ or something similar, so you can use it again. When you run this, it will compile your code to the same directory as the file is in. Alternatively, you can compile and run it at the same time by using the following line (save it as ‘C++ compile and run’):
cmd /K g++ “$(FULL_CURRENT_PATH)” -o “$(CURRENT_DIRECTORY)\$(NAME_PART).exe” && “$(CURRENT_DIRECTORY)\$(NAME_PART).exe”
This runs the file in the console in Notepad++. If you run the .exe in your folder, you see a console pop up briefly. This is because computers are so fast, it executes the program without giving time to humans to see the result of hello_world.exe. To demonstrate its effect, you can create a batch file and run that instead. Create a new file containing:
Save the file as hello_world.bat. If you run hello_world.bat, it pauses after it executed hello_world.exe, giving you time to see ‘Hello world!’ printed in the command line.
That’s how you create your own executables in C++! There are plenty of good materials out there to learn programming, but they are often vague and confusing on compilers (arguably the most crucial part). Hopefully this helps you getting started with languages such as C or C++.
Recently, I completed my first course on Coursera: interactive programming in Python, by Rice University. I would like to share some of my experiences, insights, and in particular the application of learning this kind of stuff as an (interaction) designer.
by Robert A. Paauwe (www.ax38.org)
As a designer that is slowly adopting the way of the programmer, I am familiar with imperative programming paradigms (cf. Arduino), where everything is rigid, sequenced, and recipe-like. Designers often abuse these systems by copy-pasting chunks of sequential code and inserting a huge amount of delays (some examples here, and in the appendix of my thesis). Generally, this is because of two reasons: 1) it works (for simple programs) and 2) they do not know any better. It is simply the fastest solution with the minimum amount of learning effort, which is a combination that works well in design projects.
However, things get tricky when you start using a lot of repetitive code and delays a lot. A lot of repetitive code ensures difficulties in reading, debugging and changing code, too many delays interrupt the loop, delaying the illusion of real-time, causing all sorts of difficulties.
Contrary to this, the Coursera course focuses on interactive programming using Python and assumes you have zero knowledge in programming or Python. However, any prior knowledge helps as the difficulty of the course increases exponentially over the weeks. I can recommend Alan Downey’s How to Think Like a Computer Scientist to get started with Python. It is free and offers a nice introduction to the basics of Python.
Rather than treating infinite amount of programming concepts in sequence, the Coursera course builds up knowledge in weekly assignments to make a working game each week. During the course of 9 weeks, you make at least 7 games (some take several weeks to complete): rock paper scissors, guess the number, stopwatch game, pong, memory, black jack, asteroids.
The interesting part is that each assignment increases in complexity. The first games are only text-based, the later assignments include graphics, sounds, keyboard and mouse input (see the header image).
Rice university provides each week with a set of videos that treat the concepts required for that week’s assignment. In turn, each student is asked to peer review the work of at least 5 other students every week, according to a fixed list of criteria. The workload is approximately 7-10 hours each week, but it quickly stacks up if you watch all the videos, peer review 5 students, do the mandatory tests every week, and build the game. Needless to say, this course is a tremendous time sink but well worth the effort. It teaches many things that I found very difficult to learn elsewhere. Object-Oriented Programming (OOP), helper functions, keyboard and mouse input, Graphical User Interfaces (GUIs). Finally, one of the best things about this course is that they have a very active staff that is reachable via email, ready to help you when you get stuck on programming (if the answer isn’t already posted in the forums).
The course uses Codesculptor, an online IDE and compiler, which is rather cute. It is complete and allows you to do everything for the course, and it makes sense from the perspective of managing the course (all data is online accessible, no local files). This is great if you are an absolute beginner, but once you become more proficient, I believe that these online environments restrict you from advancing your skill. Especially because some fundamental libraries are embedded in the IDE, it is impossible to run your programs locally (the SimpleGUI library is not available outside Codesculptor). This is the point where I believe these custom (online) IDEs have outlived their usefulness. All the programs that I made during this course only run in Codesculptor, and online when I am online. To run it locally, I have to port everything to, say TKinter or another GUI library.
What I found really interesting from a designers perspective is that the course proposed a structure to build up their, that does not differ too much to the solution proposed in the Code Companion. The course roughly teaches you to follow these 9 steps:
1. Import modules and libraries
2. Global variables
3. Create classes
4. Import assets
5. Create helper functions
6. Create event handlers
7. Initialise the program
8. Register event handlers
9. Start the program
Now I will not go into detail of these steps (follow the course), however I do find it interesting that they seem to map pretty close to the steps of the Code Companion: Blueprint. The difference is that in the Blueprint, you sketch the paths between states beforehand, whereas the course implies that this sketching happens during the process of programming. The Code Companion’s Blueprint has the following steps, and this is how I believe they relate to the previous 9 steps.
1. Program description (the weekly assignment)
2. Determine inputs and outputs
3. Define data (global variables, assets, libraries).
4. Define transformers (helper functions, classes)
5. Define conditions (event handlers)
6. Sketch the path from input to output (part of programming)
Seeing that the CC: Blueprint and the course show some overlap, I would deem this course really helpful for interaction designers that would like to step up from programming Arduino’s and want to go beyond simple I/O interaction. Although the steep learning curve, this course does allow you to better understand the world of programming, and how you can make your ideas tangible through programming. It really is the next step in deconstructing ideas into programmable solutions.
As a final note, this course came with a confronting realisation. There is no magic way to learn programming. It takes many hours of practice, and what I find most difficult after this course is finding a project for myself that is both fun and achievable tod further increase my skill. Most of the projects I imagine end up being overly complicated. If you have any suggestions, feel free to drop a line at email@example.com.
Downey, A.B., . How to think like a computer scientist: Python. Green Tea Press.
Paauwe, R. A. (2012). Programming for interaction designers: bridging the gap between design idea and code implementation. Delft University of Technology.
Warren, J., Rixner, S., Greiner, J., Wong, S. Coursera: An Introduction to Interactive Programming in Python. RICE University.