September 28th, 2017

What is a computer?

Summary of last week

Is a general purpose device that can

  • read, process and write numbers
    • (and things that can be represented by numbers)
    • to and from the memory
  • following a program stored also in the memory
    • many simple steps

Changing the program changes the purpose of the machine

Computers have bad memory

When they don’t have energy, they forget all

All data must be stored in secondary memory

Today secondary memory is

  • hard disk
  • USB stick
  • Cloud storage

Structure of secondary memory

The disks store a huge amount of data

To organize it we use files

To organize the files we use folders also called directories

Files

Like the main memory, a file is just a list of bytes

The meaning of the file depends on the context

Most of the times, the name of the file suggests a context

File attributes

Besides the data itself, files have metadata

That is, data about the data. For example

  • Files have a name
  • Files have a modification date, maybe other dates too
  • Files have a size
  • Files have permissions

File names

The names of the files are “words”: a serie of letters, numbers and some symbols

Technically, a filenames is a String or list of characters

Maximum length of a filename is 250 characters

Avoid /, :, +, |, <, *, > quotes

Use letters (A-Z, a-z), numbers (0-9), ., -, _,

File names

In some systems small caps and BIG CAPS are not equivalent. Be systematic and coherent

If the filename includes ., the text after it is called extension

In Microsoft Windows (c) extensions are usually 3 letters

  • EXE, JPG, DOC, XLS, TXT, CSV
  • These are hints on how to interpret the file

Kinds of file

At low level there is only one type of file

For us, it is useful to separate in two:

Text Files:
each byte is a character, we can read it
Binary Files:
bytes are grouped in binary numbers, representing images, sounds, etc.

Among binary files we have EXE files, which are programs for Windows

Representing text

The most natural way to represent a text document is to encode each letter with a single byte

There is a basic standard for English, called ASCII

Each number from 0 to 127 is either a symbol or a special signal, such as

  • New Line
  • End of Message
  • Tab
  • Space
  • Backspace

ASCII code

30 40 50 60 70 80 90 100 110 120
0 ( 2 < F P Z d n x
1 ) 3 = G Q \[| e | o | y 2| | | 4|\>| H| R|\\| f | p | z 3| !| +| 5| ?| I| S|\] g q {
4 " , 6 @ J T ^ h r |
5 # - 7 A K U i s }
6 $ . 8 B L V ` j t ~
7 % / 9 C M W a k u
8 & 0 : D N X b l v
9 ´ 1 ; E O Y c m w

Numbers between 128 and 255 are not used in ASCII

Non English languages use these values for symbols like “Ç”, “Ö”, “É”, “Ñ”

Text Files

  • are universal
  • are easy to read and write from a program
  • do not have any style like bold or italic
  • are like books without figures

Microsoft Word files (doc or docx) are NOT text files

You shall not use Word for this course

Example binary file

Example text file

Text files are for humans and computers

Text files are for humans and computers

  • Binary files are hard to read
    • unless you have the correct program
  • Text files can be read by humans
    • Each byte is a letter
  • Text files can be read by computers
    • Data must be recyclable
    • The output of one program is the input of another program