62 Teaching Languages Figure 3-4: Using a battle robot to study programming can make programming more exciting. Instead of writing a program just to control a robot, these games force you to write a program to move a robot on-screen, search for other robots nearby, and then attack those other robots with a cannon. After you finish your program, you can see the results by watching your robot battle another robot in a gladiator-style battle. Write a “good” program, and your robot can defeat another robot. Write a “bad” program, and your robot gets blasted into chunks of (virtual) charred metal. To program a “battling robot,” use a simplified version of a popular programming language, such as Java or C++. That way you not only figure out the basics of a popular programming language, but you can also start writing “real” programs that actually do something interesting right from the start. Table 3-1 lists some popular “battling robot” programming games. Table 3-1 Popular “Battling Robot” Programming Games Program Name Language Used Where to Find It Robocode Java http://robocode.sourceforge.net C++ Robots C++ http://www.gamerz. net/c++robots CRobots-3D C http://antru.ru/crobots3d

“Curly Bracket” Languages 63 “Curly Bracket” Languages If you know BASIC or Pascal, you can rush out and start writing programs without ever needing to know another programming language again for the rest of your life. However, it’s far more common for programmers to know two or more programming languages. Typically, the one language that most programmers know is one that belongs to a family of related languages known as the “curly bracket” family. The “curly bracket” language family gets its name because they use curly brackets to define the start and ending of a block of commands, such as Book I Chapter 3 Types of Programming Languages #include void main() { printf(“Notice how the curly brackets\n”); printf(“identify the beginning and end\n”); printf(“of your commands?\n”); } Rather than use curly brackets, many other programming languages use descriptive words, like Begin or End, to identify the start and end of a block of code. The most popular “curly bracket” language is C. The C language is popular for several reasons: ✦ Power ✦ Efficiency ✦ Portability The power of C The C language is a curious combination of assembly language and high-level languages, like BASIC. Like assembly language, C provides commands for directly manipulating every part of the computer, including memory, hard disks, and printers. Like a high-level language, C lets you focus on the logic of your program without worrying about the technical details of the computer so you get the best of both assembly language and high-level languages. Because C programs are nearly (note the emphasis on the word “nearly”) as easy to write and understand as high-level languages but still give you the power of accessing the computer’s hardware like assembly language, C is often used for creating large, complicated programs (such as operating systems and word processors) along with more exotic programs (like antivirus utilities or disk diagnostic programs).