Difference between revisions of "RPi Education/Manual"
Monojohnny (talk | contribs) (→bash) |
m (Spelling & Grammatical Fixes) |
||
Line 2: | Line 2: | ||
− | = | + | =Intro= |
− | == | + | ==General== |
The objective is to educate people in computer science. | The objective is to educate people in computer science. | ||
− | == | + | ==Hardware== |
− | + | Cheap hardware with 1/2 open specifications allow the masses to learn modern computer science. | |
− | # | + | # Plug in your RPi to your monitor with the hdmi and usb cable |
− | # | + | # Plug in your mouse and keyboard to your monitor |
− | # | + | # Plug in your monitor power and turn it on. |
− | == | + | ==Software== |
Linux is used, it is open source, user friendly, and technically capable. | Linux is used, it is open source, user friendly, and technically capable. | ||
− | == | + | ==Language Selection== |
− | + | Beginners should select a high level language. Advanced users may select different languages combinations depending on the available libraries, programming paradigm, and optimizations. | |
All code is executed in binary assembled from assembly code compiled from a language sometimes in-turn compiled from other higher level languages. | All code is executed in binary assembled from assembly code compiled from a language sometimes in-turn compiled from other higher level languages. | ||
Line 19: | Line 19: | ||
There are 2 main interfaces for most all applications in linux CLI, and GUI, while GUIs are user friendly CLIs are more simple to build and can be used as building blocks for more complicated tools/toys. | There are 2 main interfaces for most all applications in linux CLI, and GUI, while GUIs are user friendly CLIs are more simple to build and can be used as building blocks for more complicated tools/toys. | ||
− | + | It is considered good programming to use an iterative approach, using existing tools and patterns as much as possible, as such it is customary to start with a hello world: | |
− | == | + | ==Bash== |
− | + | Bash is the language of the terminal. | |
# open the termonal application | # open the termonal application | ||
Line 30: | Line 30: | ||
That was a computer program, | That was a computer program, | ||
− | + | If you want to learn more about the echo command you can type '''man echo''' (press '''q''' to quit) | |
<tt> | <tt> | ||
Line 36: | Line 36: | ||
</tt> | </tt> | ||
− | + | Now let's make our program into runnable file: | |
# '''nano hi.sh''' | # '''nano hi.sh''' | ||
Line 56: | Line 56: | ||
(vim, and gedit are other editors you may with to use.) | (vim, and gedit are other editors you may with to use.) | ||
− | == | + | ==Python== |
− | + | Make a file called '''hi.py''', put '''print("Hello, world!")''' in it and run it with '''python hi.py''' | |
− | + | Now a GUI version: | |
...//TODO format code in wiki... | ...//TODO format code in wiki... | ||
− | = | + | =Beginning= |
− | + | Features, libraries, and limitations. | |
==Python== | ==Python== | ||
Line 111: | Line 111: | ||
− | + | If all went well, there will no error messages and a new file called 'a.out' should have been created by the compiler. | |
<tt> | <tt> | ||
Line 167: | Line 167: | ||
==Java== | ==Java== | ||
− | = | + | =Intermediate= |
− | + | Useful tools and fun toys. | |
− | == | + | ==Bash== |
==C/C++== | ==C/C++== | ||
− | == | + | ==Perl== |
==Java== | ==Java== | ||
Create a text file called 'hello.java' with the following content: | Create a text file called 'hello.java' with the following content: | ||
Line 216: | Line 216: | ||
==Geogebra== | ==Geogebra== | ||
− | = | + | =Advanced= |
− | + | Algorithms, Heuristics, Design Patterns, and Optimization. | |
− | == | + | ==Hardware== |
− | == | + | ==Assembly== |
− | == | + | ==Drivers== |
Revision as of 10:19, 24 April 2012
Please add any contributions to the educational user manual here. These should take the form of step-by-step guides or listings with descriptions. Alternatively, email your contribution by taking a look at this Raspberry Pi forum posting.
Contents
Intro
General
The objective is to educate people in computer science.
Hardware
Cheap hardware with 1/2 open specifications allow the masses to learn modern computer science.
- Plug in your RPi to your monitor with the hdmi and usb cable
- Plug in your mouse and keyboard to your monitor
- Plug in your monitor power and turn it on.
Software
Linux is used, it is open source, user friendly, and technically capable.
Language Selection
Beginners should select a high level language. Advanced users may select different languages combinations depending on the available libraries, programming paradigm, and optimizations.
All code is executed in binary assembled from assembly code compiled from a language sometimes in-turn compiled from other higher level languages.
There are 2 main interfaces for most all applications in linux CLI, and GUI, while GUIs are user friendly CLIs are more simple to build and can be used as building blocks for more complicated tools/toys.
It is considered good programming to use an iterative approach, using existing tools and patterns as much as possible, as such it is customary to start with a hello world:
Bash
Bash is the language of the terminal.
- open the termonal application
- type: echo Hello World!
echo Hello World!
That was a computer program,
If you want to learn more about the echo command you can type man echo (press q to quit)
man echo
Now let's make our program into runnable file:
- nano hi.sh
- echo Hello $1!
- [Ctrl]+[x],[y],[enter]
- bash hi.sh Tux
bash hi.sh Tux
Which should ouput:
Hello Tux!
(vim, and gedit are other editors you may with to use.)
Python
Make a file called hi.py, put print("Hello, world!") in it and run it with python hi.py
Now a GUI version:
...//TODO format code in wiki...
Beginning
Features, libraries, and limitations.
Python
Create a text file called 'hello.py', with the following contents
print "Hello World!"
To run the program, type the following
python hello.py
It should respond with:
Hello World!
C/C++
C and C++ are often put together, but are indeed two similar but different languages.
C
Create a Text File called 'hello.c' which contains the following:
#include "stdio.h"
void main() {
printf("Hello World!\n");
}
Now compile the file using 'cc' , like this:
$ cc hello.c
If all went well, there will no error messages and a new file called 'a.out' should have been created by the compiler.
$ ls
hello.c
a.out
To run your program type:
$ ./a.out
It should report back with your message:
Hello World!
C++
For starters the famous "Hello world!" example. Save the following code in a file called helloworld.cpp in a directory of your choice (e.g. ~/cpp). The filename can be chosen arbitrarily, but should describe the content.
//Compile with: g++ helloworld.cpp -o helloworld
#include <iostream>
using namespace std;
int main () {
cout << "Hello world!" << endl;
return 0;
}
Open a terminal and switch to the directory, which contains the saved file.
cd ~/cpp
Make sure with ls that you are in the correct directory. It should output helloworld.cpp and all other files in this directory (if any).
Now it is time to translate your code so your computer can understand it. This is called compiling.
g++ helloworld.cpp -o helloworld
If everything went ok, nothing is printed. Now run your program.
./helloworld
This outputs Hello world! on the command line.
Java
Intermediate
Useful tools and fun toys.
Bash
C/C++
Perl
Java
Create a text file called 'hello.java' with the following content:
public class hello {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Now compile your file as follows:
$ javac hello.java
Notice how a new file was created after compilation:
$ ls
hello.class hello.java
To run your program:
$ java hello
It should respond with
$ Hello World!
Scratch
Greenfoot
Geogebra
Advanced
Algorithms, Heuristics, Design Patterns, and Optimization.