View on GitHub

REPL

The Learning Hub for UoL's Online CS Students

Go back to the main page

Table of contents


Introduction to Programming I

This module focuses on basic programming techniques. You’ll learn how to use the fundamental elements of computer programming such as variables, conditionals, functions and loops. You’ll learn how to create interactive, graphical computer programs. You will also be introduced to basic object-oriented programming techniques.

Professor(s)

Topics covered

Assessment

Coursework only (Type II)

Module specification

Recognition of Prior Learning

Syllabus

Resources

Essential reading

“There is no required textbook for this module. The module draws on number of different, largely web-based, public resources as well as the resources produced as bespoke material for this module. The programming language is Javascript, with the p5js library used for graphical and interactive programming functionality. The main external resource is the set of online tutorials available from: https://p5js.org/learn/.”

“Specific readings for each topic are listed with direct links to free online resources that provide additional material on the topics of this course.”

JavaScript

p5.js - JavaScript library
W3 Schools

Kinks to be aware of

:heart: Notes

On REPL (see relevant sections)

Sleuth assignments

Tips & Tricks
Utils and aids (student created)

The Game Project

Text editor

Configuring VS Code (optional)

This section is optional but recommended for your sanity in the long run as p5.js will be used in a few modules across this degree. You can certainly use VS Code as is without the need to install further extensions, but the following may make your life easier.

Extensions

VS Code supports JavaScript and its ecosystem by default, but you may want to enable more functionality by installing the following extensions:

Once you’ve gained some experience and confidence, you may want to try these as well:

p5.js autocompletion

To enable autocompletion for p5.js in a beginner-friendly way, you can install the extension p5.vscode. If you feel more adventurous and are looking for a challenge and some extra flexibility in your setup, please keep reading!

First install Node.js. Node is a JS runtime - a program that runs JS code. It’s not entirely unlike your browser’s JS engine - in fact, it is based on Chrome’s V8 engine - but it’s intended for servers and commandline programs rather than web pages. Its package manager, npm, is useful for setting up JS projects of any scale, so it’s a good tool to have if you’re going to work with JS. When you install Node, make sure to choose the option “add to PATH”, so you have Node and npm available throughout your system. Once Node and npm are installed, open Code and a commandline interface (cmd.exe or powershell.exe in Windows, Terminal in macOS), navigate to your project folder (eg. Documents/Goldsmiths/ITP1/Game_project) and follow these steps:

  1. Type the following command into your commandline: npm i --save-dev @types/p5 . This will tell npm to download type definitions for p5.js. You will notice that npm has created a node_modules folder and a couple of files, which it uses to track and manage downloaded packages; you needn’t worry about those at the moment (for more information on npm, see the npm Docs).
  2. In Code, create a new file with the following text, and save it to the project folder as jsconfig.json:
{
  "compilerOptions": {},
  "exclude": ["node_modules"],
}

This will let Code know that you’re working on a JS project and that it should expect some other configuration files like globals.d.ts to be present (for more configuration options, see the jsconfig.json reference).

  1. Create another file with this text, and save it to the project folder as globals.d.ts:
import {  } from "./node_modules/@types/p5/global";

This will import the type definitions you just downloaded into the global scope, allowing Code to autocomplete all of p5’s identifiers from anywhere in your code (for more information on global.d.ts, see the TypeScript documentation; for more information on p5.js’s modes, see p5.js’s Github wiki).

Conclusion

Congratulations! Now VS Code is all set up. Keep a copy of Code’s keyboard shortcut reference handy, and you’ll be a Code master in no time!