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.

64<br />

“Curly Bracket” Languages<br />

With great power comes great responsibility, and C is no exception. Because<br />

C programs can access every part of the computer’s hardware, C programs<br />

can fail dramatically by crashing other programs, including the entire operating<br />

system.<br />

The efficiency of C<br />

A C compiler tends to create smaller, faster, more efficient programs than<br />

compilers <strong>for</strong> other <strong>programming</strong> languages. The reason is that the C language<br />

is much simpler and thus easier to translate into equivalent machine<br />

language commands.<br />

What makes the C language simpler is its small number of commands or keywords.<br />

Keywords are special commands used in every <strong>programming</strong> language.<br />

The more keywords a <strong>programming</strong> language uses, the fewer commands you<br />

need to make the computer do something. The fewer keywords a <strong>programming</strong><br />

language offers, the more commands you need to make the computer<br />

do something.<br />

Think of keywords like words in a human language. The fewer words you know,<br />

the more limited your communication is. If a little kid only knows the word hot,<br />

he can only express himself in a limited manner, such as describing something<br />

as very hot, a little hot, or not so hot. However, if a kid knows a lot of different<br />

words, he can express himself much better. Rather than use two or more words<br />

to describe something as very hot, a little hot, or not so hot, a kid with a richer<br />

vocabulary could describe the same items as scalding, warm, or cool.<br />

A <strong>programming</strong> language with a lot of keywords means you can write a program<br />

with fewer commands. That’s great from the programmer’s point of<br />

view, but inefficient from the computer’s point of view.<br />

The more keywords used in a language, the more work the compiler needs to<br />

do to translate all these keywords into machine language. As a result, programs<br />

written in languages that use a lot of keywords tend to run much slower than<br />

programs written in C.<br />

A C program compiles to smaller, more efficient machine language commands<br />

because instead of offering a large number of keywords, the C language<br />

offers just a handful of keywords. This makes it easy <strong>for</strong> a compiler to<br />

translate the limited number of keywords into machine language.<br />

However, as a programmer, you need to use C’s limited number of keywords to<br />

create subprograms that mimic the built-in commands of other <strong>programming</strong><br />

languages. Because this can be impractical, the C language often includes<br />

libraries of subprograms that mimic the built-in commands of other <strong>programming</strong><br />

languages.

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

Saved successfully!

Ooh no, something went wrong!