1. computers - uni-weimar.de file1. computers prof. dr. charles wüthrich mfa gianluca pandolfo,...
TRANSCRIPT
1. Computers
Prof. Dr. Charles Wüthrich MfA Gianluca Pandolfo, CoGVis/MMC, Faculty of Media Bauhaus-University Weimar
A Computer
• From a young age, today people are used to use one or more computers
October 2017 Charles Wüthrich 2
A Computer
• From a young age, today people are used to use one or more computers
October 2017 Charles Wüthrich 3
A Computer
• From a young age, today people are used to use one or more computers
October 2017 Charles Wüthrich 4
Cou
rtesy
Bun
desa
rchi
v
What makes a computer?
October 2017 Charles Wüthrich 5
A minimal computer
October 2017 Charles Wüthrich 6
Processor
A minimal computer
October 2017 Charles Wüthrich 7
Memory
Processor
A minimal computer
October 2017 Charles Wüthrich 8
Memory
Processor
I/O
A minimal computer
October 2017 Charles Wüthrich 9
Memory
Processor
I/O
Hardware
A minimal computer
October 2017 Charles Wüthrich 10
Memory
Processor
I/O
Hardware
A less minimal computer
October 2017 Charles Wüthrich 11
Memory
Processor
I/O O
pera
ting
Syst
em (O
S)
Hardware
A less minimal computer
October 2017 Charles Wüthrich 12
Memory
Processor
I/O O
pera
ting
Syst
em (O
S)
Hardware
A more realistic computer
October 2017 Charles Wüthrich 13
Memory
Processor
I/O O
pera
ting
Syst
em (O
S) Harddrive …
Bus
Hardware
A not quite so minimal computer
October 2017 Charles Wüthrich 14
Memory
Processor
I/O
Ope
ratin
g Sy
stem
(OS)
Gra
phic
al U
ser I
nter
face
GU
I
HD ..
Bus
A not quite so minimal computer
October 2017 Charles Wüthrich 15
The file system
• All data organized in a file system (on your HD) like a tree
• Root directory: / • Subdirectories:
– /dir1/ /dir2/ …"
• Subsubdirectories – /dir1/sub1 /sub2 /… /dir2/sub1 /sub2 /… … and so on..."
October 2017 Charles Wüthrich 16
Command Line Interface (CLI)
• All systems have a Command Line Interface where you can type commands for the computer Mac: Terminal"
October 2017 Charles Wüthrich 17
Moving in the file system
• Change directory you are working at: from the CLI type cd "
• Example: cd / "
• Current directory: ."
• Up directory.. cd ..
October 2017 Charles Wüthrich 18
Listing files
• From any directory position: ls"
• Example: ls ./introcs/ ArtistsLoveJava.java "hello " "lovejava checkstyle-5.5 " "java3d" "stdlib.jar findbugs-2.0.3 " "log.txt"
• Lists the subdirectory of the current directory named introcs
"
October 2017 Charles Wüthrich 19
Editing files
• You will need an editor application, such as: nano emacs . . . ."
• Example: nano myfile.txt "
October 2017 Charles Wüthrich 20
My first program
October 2017 Charles Wüthrich 21
Compiling my first program
October 2017 Charles Wüthrich 22
Compiling my first program
• Compiling: a “translator” compiles your high level code into a now level code understandable by the machine
• A compiler does exactly this, and achieves machine (or in our case java virtual machine) executable code
• This code is then ready to be “executed” by the machine so as to “run” your instructions
October 2017 Charles Wüthrich 23
Running my first program
October 2017 Charles Wüthrich 24
My first program (IDE)
October 2017 Charles Wüthrich 25
My first program
October 2017 Charles Wüthrich 26
Errors
• When you write a program there are three types of errors that can happen – Compile time: the compiler cannot understand the code you
typed in because it does not conform to the syntax – Execution time: the machine tries to execute the code you
wrote (which compiles correctly). • Possible causes: Division by zero, trying to touch things that
you are not allowed to touch (in the system) – Logical errors: most difficult to catch.
Wrong results, program behaves erratically…. Catching these is both frustrating and rewarding.
October 2017 Charles Wüthrich 27
Controlling (a bit) Input and Output
• I’d like to discuss with you a new simple program:
• This time, the program has more lines • The computer starts at the main line, and executes
each of the 3 lines one after the other • What do these lines do?
October 2017 Charles Wüthrich 28
Controlling (a bit) Input and Output
• The first line simply prints the content of the brackets in the CLI
October 2017 Charles Wüthrich 29
Controlling (a bit) Input and Output
October 2017 Charles Wüthrich 30
• The second line prints a thing which is called “args[0]” • And who is this?
Controlling (a bit) Input and Output
October 2017 Charles Wüthrich 31
• The second line prints a thing which is called “args[0]” • And who is this? • For now, to you, “args[0]” contains the first thing you
typed after calling the program name when you run the code: java ReadArgument sillycreature
Controlling (a bit) Input and Output
• The second line prints a thing which is called “args[0]” • And who is this? • For now, to you, “args[0]” contains the first thing you
typed after calling the program name when you run the code: java ReadArgument sillycreature will contain “sillycreature”
October 2017 Charles Wüthrich 32
Controlling (a bit) Input and Output
• The third line prints “and yours?” • So what is the result if we type
java ReadArgument worms in the console?
October 2017 Charles Wüthrich 33
Controlling (a bit) Input and Output
October 2017 Charles Wüthrich 34
My favourite pets are worms. And yours?
Controlling (a bit) Input and Output
October 2017 Charles Wüthrich 35
My favourite pets are worms. And yours?
• Notice the different use of “print” and “println”
+++ Ende - The end - Finis - Fin - Fine +++ Ende - The end - Finis - Fin - Fine +++
End