מה זה C?
שפת מכונה, אסמבלי ושפה עילית, המהדר ובעיית הניידות, איך C נולדה יחד עם Unix ב־Bell Labs, ואיפה משתמשים ב־C היום.
השיעור הזה כתוב באנגלית בלבד.
Where C lives
Look at the devices around you: a phone and its charger, a smartwatch, a car, an ATM. Each one has a small computer inside, a microcontroller (מיקרו־בקר), that runs a program. The phone charger's program decides how much current to give the battery. The smartwatch reads its sensors and watches its battery. The car's engine control unit (ECU) controls the engine and the safety systems. A large share of these programs are written in C.
What is C?
C is a general-purpose programming language, created by Dennis Ritchie at Bell Labs in 1972. It is popular because:
- it is fast and runs on almost every kind of computer;
- it shows how programs work "under the hood", close to the hardware;
- it is a basic language of computer science: many other languages and tools are built on it;
- it is closely connected to the Unix operating system, which was written in it.
A two-minute overview (it moves fast; you will understand more of it at the end of the course):
To understand why C was invented, we start at the bottom: what the processor itself runs.
Layer 1: machine code
A processor runs machine code (שפת מכונה): instructions written as patterns of bits. Here are two bytes of machine code:
10110000 01100001On a PC processor (the x86 family) these two bytes mean "put the number 97 in register AL". The first byte is the instruction, the second byte is the number: 01100001 in binary is 97.
Machine code:
- is a list of bit patterns;
- is run directly by the processor;
- belongs to one family of processors: each family has its own patterns;
- is very hard for people to read and to fix.
The same bits can mean something different on another kind of processor. A phone's processor (the ARM family) would read 10110000 01100001 as a different instruction.
Layer 2: assembly language
Assembly language (שפת סף, אסמבלי) gives each bit pattern a short name. Instead of remembering 10110000, a programmer writes MOV. Each line is one processor instruction:
MOV R0, #5 ; put 5 in register R0
ADD R0, R0, #3 ; R0 = R0 + 3A register (אוגר) is a small storage place inside the processor. After the first line R0 holds 5; after the second line it holds 8. Other short names: ADD (add), JMP (jump to another line).
The portability problem
Assembly is easier than bits, but it is still tied to one family of processors. A program written in the assembly language of machine A does not run on machine B, which has a different processor and different instructions.
Imagine a large program written in the assembly language of one processor. The company buys a new computer with a different processor, and much of the program must be written again. Making a program run on other machines is called portability (ניידות). Assembly programs are not portable.
Layer 3: high-level languages
A high-level language (שפה עילית) is close to English and to mathematics. Here is one multiplication at all three layers:
| Layer | The same multiplication |
|---|---|
| 3. High-level (C) | total = price * quantity; |
| 2. Assembly (ARM) | MUL R2, R0, R1 |
| 1. Machine code (ARM) | 11100000 00000010 00000001 10010000 |
(The full assembly program also needs lines that bring price and quantity into registers and store the result in total. In C it is one line.)
A high-level language is:
- easier to read;
- easier to write and to fix;
- able to say bigger ideas in one line;
- translated into machine code by a compiler.
C is a high-level language. This whole course is in layer 3.
The compiler
The text you write is called source code (קוד מקור). In this course it is a file named main.c. A compiler (מהדר) reads the source code, checks it for mistakes, and translates it into machine code:
Source code (main.c) → compiler → machine code (a file the processor can run)
This also solves the portability problem: write the program once in C, and use a compiler for each kind of processor. One compiler makes machine code for a PC, another makes machine code for a phone, both from the same main.c.
The video explains the difference between a compiler, which translates the whole program before it runs, and an interpreter, which translates while it runs. C uses a compiler.
Bell Labs and Unix
In the 1960s, computers were expensive and hard to use. Bell Labs, the research lab of the American phone company, took part in a large operating-system project called Multics. After Bell Labs left the project, two of its researchers, Ken Thompson and Dennis Ritchie, kept some of its ideas and wanted a simpler working environment.
In 1969 Ken Thompson began building the system that became Unix, on a small DEC PDP-7 computer. Unix managed files, ran programs and let people work with the computer: it is an operating system (מערכת הפעלה). The first Unix was written in assembly.
Assembly worked, but it was:
- hard to develop;
- hard to maintain;
- tied to one machine;
- hard to move to new hardware.
Unix needed a new language.
From BCPL to B to C
| Language | Who and when | What it added |
|---|---|---|
| BCPL | 1960s | an earlier language for writing system software |
| B | Ken Thompson, 1969 | built on BCPL's ideas; ran on the early Unix machines, but did not fit the newer PDP-11 computer well |
| C | Dennis Ritchie, 1972 | added data types and what Unix needed |
C combines two things:
- High-level structure: variables, functions, conditions, loops and structured data. We learn all of these in this course.
- Low-level control: close control over memory and hardware.
Unix rewritten in C
In 1973 most of Unix was rewritten in C. Only small parts that depend on the machine stayed in assembly. This was unusual: people expected an operating system to need assembly.
The result: to move Unix to a new computer, you rewrote only the small assembly parts and compiled the rest. Unix became much more portable, and C and Unix helped each other spread. Linux, macOS and Android all come from this line of systems.
Where is C used?
C is used when software must work close to the hardware:
- microcontrollers and embedded systems (מערכות משובצות): a computer inside a device;
- operating systems and device drivers;
- cars and robots;
- communication and network equipment;
- medical and industrial devices;
- databases, compilers and system libraries.
Why C? It is fast, small, predictable, and it gives hardware control. A small microcontroller has little memory, a slow processor and strict timing. C lets engineers control memory, single bits and hardware registers, with programs that need very few resources.
C today
In January 2026, C was the second most popular programming language in the world on the TIOBE index, behind only Python, and TIOBE pointed to embedded systems as the reason.
C also shaped other languages. C++ and Objective-C grew directly out of C, and the style of C (braces, semicolons, operators) shaped Java, C#, JavaScript, Go and Rust. If you can read C, you can read much of them.
Jobs that use C include embedded software developer, firmware engineer, real-time software engineer, Linux systems or driver developer, robotics and control engineer, communication systems engineer, and hardware validation engineer.
How does programming work?
A programmer works in five steps:
- Define the problem: understand what must be solved.
- Plan a solution: break the task into small steps, an algorithm.
- Write the code in a programming language.
- Test and debug: make sure the program does what it should.
- Run the program: look at the results and improve.
Steps 4 and 5 often send you back to step 3. The whole chain looks like this:
Programmer → high-level code → compiler → machine code → the computer runs it
Key words
| English | Hebrew | Meaning |
|---|---|---|
| machine code | שפת מכונה | bit patterns the processor runs |
| assembly language | שפת סף (אסמבלי) | short names for processor instructions |
| high-level language | שפה עילית | a language close to English and math, like C |
| compiler | מהדר | translates source code into machine code |
| source code | קוד מקור | the text the programmer writes |
| portability | ניידות | the program can run on other machines |
| register | אוגר | a small storage place inside the processor |
| operating system | מערכת הפעלה | the program that runs the computer: Unix, Linux, Windows |
| microcontroller | מיקרו־בקר | a small computer on one chip |
| embedded system | מערכת משובצת | a computer inside a device |
Practice
More questions, with answers, are on the unit 1 practice page.