https://elinux.org/api.php?action=feedcontributions&user=Timo&feedformat=atomeLinux.org - User contributions [en]2024-03-28T14:49:52ZUser contributionsMediaWiki 1.31.0https://elinux.org/index.php?title=RPi_Education/Manual&diff=122774RPi Education/Manual2012-04-24T12:36:48Z<p>Timo: Hierarchy corrected.</p>
<hr />
<div>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 [http://www.raspberrypi.org/forum/educational-applications/the-official-raspberry-filling-call-for-contributions Raspberry Pi forum] posting.<br />
<br />
<br />
=intro=<br />
==general==<br />
The objective is to educate people in computer science. <br />
==hardware==<br />
cheap hardware with 1/2 open specifications allow the masses to learn modern computer science.<br />
# plug in your rpi to your monitor with the hdmi and usb cable<br />
# plug in your mouse and keyboard to your monitor<br />
# plug in your monitor power and turn it on.<br />
==software==<br />
Linux is used, it is open source, user friendly, and technically capable. <br />
==language selection==<br />
beginners should select a high level language. Advanced users may select different languages combinations depending on the available libraries, programming paradigm, and optimizations.<br />
<br />
All code is executed in binary assembled from assembly code compiled from a language sometimes in-turn compiled from other higher level languages. <br />
<br />
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.<br />
<br />
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: <br />
==bash==<br />
bash is the language of the terminal.<br />
<br />
# open the termonal application<br />
# type: '''echo Hello world!''' <br />
<br />
That was a computer program,<br />
<br />
if you want to learn more about the echo command you can type '''man echo''' (press '''q''' to quit) <br />
<br />
now let's make it a runnable file:<br />
<br />
# '''nano hi.sh'''<br />
# '''echo Hello $1!''' <br />
# '''[Ctrl]+[x],[y],[enter]'''<br />
# '''bash hi.sh Tux'''<br />
<br />
(vim, and gedit are other editors you may with to use.)<br />
==python==<br />
<br />
make a file called '''hi.py''', put '''print("Hello, world!")''' in it and run it with '''python hi.py''' <br />
<br />
now a GUI version:<br />
<br />
...//TODO format code in wiki...<br />
<br />
=beginning=<br />
<br />
features libraries and limitations <br />
<br />
==Python==<br />
<br />
==C/C++==<br />
<br />
C and C++ are often put together, but are indeed two similar but different languages.<br />
<br />
===C===<br />
----<br />
<br />
===C++===<br />
----<br />
<br />
For starters the famous "Hello world!" example. Save the following code in a file called <tt>helloworld.cpp</tt> in a directory of your choice (e.g. <tt>~/cpp</tt>). The filename can be chosen arbitrarily, but should describe the content.<br />
<br />
<syntaxhighlight lang="cpp"><br />
//Compile with: g++ helloworld.cpp -o helloworld<br />
#include <iostream><br />
<br />
using namespace std;<br />
<br />
int main () {<br />
cout << "Hello world!" << endl;<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
Open a terminal and switch to the directory, which contains the saved file.<br />
<br />
<tt>cd ~/cpp</tt><br />
<br />
Make sure with <tt>ls</tt> that you are in the correct directory. It should output <tt>helloworld.cpp</tt> and all other files in this directory (if any).<br />
<br />
Now it is time to translate your code so your computer can understand it. This is called compiling.<br />
<br />
<tt>g++ helloworld.cpp -o helloworld</tt><br />
<br />
If everything went ok, nothing is printed. Now run your program.<br />
<br />
<tt>./helloworld</tt><br />
<br />
This outputs <tt>Hello world!</tt> on the command line.<br />
<br />
==Java==<br />
<br />
=intermediate=<br />
<br />
useful tools and fun toys.<br />
<br />
==bash==<br />
==Python==<br />
==C/C++==<br />
==perl==<br />
==Java==<br />
==Scratch==<br />
==Greenfoot==<br />
==Geogebra==<br />
<br />
=advanced=<br />
<br />
algorithms, heuristics, design patterns, and optimization<br />
<br />
==hardware==<br />
==assembly==<br />
==drivers==</div>Timohttps://elinux.org/index.php?title=RPi_Education/Manual&diff=122732RPi Education/Manual2012-04-24T11:23:55Z<p>Timo: C++ hello world example</p>
<hr />
<div>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 [http://www.raspberrypi.org/forum/educational-applications/the-official-raspberry-filling-call-for-contributions Raspberry Pi forum] posting.<br />
<br />
<br />
=intro=<br />
==general==<br />
The objective is to educate people in computer science. <br />
==hardware==<br />
cheap hardware with 1/2 open specifications allow the masses to learn modern computer science.<br />
# plug in your rpi to your monitor with the hdmi and usb cable<br />
# plug in your mouse and keyboard to your monitor<br />
# plug in your monitor power and turn it on.<br />
==software==<br />
Linux is used, it is open source, user friendly, and technically capable. <br />
==language selection==<br />
beginners should select a high level language. Advanced users may select different languages combinations depending on the available libraries, programming paradigm, and optimizations.<br />
<br />
All code is executed in binary assembled from assembly code compiled from a language sometimes in-turn compiled from other higher level languages. <br />
<br />
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.<br />
<br />
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: <br />
==bash==<br />
bash is the language of the terminal.<br />
<br />
# open the termonal application<br />
# type: '''echo Hello world!''' <br />
<br />
That was a computer program,<br />
<br />
if you want to learn more about the echo command you can type '''man echo''' (press '''q''' to quit) <br />
<br />
now let's make it a runnable file:<br />
<br />
# '''nano hi.sh'''<br />
# '''echo Hello $1!''' <br />
# '''[Ctrl]+[x],[y],[enter]'''<br />
# '''bash hi.sh Tux'''<br />
<br />
(vim, and gedit are other editors you may with to use.)<br />
==python==<br />
<br />
make a file called '''hi.py''', put '''print("Hello, world!")''' in it and run it with '''python hi.py''' <br />
<br />
now a GUI version:<br />
<br />
...//TODO format code in wiki...<br />
<br />
=beginning=<br />
<br />
features libraries and limitations <br />
<br />
==Python==<br />
==C/C++==<br />
<br />
C and C++ are often put together, but are indeed two similar but different languages.<br />
<br />
=C=<br />
<br />
=C++=<br />
<br />
For starters the famous "Hello world!" example. Save the following code in a file called <tt>helloworld.cpp</tt> in a directory of your choice (e.g. <tt>~/cpp</tt>). The filename can be chosen arbitrarily, but should describe the content.<br />
<br />
<syntaxhighlight lang="cpp"><br />
//Compile with: g++ helloworld.cpp -o helloworld<br />
#include <iostream><br />
<br />
using namespace std;<br />
<br />
int main () {<br />
cout << "Hello world!" << endl;<br />
return 0;<br />
}<br />
</syntaxhighlight><br />
<br />
Open a terminal and switch to the directory, which contains the saved file.<br />
<br />
<tt>cd ~/cpp</tt><br />
<br />
Make sure with <tt>ls</tt> that you are in the correct directory. It should output <tt>helloworld.cpp</tt> and all other files in this directory.<br />
<br />
Now it is time to translate your code so your computer can understand it. This is called compiling.<br />
<br />
<tt>g++ helloworld.cpp -o helloworld</tt><br />
<br />
If everything went ok, nothing is printed. Now run your program.<br />
<br />
<tt>./helloworld</tt><br />
<br />
This outputs <tt>Hello world!</tt> on the command line.<br />
<br />
==Java==<br />
<br />
=intermediate=<br />
<br />
useful tools and fun toys.<br />
<br />
==bash==<br />
==Python==<br />
==C/C++==<br />
==perl==<br />
==Java==<br />
==Scratch==<br />
==Greenfoot==<br />
==Geogebra==<br />
<br />
=advanced=<br />
<br />
algorithms, heuristics, design patterns, and optimization<br />
<br />
==hardware==<br />
==assembly==<br />
==drivers==</div>Timo