15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

16<br />

The History of Computer Programming<br />

So given these advantages of C or high-level languages, why would anyone<br />

ever use machine language or assembly language? The answer is simple:<br />

speed and efficiency.<br />

If you want to write the smallest, fastest program possible, use machine<br />

language because machine language is the native language of all computers.<br />

Un<strong>for</strong>tunately, machine language is so hard to understand, write, and modify<br />

that writing anything but small programs in machine language is nearly<br />

impossible.<br />

Rather than use machine language, most programmers use assembly language<br />

when they need speed and efficiency. Assembly language creates small and<br />

fast programs, but they’ll never be as small or fast as machine language programs.<br />

That’s because processors understand only machine language, so<br />

when you write an assembly language program, you have to translate that<br />

assembly language program into machine language.<br />

Translating assembly language into machine language by hand would be<br />

slow and error-prone, so computer scientists have created special programs<br />

that can do this automatically. These programs are assemblers.<br />

An assembler takes an assembly language program and converts it into machine<br />

language, but this conversion process isn’t perfect. That’s why assembly language<br />

tends to create bigger and slower programs than equivalent hand-crafted<br />

machine language programs. However, assembly language programs are much<br />

easier to write and modify later than machine language, so assembly language is<br />

used much more often than machine language.<br />

High-level languages are much easier to write and understand than machine<br />

or assembly language. The problem is that processors don’t understand<br />

high-level languages either, so you have to translate a high-level language<br />

program into equivalent machine language commands.<br />

Doing this by hand is nearly impossible, so computer scientists have created<br />

special programs — compilers — to do this <strong>for</strong> them. A compiler does nothing<br />

more than take a program written in a high-level language and translates<br />

it into equivalent commands written in machine language.<br />

This translation process isn’t perfect so that’s why programs written in highlevel<br />

languages tend to be much bigger and slower than equivalent programs<br />

written in machine or assembly language. So when programmers want to create<br />

large, complicated programs that still run fast and take up as little space as<br />

possible, they tend to rely on the C <strong>programming</strong> language. That’s why so many<br />

programs are written in C because C creates programs nearly as small and fast<br />

as assembly language programs, while also being nearly as easy to write and<br />

understand as high-level languages. (Note the emphasis on the word “nearly.”)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!