Introduction

Sections:

Introduction

Yay! You made it to the first lesson! This lesson is that obligatory kinda unimportant and boring lesson that covers the various overview stuff that you sorta knew at the back of your head. I’ll try to keep things brief, and you definitely don’t have to memorise the stuff in here, but it is generally important that you have a rough idea of this stuff.

So, what actually is a program? A program is a series of very specific instructions for a computer to carry out, one at a time.

Languages

So great. A program is a series of instructions. But how do you give the computer those instructions? Well, you’ve got to give it the instructions in a way it can understand.

A programming language sets out well-defined ways for people to write the instructions in a way that the computer can understand them. They have a set-of well defined syntax and also some useful features to make your life easier.

Different languages are used for different things. Some common ones are:

Most languages share common ideas, but with slight differences and extra features. All the ideas taught in this guide are shared throughout common desktop programming langagues, such as Java, Python or C++, and they’re also applicable in some of the other languages like javascript.

For example, both Python and Java let you send messages to the console. In Java this is

System.out.println("The Message");

While in python it is

print("The Message")

Although their are slight differences, the central idea of sending a message to the console is present in both. It is only the syntax that has changed.

Note: While we’re on the subject their is a big difference between java and javascript. Java is a programming language for running programs on your computer, such as Minecraft. Javascript is a website thing and allows websites to do dynamic things, like facebook letting you click on pictures and Gmail letting you open emails and stuff (without reloading the page)

## Syntax and Thinking programmaticaly So on the surface, initally programming can seem to be about syntax. Syntax is how you write the instructions, and initially learning to program will mean learning how to talk to the computer - i.e. how to syntax.

However, syntax isn’t really programming. Programming is about thinking logically about solving problems, and the tasks needed to do so. We’ll cover this more in Algorithims, but esentially most of programming is:

 I want computer to do x.
 What steps do I tell the computer to do such that it does x?

It’s important to learn how to think programmaticaly, solving problems logically. The activiteis at the bottom of the page should try to do this, so it’s important that you do them!

## Compilers So ultimately computers just work with electrical currents representing 0s and 1s. How do your instructions, written in semi-english, end up giving these low-level instructions?

Well, programs get compiled. Compilers are programes which convert your human-readable code into bytecode, that a machine can use and execute.

Java and C++ are both high-level compiled languages.

Note: Some other languages, like python, are interpreted. This means that an intrepreter reads the code line by line and decides what to do then. This runs a bit slower, but does have some other (mystical) benefits.

Libraries

Libraries are bits of code other people have published that do useful things for you. For example, one common library is unirest. Unirest manages making API calls to websites. I’ve used unirest for the TBA scraper. I don’t have to worry about knowing how to make internet calls getting data - I just use the Unirest library, and let it take care of that for me. Some common libraries we use are WPILib (does code for robot motors and stuff, published by FIRST), Arachne (our own library that makes WPILib easier to use) and OpenCV (computer vision stuff).

Setup

So, this section will get you setup with all the differnet things you need to program. Firstly:

  1. Eclipse - Eclipse is an IDE (integrated development environment) and makes Java programming easier. This is where you’ll do most Java devlopment. To Install it:
    1. Make sure you have Java installed. If you don’t , install it from https://java.com/download
    2. Download and install eclipse. You can get it from https://www.eclipse.org/downloads/. Just click on the big orange download button. Then click on the next big orange download button. Then download and run it.
    3. In the installer, when it asks you to choose, select “Eclipse IDE for Java Developers” (the first one). Click install and… install it.

2. Github! Git is a system which manages changes to code, letting multiple people work on the same code at the same time. Github is a website which stores (git) code, sorta like Google Drive… but for code. We store our code on Github in an organization repository (we also store this tutorial there, if you haven’t noticed!). So… 1. If you haven’t already, create a new Github account. You want a free account. Note that later on we have tutorials on using Git, so you don’t really need to use theirs. 2. Once you’ve made your account, click the drop down next to the weird auto-generated profile pic in the top right corner, and go “Your profile” 3. Go “Edit Profile” and Add your Name so that we know who you are in the organization and stuff. You can also add any other features you want. 4. Let us know your username so we can invite you to the “Team4613-BarkerRedbacks” organization that we use for our code. 5. Download & Install Github Desktop - https://desktop.github.com/. Github Desktop installs Git and a GUI for it on your computer. This lets you easily download, change, and upload changes to code from your computer. If it’s taking a while to download, you can move on, you won’t need it right now but you will soon. FYI I’ve had problems installing it at school before, but it worked when I tried at home, so if it dosen’t work for you that could be it.

Don’t worry about setting up a github account right now. Just download eclipse (and Java).