Vous êtes sur la page 1sur 41

Introduction to computers and

programming
Content

Hardware Network
Information storage Protocols
RAM, ROM Packets
HD, DVD Programming
Display Algorithm
Images Pseudocode
Characters (fonts) Flowchart
File system/type Languages
Encryption Source code
Compression Example
The computer
Internally
The connections
Information storage

1 bit bit (1 or 0)
8 bits byte (octet) (28)
16 bits word (216)
32 bits double (232)
64 bits long double
(264)

Encodinginformationonafixedelementoflengthnwitha
basebgivesbnnonredundantpossibilities
Information coding

Binary How to count


1286432168421
0 or 1
10110101
Octal
0-7
128+32+16+4+1=
Hexadecimal 181 (decimal)
0-9+A-F 265 (octal)
B5 (hexadecimal)
Decimal
0-9 Signed vs unsigned
0 to 255
-127 to +127
Operations on bits

Booleans: Example tables


0 = false = no AN 0 1
D
1 = true = yes 0 0 0

Operators: 1 0 1
OR 0 1
AND 0 0 1

OR 1 1 1

XOR XOR 0 1
0 0 1
NOT
1 1 0
RAM/ROM
Memory mapping
Address Values Size reminder:
0000 10111001
Kilobyte Kb 210 ~103
0001 00001111
0002 11100011
Megabyte Mb 220 ~106
.. Gigabyte Gb 230 ~109
.. Terabyte Tb 240 ~1012
..
Petabyte Pb 250 ~1015

..
FFFF 00100100
HD/DVD

track

sector

head
Display
QuickTime et un
dcompresseur TIFF (non compress)
sont requis pour visionner cette image.

Screen pixel or dots Fonts


Color coding: 32 bits
1 pixel = 3 bytes of color
Bitmap
(RGB)+1 byte alpha channel Vectors
(transparency)
TrueType, OpenType,
1600x1200x4bytes=7,5 Mb!
PostScript
Keyboard/Mouse

Each key (or The mouse movements


combination of keys) of 1 to 4 bytes (vertical &
the keyboard sends a horizontal)
code to the computer. Buttons
The code is interpreted Clicked, pressed, rolled
and converted to the
corresponding ASCII or buttons
Unicode number.
ASCII & Unicode

ASCII 7/8 bits


Unicode
UTF-8/16/32 bits
ISO-8859 (Latin)

od -c od -h
Software layers

Files Data(.doc,.mp3)
Software Word,scripts,mail,webbrowser
UserInterface Quartz CLI,XWindows Windows
OperatingSystem MacOSX Linux Windows
ROM Firmware BIOS
Hardware CPU,RAM,HD,DVD
File systems

Method the OS uses to store information


Storage unit, directories, subdirectories
(Windows, VMS)
Single arborescence (Linux, MacOSX, all Unix)
What exactly is a file?
a piece of information (text, graphic, data,
music program, script)
it is identified by a name and an logical
address (or path)
other informations: date, size, type, creator,
ownership, physical address
File system organisation

Disk 1 Disk 2 Disk 2


C: D: /

DOCS PROGS CONFIG DATA Directories /usr /home


Disk 1
WORD EXCEL EXPT1 EXPT2 Subdirectories local phil john

bin lib

emacs X11

Windows Unix
Path

The path is the logical address used


by the system or the user to locate a
file.
Example:
/bd_du_Palais/35/etage/4/appart/12/Dupont_ Jean.txt

suffix
filename
path
File types

Executable Special cases in Unix


.exe STDIN
.app STDOUT
STDERR
Unix requires x
Data
Text (.txt)
Music (.mp3)
Image (.jpg, .gif)
Movie (.mpg, .mov)
Binary (.bin)
Encryption / compression

Compression
Reducing the size of files
E.g., .mp3, .gz, .jpg, .zip
Encryption
Protecting your privacy
E.g., .pgp
Packing
Grouping the files
E.g., .tar
Networks

Direct
USB 11Mb-480Mb
Ethernet 10Mb-1Gb

Wired
Modem 56Kb
ADSL 600Kb-8Mb
LAN 10Mb-10Gb

Wireless
Bluetooth 1Mb-20Mb
WIFI (AirPort) 11Mb-54Mb
Network (ethernet or
wireless)

Computer talk to Handshaking


each other via Transmission
network protocols Ackowledgement
ip, tcp, http, ftp,

TCP/IP DNS
Domain Name Server
transmission control
protocol/internet URL
protocol Universal Resource
Locator
IP addess
192.42.197.51
DNS reminder

2 Root DNS 3
*.org

5 4
Local DNS Primary DNS
dns.anywhere.net www.expasy.org

1 6
www.expasy.org ??

Client query Target server


client.anywhere.net 129.194.8.64
Packets

The data travels


within units called
packets
Packet breakout

UsualTCP/IPpayloadperpacket:512bytes
Introduction to programming
What is a program?

How to cook?
The algorithm
Are you a programmer?
Pseudocode

This is the pseudocode for a game of Monopoly


Flowcharts
Flowcharts details
Languages

Low level (processor dependent)


Machine code, assembler
High level: structured, procedural
Fortran, C, Pascal
High level: object oriented
C++, Java, C#, Perl, Objective-C
Virtual machines
Java, C#
Scripting
Perl, Python, JavaScript
Source code -> Object code

Compiler+linker Compiler+linker
Fortran, C, Pascal, C++ Fast to execute, but
slow to debug
Interpreter Interpreter
Basic, Perl Slow to execute, but
fast to debug (no need
to recompile)
Intermediate Intermediate
Java Slow
Source code

Instructions Data structures


Statement, blocks Variable
Affectation List
Operators Array
Loops Hash
Tests Pointers
Subroutines Objects
Comments
Source code (2)

Statement, blocks Variable


One or more A region in memory
instructions for the that can be modified
processor Exists in different
Affectation types
Change to a Scalar, char, numeric,
variable boolean
Operator List, array
Hash
affect one or more
Combination->data
variable structure
+ * - / AND OR NOT
Source code (3)

Loops Pointers
Allow the computer Reference to region
to repeat blocks in memory
Tests (address)
Decide what to do Objects
Subroutines Combination of data
Programs frequently and code
called (functions)
Comments
The most important
lines of the source
code
Example: a text to treat

Noon rings out. A wasp, making an ominous sound, a sound akin to a klaxon
or a tocsin, flits about. Augustus, who has had a bad night, sits up blinking and
purblind. Oh what was that word (is his thought) that ran through my brain all
night, that idiotic word that, hard as I'd try to pun it down, was always just an
inch or two out of my grasp - fowl or foul or Vow or Voyal? - a word in a quizz
which, by association, brought into play an incongruous mass and magma of
nouns, idioms, slogans and sayings, a confusing, amorphous outpouring which I
sought in vain to control or turn off but which wound around my mind a
whirlwind of a cord, a whiplash of a cord, a cord that would split again and
again, would knit again and again, of words without communication or any
possibility of combination, words without pronunciation, signification or
transcription but out of which, notwithstanding, was brought forth a flux, a
continuous, compact and lucid flow: an intuition, a vacillating frisson of
illumination as if caught in a flash of lightning or in a mist abruptly rising to
unshroud an obvious sign - but a sign, alas, that would last an instant only to
vanish for good.

Gilbert Adair
Result

a=97 n=91
b=15 o=104 Do you see any problem??
c=26 p=15
d=35 q=1
f=23 r=43
g=32
h=44
s=59
t=77
Try with this:
i=90 u=52
j=1 v=4
The quick brown fox,
k=5 w=31 jumps over the lazy dog.
l=33 x=2
m=17 y=13
z=2
Flowchart
Source code example

#!/usr/bin/perl -w # essential line of all perl scripts

$filename = "avoid.txt"; # affect avoid.txt to the variable $filename

# open the file, or exit


open(FILE, $filename) || die "Cannot open file $filename\n\n";
@text = <FILE>; # add each line of the file to an array
close FILE;

foreach $line (@text) { # read one line from the array into $line and repeat for each line
@table = split(//,$line); # read each character of the line in an array
while ($char=pop(@table)) { # read one character of the array 'table' and repeat for all
$char =~ s/[^a-z]//; # keep only the alphabetical character a to z
if ($char) { # check if the character exists and execute the block
$count{$char}++; # if yes, increment by one the hash 'count'
}
}
}

# print each character and its number of occurence one per line
foreach $c (keys %count) {
print "$c=$count{$c}\n";
}
exit; # quit the program
Tips

Think about your Test the code


problem For all the possible
Create a flowchart functions or cases
(if possible)
Create the Give it to users as a
pseudocode beta (if not possibe)
Verify the memory Sell it (if you work
used by your for Microsoft ;-)
variables Debug
Write the code
Summary of the week

Monday Wednesday
Intro computers & Object Oriented
programming programming
Intro Unix BioPerl
Tutorial Unix EMBOSS
Thursday
Tuesday
Database indexing
Intro Perl
BLAST
Regexp & Perl In-liners HTML & cgi-bin
Friday
Finish exercises
Users questions
Unix

Next presentation

Vassilios
alias
UnixMan!!
!

Vous aimerez peut-être aussi