Computer programming: introduction Lessons

This class explains the basic components of computer programming. You'll explore many languages, varying from simple scripting to object-oriented programming. You'll examine database query and markup languages to help you understand how computers manipulate data and function across the internet. You'll also get coding examples you can use in the real world. 1. A brief history of programming languages: getting started In this lesson, you'll become familiar with types of programming languages, programming terminology and their uses. You'll also discover the essentials of programming, such as how the operating system compiles, interprets and executes commands.

2. Computer programming tutorial: learning parts of a program This lesson covers program structure. You'll learn how control statements, loops and conditional statements change the behavior of a program based on inputs or other conditions. You'll also discover how variables and constants manage your data. 3. Exploring subprograms and computer input and output This lesson introduces subprograms, functions and subroutines, which enable you to reuse commonly used portions of programs to save development time. You'll also learn about graphical user interfaces, which make working with your programs easier. 4. C, C++, C# and Java computer programming languages Some of the most popular full-featured programming languages today are C, C++, C# and Java. In this lesson, you'll learn a brief history of these languages and how to structure simple programs using them. 5. Beginning programming for the web A majority of programs written today are designed to work on the web. In this lesson, you'll learn about web programming technologies and languages, such as HTML, PHP and JSP. You'll also learn how XML exchanges data among different systems. 7. Programming for networks and mobile devices Knowing how to make computer programs that communicate with other systems over the web is essential today. This lesson covers basic networking concepts and programs that retrieve data from the internet, send email and interact with mobile devices.

6. Reading and storing computer data In this lesson, you'll learn the important programming concepts of data storage, file manipulation and memory management. You'll also learn how programs interact with databases to efficiently retrieve and store large quantities of data.

Welcome to Computer programming: introduction

A brief history of programming languages: getting started
Welcome to "Computer programming: introduction." For many of us, the world of programming reaches far and wide into our everyday lives. You might use a computer daily to write reports, play games, check your e-mail or process your company's financial records. In all of these

In this lesson, you'll become familiar with types of programming languages, programming terminology and their uses. You'll also discover the essentials of programming, such as how the operating system compiles, interprets and executes commands.  

8. Discovering your future as a professional programmer Get an introduction to the world of professional programming, starting with a survey of various kinds of digital systems. The class ends with a discussion of the environments and tools you work with as a professional programmer.

cases, you're using programs that people have written -- programs that perform a set of actions the programmers want the computer to do.

In this course, you'll learn the fundamental concepts of computer programming and discover how you can take the leap from using software provided by others to writing your own computer programs. You'll explore many languages, varying from simple scripting to objectoriented programming, while exploring topics such as logic, computer input and output and memory management. You'll also examine database query and markup languages to help you understand how computers manipulate data and function across the Internet. Finally, you'll discover real-world programming examples in a variety of languages, including C and Java. Here's what to expect in the lessons: This eight-lesson course is designed for beginning programmers. You should have a general familiarity with computers, but no prior programming knowledge is required.

Beyond the lessons, complete the accompanying assignments and quizzes, which are designed to help reinforce important concepts and topics.

What's programming?

Let's get started with the topics in Lesson 1.

Throughout this course, we provide Flash examples. To view these examples, you need the Adobe Flash Player. Keep an eye out for notes with links that say "See how to ____" or something similar. Some of these files are very large (10 MB or so) and may take a while to appear or download if you have a slow connection.

Lesson 1: A brief history of programming languages: getting started helps you become familiar with types of programming languages, programming terminology and their uses. You'll also discover the essentials of programming, such as how a computer compiles, interprets and executes commands. Lesson 2: Computer programming tutorial: learning parts of a program covers program structure. You'll learn how control statements, loops and conditional statements change the behavior of a program based on inputs or other conditions. You'll also discover how variables and constants manage your data. Lesson 3: Exploring subprograms and computer input and output introduces subprograms, functions and subroutines, which enable you to reuse commonly used portions of programs to save development time. You'll also learn about graphical user interfaces, which make working with your programs easier. Lesson 4: C, C++, C# and Java computer programming languages dives into some of the most popular full-featured programming languages today: C, C++, C# and Java. In this lesson, you'll learn a brief history of these languages and how to structure simple programs using them. Lesson 5: Beginning programming for the web describes how a majority of programs written today are designed to work on the Web. In this lesson, you'll learn about Web programming technologies and languages, such as HTML, PHP and JSP. You'll also learn how XML exchanges data among different systems. Lesson 6: Reading and storing computer data explains the important programming concepts of data storage, file manipulation and memory management. You'll also learn how programs interact with databases to efficiently retrieve and store large quantities of data. Lesson 7: Programming for networks and mobile devices describes how to make computer programs that communicate with other systems over the Web, which is essential today. This lesson covers basic networking concepts and programs that retrieve data from the Internet, send e-mail and interact with mobile devices. Lesson 8: Discovering your future as a professional programmer is an introduction to the world of professional programming, starting with a survey of various kinds of programming specialties. It continues with a discussion of the environments and tools you'll work with as a professional programmer.

Programming makes computers perform specific actions. For example, when you enter 2*7 on


a pocket calculator, you give the calculator a set of instructions. You're saying, "Multiply the number two by the number seven, and give me the result." Most simple calculators can interpret a limited number of commands, so there are only a few instructions you can give it. A computer, on the other hand, is capable of doing much more, and because of those capabilities, you have to give the computer more sophisticated instructions in the form of a programming language.

Programming language essentials

before electronics

A computer is essentially a machine that receives instructions and does something with those instructions. Like a calculator, it understands those instructions in a limited way. Computers don't (yet) understand English, Spanish, or French instructions; they only understand numbers. At the most basic level, they interpret sets of 1s and 0s, which are the equivalent of on and off, or true and false. This reliance on two states (1 or 0) is why computers are called binary systems.

The problem is, we humans think in terms of words and concepts, so programming languages were invented to mediate verbal concepts and binary mathematics. A computer, with the proper set of instructions, can translate words in a programming language into 1s and 0s, and then execute the program. As you'll see, the history of programming has involved different kinds of programming languages, some of which were almost as complex as typing numbers directly into the computer's memory and others that use somewhat common phrases and commands to enable programs to work. You might wonder why there are so many programming languages, but they all fit a need or solve a problem. Some are better suited for working with hardware devices, such as scanners or printers, whereas others are better for medical equipment, and still others for Web e-commerce.

The idea of mechanical aids to computation has been kicking around since way before electronics finally made generalpurpose computers practical. Probably the most famous try at a mechanical computer was Charles Babbage's Analytical Engine.

Learning the basics of programming

The language you choose for a given project depends on many factors, including which languages you know well. Still, there are many concepts that almost all languages have in common, which you'll see in the next section. Learning a new programming language is sometimes just a matter of learning new names for familiar concepts.

This course is designed to introduce you to the basics of programming so you have a good understanding of what programming is -- and what it isn't. You'll learn some standard programming terms and concepts that are used in all programming languages. When you're ready to learn a particular language, such as Java or C#, you'll already have a good understanding of programming itself and can focus on the specific language you want to learn.

The course lessons won't teach you how to program a particular language, although you'll get a glimpse of the inner workings of BASIC, C, Java, and more. If you want to practice using some of the programming structures taught in the course, however, you can install a language editor on your computer and start writing your own programs. A good first language is BASIC.

A beginner's computer language

The first computer language to make programming accessible to beginners was BASIC (Beginner's All purpose Symbolic Instruction Code). It was invented at Dartmouth College in 1963 for use in undergraduate beginning programming courses. When the microprocessor revolution made it feasible for individuals to own computers, BASIC was usually the language used because it was simple enough to run on small systems.

A version of BASIC for microcomputers was Microsoft's first product and the foundation of that vast software empire. Until the release of Windows 2000, Microsoft operating systems came with a version called QBASIC. Although Windows no longer includes BASIC, another version,

Continued use of Liberty BASIC beyond the trial period requires a $49. Writing a program to perform an action as simple as printing the words "Hello. unsophisticated program. don't fear. Although not part of the language. yet involve much greater levels of complexity than scripts. The Linux operating system. It just takes a bit of practice. Full programming languages Full programming languages are what most people associate with programming.   Understanding types of programming languages Scripting languages The least you need to know A script is a simple. this lesson splits the types of programming and programming languages used into two categories: scripting languages and full programming languages.markup languages such as HTML (Hypertext Markup Language) and query . The remaining pages in this lesson delve deeper into what a programming language is and isn't. and introduce you to the different kinds of programs you might want to create.a scripting language can do this in one or two lines. Essentially. a friendly. When working with a full-featured language. a student clicks the Enroll button and she's registered and enrolled for the class. it's time to dig into the meat of the course. Scripts are written in scripting languages such as JavaScript and TCL (Terminal Control Language). You can download Visual Basic Express Edition for free. it'll become second nature to you. and at the risk of oversimplification. World" can take over a half dozen lines of program code -.chunks of code that have been thoroughly debugged and documented. For the purposes of introducing programming. a script program generally takes the information you submit and does the following: Adds your name to the list of people taking the course Adds events to your calendar and modifies your user profile Sends you a confirmation e-mail The capabilities and level of complexity of most scripts are limited. Just as there are times when your pocket calculator is built to give you what you want quickly. these libraries are essential when writing large applications. Today these full-featured programming languages are only a part of programming. or desired. or even a total operating system. These kinds of languages are covered later in the course. For example. you can write complete applications. Languages such as C# and Java provide the ultimate in power and flexibility. and can be imported into your program with simple statements. is available as a free trial download for all Windows systems. scripting languages provide a list of instructions for the computer to follow.95 license fee. Full programming languages achieve much of their power by means of extensive libraries of code -. In the online class example. you've learned that not all programming languages have the same flexibility or complexity as others. You'll look more at JavaScript in lessons 3 and 5 of this course. Microsoft also offers Visual Basic. there are many times when more limited programming is useful. If you're concerned that you won't be able to keep all of the terms and concepts associated with programming straight. graphical programming language that enables you to create programs with appealing user interfaces. So far. is written entirely in C.called Liberty BASIC. the programmer gives a list of instructions for the computer to perform every time a certain action or event happens. Now that you've been introduced to the concept of computer programming. After you get comfortable with programming. when you register to take an online class. Companion languages Programming has a few companions that are often listed as programming languages but really aren't -. for example.

which calculates the required table and creates a customized Web page. they're often used in conjunction with programming languages to make programs do more. the open-source PHP (Perl Hypertext Preprocessor). and interest Mortgage Loan Calculator. perform some action on it. Web programs take input from a user (usually provided in a form). and the original data is marked up. The program presents the user with a form that requests basic information about a bank loan: the loan term. The three most popular languages for writing dynamic Web pages are ASP (Active Server Pages) from Microsoft. Markup languages Programmers use markup languages to add special information and actions to the basic information contained in a document. and Sun's JSP (Java Server Pages) technologies. Dynamic web programming languages The majority of computer programs developed today exist on the Web because it provides a convenient. Creating customized Web pages "on the fly" is a technique known as dynamic Web programming. markup languages let you create these actions quickly and easily. there's no easier way to interact with a program than providing users with a URL (Uniform Resource Locator) they can access. he or she clicks the Show/Recalculate Amortization Table button. Enlarge image After the user provides the information requested on the form. Markup languages don't provide for the control or complexity to write a full program. However. HTML is the basic markup language used to create Web pages. for example. tables. and is essential to Microsoft's view of future office application programming. An example is shown in Figure 1-2. accessible user interface. Clicking this button sends the information back to the server. Whereas there's a limited number of actions you can make Web pages perform. An HTML page can hold images. text. such as a Web browser. which contains the information requested by the user. The browser displays your text and images based on the instructions in the HTML embedded in the document. It's used to move data around the Internet. After all. principal amount. and anything a presentation slide can. To see what you've done. such as a billing or reservation system. XML (Extensible Markup Language) is rapidly becoming the most significant markup language in general use. For example.languages such as SQL (Structured Query Language). you need a viewer. They're called markup languages because special instructions are added to a text file. consider the Bankrate. shown in Figure 1-1. Figure 1-1: Mortgage loan calculator. Formatting documents and preparing Web pages are prime functions of markup languages. . however. and then create an HTML page providing the output.

and those that translate to codes that aren't hardware specific. In lessons 5 and 6 of this course. The term you use depends on the language you use.   Examining interpreters and compilers Compilers With an understanding of scripting languages. which make your code run. and companion programs under your belt. Whatever language you decide to write a program in. You need to make a distinction between compilers that translate to codes used by a specific kind of hardware and operating system. An example of a query language is SQL. A C program compiled for Windows hardware can be run only on Windows because the codes written by the compiler are specific to Intel microprocessors. it's done. full programming languages. you're out of luck. others are designed to be compiled. Because they operate similar to scripts. a set of instructions is processed. but in slightly different ways. which is a software implementation of a computer (the machine) that executes programs like a physical computer. or view data. the designers of Java came up with a set of instruction codes to which any Java program can be compiled. Both compilers and interpreters do the same thing.   A compiler gathers all of a program's lines of code and. Enlarge image Query languages Similar to scripting languages. query languages consist of a simple set of instructions for the computer to process. Java is a prominent language that uses the virtual machine concept. they can be considered a special type of scripting language. After carefully considering all of the basic operations a computer might be called upon to do. translates the entire program into a format that's closer to machine code. To get around this limitation. Compiling a program this way takes time. it must be translated into code that a computer understands. but after it's done. you'll explore these special-purpose companion languages and how you can use them with your favorite programming language to enhance your programs. Some languages are designed to be interpreted. Query languages are used with database systems to add. the concept of a virtual machine was invented. let's take a look at interpreters and compilers. When a query is run. Every computer that can run a Java program has a small program specific to that computer . at one time. A special-purpose program called a compiler or interpreter performs this translation. you can use the program whenever you want. And some languages can be either interpreted or compiled. remove.Figure 1-2: Amortization table. If you want to run that program on a Mac or an IBM mainframe.

the compiler or interpreter translates the program with the appropriate instructions for that operating system. were specifically designed to be independent of which computer they're interpreted or compiled on. whereas an interpreter translates one line at a time. however. It's important to understand the main distinction between a compiler and an interpreter. a compiler translates every line at once. They provide generic instructions for tasks such as gathering input or writing output. however. Interpreters An interpreter. for example. interpreters run programs more slowly than a compiled program can be executed because they have to translate every line each time the program is run. An OS (operating system) is the most important set of instructions the computer has. Just to add to the confusion. accept input from the keyboard and mouse. instructions are used that are specific to one operating system. and executes the required machine code. The most common operating systems for personal computers are: Older PCs used DOS (Disk Operating System) as the operating system. . Fortunately. there are other operating systems such as OS/2 (now eComStation) and BeOS.less common. yet gaining popularity Mac OS for Apple Macintosh or iMac computers When some programs are written. talk to the modem or Ethernet card. however. Other programs require the environment provided by the operating system to do these jobs. Larger computer systems use yet other OSs. These are the instructions that tell it how to do basic actions. you compile it for one operating system's set of instructions. It reads one line of your instructions. you'll learn more about the elements and constructs that make up a computer program. this means that you have to change your programs to use them on a computer with a different OS.that can read the virtual machine codes and execute the corresponding code for the specific hardware. or flash disk. However.   Understanding operating systems Now that you're familiar with interpreters and compilers. You'll also learn how to read pseudocode. You won't be compiling any C programs here. the language commonly used to describe what a computer program does. for the time being. CD disc. Microsoft Windows for PCs Linux for PCs -. on the other hand. you have to recompile it. you don't have to concern yourself with this. let's turn our attention to the importance of operating systems. Languages such as HTML and Java. but it's something to remember. display text and images on the monitor. and so on. When you compile a program such as a C program. When they're compiled or interpreted. does very much what you'd expect something called an interpreter to do. Interpreters allow for flexibility and experimentation. Moving on In this lesson. such as read and write to and from the hard disk. Both translate lines of code from a program into machine code. If you want to use the program on a separate operating system. figures out what this means for the specific computer. you got an overview of basic programming concepts and terminology and were introduced to different types of programming languages. modern languages try to minimize OS-specific commands. In Lesson 2.

For a powerful yet still relatively easy-to-learn language (with. Try entering some of the terms discussed in this lesson to learn more about them. Quiz #1   A) B)   A) B)   C) D) C) D) Full Question 1: Which of the following are categories of programming languages? (Check all that apply. try entering the phrase XML tutorial at Google or your favorite search engine. and takes just over 35 MB of disk space.Assignment #1 Finally. A six-lesson tutorial is included under the Help menu (select Help. Unless your hard drive is really cramped for space. One of the great advantages to learning programming in the Internet age is the huge array of public resources available. If your operating system is Windows. you'll have the opportunity to set up your own computer so you're ready to try your hand at a BASIC program or two. let's face it. A typical Python distribution download is about 11 MB. Spend some time getting familiar with these resources. you can download a trial version of Liberty BASIC for free. The documentation furnished with Python includes a tutorial that assumes a bit more familiarity with programming concepts than the Liberty BASIC tutorial.) An interpreter A compiler A programmer A program companion Scripting Array Application . Liberty BASIC opens automatically after installation. Assignment #2   Liberty BASIC has an active user community with many current tutorials and books. you should install all of the options.5 MB of space. The major Internet search engines also index many sites that can be useful to the beginning programmer. starting with the Tech Terms Dictionary. Although you can use Python as a scripting language. For example. complete the assignment and take the quiz for this lesson to reinforce important topics.) Question 2: What translates a program's instructions one line at a time as they're needed? Question 3: Which of the following examples are good uses for a markup language? (Check all that apply. Save the downloaded executable file (which is about 3 MB) somewhere convenient and double-click it to start the installation process. The installed files will take a little over 8. it supports object-oriented programming and is powerful enough to do serious work. Just double-click the downloaded executable file to start the installation process. Do the first lesson in the tutorial now. Before you move on. a cool name) you can find a version of Python for just about any operating system at the Python Web site. and then select Liberty BASIC Tutorial).

In this lesson. Pseudocode is a way of writing instructions in something close to natural English but that's related to typical programming languages.) Talking to the computer's hardware (disk drives. A clear vision of what you want the program to do makes actual program writing much simpler. and so on) Providing an environment for programs to run Compiling programs Providing debugging capabilities for programs ASP JSP BASIC PHP Formatting a document Preparing a Web page Creating a reservation system Writing a billing system Discovering control statements Computer programming tutorial: learning parts of a program This lesson covers program structure. so you should use pseudocode. For example.) Question 5: Which of the following jobs are performed by the operating system? (Check all that apply. a conditional statement performs different computations or actions depending on whether a condition is true or false. Read the first message. More formally. monitor. Delete the message if it looks like annoying spam. the basic use of each structure is the same. depending on a specific logical condition. For a general discussion. In Lesson 1. Open your e-mail inbox and find your new e-mail messages. A loop is a set of instructions that can be executed one or many times. you learned that a program is just a set of instructions that tells a computer what to do in a language it can understand. say you want a computer to read your e-mail for you and then delete all the messages you've received that look like spam advertisements.   Welcome back. loops and conditional statements change the behavior of a program based on inputs or other conditions. You'll also discover how variables and constants manage your data. In this case. Leave the message untouched if it might be a real message. you'll learn about the different logical structures within a computer program that you use to create those instructions.called syntax -. until you know what your program needs to do.A) B)   A) B)   A) B)   C) D) C) D) C) D) Question 4: Which of the following languages can you use to create dynamic Web pages? (Check all that apply. Determine if this message looks like annoying spam. it's best to avoid using only the syntax of a single language. Professional programmers often spend as much time planning as . Although the syntax might be different across languages. Go on to the next message and repeat the process until all messages have been checked. Always plan before you code Scripting languages and full programming languages use structures called control statements to hold instructions that help computers make decisions about what to do (called conditional statements) or perform tasks multiple times (called loops). or even decide which structures to use in your program. Every scripting or programming language has a different set of rules -. you'd want the program to do the following: A key lesson experienced programmers know well is that you can't start programming.for using these different structures in a program written in that language. You'll learn how control statements. This takes some thought and planning on your part.

In some languages. the computer has to make a decision with each message whether or not it should delete it." In pseudocode. There are several different kinds of loops: loops that are executed according to a counter. This is one of the fundamental rules of programming: computers only do what their instructions tell them. To do that. let's move on to some more complex loops and conditional statements. they do programming." or. you can phrase a loop as. The concept is simple. This example includes a conditional statement (if the message subject contains certain words. and the (do something else) part is the false branch. IF (some logical condition is met) THEN (do something) ELSE (do something else) The other control statement used in the e-mail testing routine is a loop. they all mean approximately the same thing. among others. and where the loop ends. continue doing whatever is in the loop. the following is an example of a do-until loop: . you can usually determine which one to use by phrasing it as if you were giving instructions to a human. To force message processing to occur for each message in the inbox. it has to be able to make decisions. WHILE (there are messages that haven't been read) process the message END WHILE Although there are several types of loop statements. there are even more possibilities. This says: IF (the message subject starts with ADV) THEN (delete the message) The (do something) part of the if-then-else statement is called the true branch.In this case. "Do this 100 times. and when. You have to tell it exactly what to decide. but the loop examples mentioned here are the most common. you can use a while loop that looks similar to the following: The end while statement lets the computer know which instructions are part of the loop. however. You have to tell it to check the e-mail subject. What the computer does from there depends on the message passing this subject-matching test. delete the message) and a loop (keep checking each message until all messages are tested). While the test statement is true (there are messages that haven't been read). and that execute until a specific condition is met. The most common conditional statement is an if-then statement. For example. Understanding loops and conditional statements   In the case of this e-mail routine. A common extension of the if-then statement is the if-then-else statement. "Do this until you're out of messages. and then what text to look for. you're having the computer do work for you. Here's a simple example: Different programming languages have slightly different ways of phrasing and punctuating that statement. Now that you're familiar with basic control statements. you use statements that make a logical decision. To write loops and conditional statements.

and the idea of "not. less than or equal to. A Boolean expression asks the computer to do one of the following: Tell you if one value is greater than another Tell you if one value is less than another Tell you if one value is equal to another More advanced Boolean operations use greater than or equal to. Loops with counters A for loop uses a counter to perform a task a specified number of times. 4. you need to understand Boolean expressions. Look at the subject of the message. Close the mailbox. 3. b. Conditional statements In conditional statements. Before you can work with control statements efficiently." but it's essentially grade-school arithmetic in action. computers are literal and can't read a programmer's mind. The program is done. . you must be sure there's at least one message to process before entering the loop. In an actual program. END WHILE. Remember. Not advancing to the next item in a loop is a common error. 5. you'd use a Boolean expression to specify this condition in terms a computer can understand. you could write the processing loop this way: Now. DO process the message UNTIL (there are no more messages to process) Different programming languages have different syntaxes and terms for loop control statements. your loop would keep testing the same message repeatedly. Notice that it's important to tell the program to get the next message in Step 3. THEN delete it. let's go back to your e-mail checking routine and fill in some details. Remember back in school when you learned how to compare two numbers? This is the same idea. however. 2. otherwise. it now looks something like this: FOR (number of messages) process the next message END FOR 1. you use Boolean expressions to instruct the computer to make a decision. Open the mailbox and get any new messages.Note that because this loop always executes the process at least once. A Boolean expression is one that can be evaluated as either true or false. In the example e-mail program. are universal. If your e-mail program knew in advance how many messages were waiting. Get the next message. The concepts. IF (the subject starts with ADV) c. the message is deleted if the subject contains a certain string. WHILE (there are more messages to look at) do the following: a. In terms of the control statements just discussed.

and try to multiply or divide that string later. such as the number of letters in a name compared with the maximum number allowed. you can write an expression that's true when one number is equal to another. such as a collection of variables (discussed shortly). for these pseudocode examples. called total. For example. such as numbers. one after the other. In the next section of this lesson. 3. If you add count to a number. storing. It could be a type of number. you need to define the type of information you're going to use them to store. IF (the message is from Julie AND the message is longer than 30 lines) THEN delete it Programming with variables and constants   In programming terms. are strongly typed -they require you to declare which kind of data they'll hold before you use them. with no decimal. In fact. and letters. these languages quickly and easily convert variables to the type they think you need. These are variables whose values you Some programming languages. they need to use variables to store data. For example. If you store a number as a string. as shown in the following: An integer is a number such as 1. Programs deal with all types of data. OR. if you want to discard long e-mails from Julie. such as Perl and PHP. Other languages. or something else. 4. it'll convert the variable to a number. such as Java and C. You can also perform operations such as: total = count + 2 in which you just added 10 to the value held in the variable count. count = count + 10 One important point about variables is that. a variable is a name used to store and refer to a value. 2. For other numbers. you'll take a look at the concept of variables and constants. if count is still storing the value 5. and retrieving these different kinds of information. is used in the following: count = 5 Strong and weak typing In this example. Another variable. For example. The analogy is a string of beads. which means they don't require you to declare a type for variables. when comparing numbers. in most languages. total There are other special variables called constants. have weak typing. and so on. Variables provide the convention for naming. you need to define the count and total variables before you use them. and NOT logic. dates.Programming languages provide syntax for creating Boolean expressions about data of different types. you can use a type called real or float (short for floating point). When comparing text. For the previous examples. so variables are where items of data live. integer: count. you might write something similar to this: For most programs to run properly. it's just as if you added 5. Different languages store text in different ways. letter. and will give you an error if you try to do something strange (such as multiply a . you use a type called string that stores text as a string of letters. You can also combine Boolean results with the familiar AND. you just set the variable total to equal 7. you can write an expression that's true if one word comes before another alphabetically. names. you can define a variable called count and set it to store the number 5 by doing the following: You can then treat this variable the same way you'd treat a number.

you can sort an array of strings alphabetically with a single command. In most programming languages. That's a little quirk you have to get used to. just use this pseudocode version. Arrays combined with the for-end for control structure make it possible to manipulate large amounts of data with simple commands. and enables you to get at them in terms of their position relative to the top of the stack. these are covered later in the course. which you should do. The inner part of the while control structure would then look something similar to this: Weak typing is usually a bad idea: It allows ambiguity in your programs and encourages you to write sloppy code. you now have a program that can handle multiple spammer names with only one named variable. you can require explicit variable declarations in Perl by including the command use strict "vars". Languages that use weak typing often provide an option to enforce strong typing. you can step through a list of data one item at a time using a control structure such as for-end for. To continue with the earlier e-mail checking example. For now.set once and never change. For example. If you have an array with 10 items. in a mathematical program. THEN delete the e-mail and stop the loop 3. as shown in the following: The value of pi doesn't change as you use it. you might declare a constant called pi. FOR (every N in the SPAMMER array) 1. you might provide the program with an array of names of people who are sending you annoying spam. Due to conventions that started back in the mists of time. you'd use that list item's index number to access it. in the header of your Perl scripts. a stack structure holds onto values in the order they're added. In addition. Different languages use different methods of declaring variables and constants. Many programming languages also enable you to pick an individual item from a list using an index. A list or array is like a grocery list in real life: It wouldn't make much sense to write each thing you need from the grocery store on separate sheets of paper. END FOR By using an array. you put all these items into a list. total . the next section focuses on converting variables. real constant : pi pi = 3. many languages consider the index of the first item in an array to be zero. 1. IF (the sender equals the Nth SPAMMER) 2. For example. For example. Some programming languages have specialized structures to add additional logic to variables they hold onto. many languages provide built-in functions that work with arrays. so you store this value in a constant. if you want to grab the third item in a list. Instead. Now that you've been introduced to variables and constants. Converting variables Most programming languages require you to define the type of information that's stored there as in the previous example: integer: count.14159 string by 3). Collections of variables Most programming languages also enable you to put data values into a list or array. they have indexes 0 through 9. among other aspects of basic programming. For example. For example. Look at the sender of the e-mail 2.

which type of statement would you use? 3. work through each of the problems. Using a single variable to represent a complex object is an essential part of OOP (objectoriented programming). complete the assignment and take the quiz for this lesson. a variable representing an e-mail message could contain the name of the sender. such as the following example: In this example. Which type of loop would you use in a program to look at all the numbers in the array? 2. and then check your answers against the solution provided: Solution Challenge exercise Write detailed pseudocode for a program that.However. You have to convert that string to a number. You're writing a program that. You have no advance knowledge how many books are in the box. string: inputFromUser = getInput count = parseStringAsNumber( inputFromUser ) Some other common functions that typical programming languages provide include trigonometric functions such as sine. and Java enable you to program with variables that are containers for multiple simple variables. outputs tomorrow's date. you'll look at other important structures that computer languages use. and some examples using what you learned in this lesson. 1. It might look like a number to you. as well as variables and constants. Boolean expressions were explained. The user input is stored as a string. your program might have to deal with a representation of a number that the user inputs as a series of digits. You learned about pseudocode. the time it was sent. For this assignment. and loops. You roll a die 10 times and each time record the number that comes up in an array of integers. such as 12 or 100. . as you move books from a box to a shelf. and it might even be empty. the subject. The capability to hide many parts behind a single variable name is part of what makes OOP so powerful. the title of each book is printed. and an attached file. so you can't perform mathematical operations with that input. Common functions that manipulate strings include converting to uppercase. but it's a string of characters to the computer. You'll learn more details about this power in several upcoming lessons. To continue the e-mail example. Which type of loop should you use? 4. Languages provide functions that can convert between string and number representations. given the current date. C#. control and conditional statements. Before moving on. If you flip a coin once and print one message for heads or another for tails. cosine. and tangent. In Lesson 3. Variables with multiple parts Modern object-oriented languages such as C++. the message text. you might expect the user to type in a number. Moving on Assignment #3 This lesson introduced you to the basic building blocks of a simple program. Write the pseudocode for a program that prints the area of a simple triangle.

an if-then-else statement is the most obvious choice. and the box could be empty. Print results.5.7. 4. create a collection of variables for a digital song on your might use the following simple variables: Based on this example. Get the current date [month. For example. and put it on the shelf. You could phrase this process as. year]. "If there is a book in the box.The solutions for this assignment are as follows: 1. The pseudocode for determining the area of a triangle and printing the results might look like the following: Challenge exercise solution Get values for the base and height.3. For a single simple decision based on a condition to be done once.9. consider a book -. A for loop provides a convenient index and counter. string: title string: author integer: year of publication integer: number of pages . The pseudocode for a program that outputs tomorrow's date given the current date might look like the following: Assignment #4   1.11 If day = 30 increment month else increment day else if month = 2 If day = 29 or day = 28 and it's not a leap year increment month else increment day 3. but the for loop is easiest.10.6. You could create the same effect with a separate variable. 2. increment day add 1 to current day increment month if month = 12 increment year else add 1 to current month day = 1 increment year add 1 to current year month = 1 leap year divisible by 400 or divisible by 4 but not 100 Think of a complex object that could be described as a collection of simple variables. day. get it. You actually could write this as a while loop. it'd be very tricky (and pointless) to do. Calculate the area. If month = 1. however. 3. print the title.12 If day = 31 increment month else increment day else if month = 4. 2. day. Output tomorrow's date [month." A while-end while loop would accomplish the task because you don't have to know how many books are on the shelf. year] in a numerical format.

Question 3: True or False: Loops can use counters to perform a task a specified number of times. what programmers call IO -.   When to write subprograms .Solution The following are possible variables for a digital song stored on a computer: Quiz #2   A) B)       A) B) A) B) A) B)   A) B)   C) D) string: song title string: artist string: album name string: genre string: file format integer: length integer: year of publication Question 1: Which term describes a set of rules used by a scripting or programming language? Question 2: True or False: A variable performs different computations or actions depending on whether a condition is true or false.short for input and output. You'll also explore a new topic. you'll learn about the use of subprograms and how they facilitate breaking complex programming problems into simpler parts. This lesson introduces subprograms. You'll also learn about graphical user interfaces.16 for use in mathematical operations? C) D) C) D) Question 5: Which one of the following variable types could hold the value Renee? Binary String Float Integer Integer Using subprograms to make programming easier Exploring subprograms and computer input and output Welcome back. functions and subroutines. In this lesson. True False Float Binary String True False Pseudocode Syntax Control statement Boolean expression Question 4: Which one of the following variable types could hold the number 5. you learned about logical control statements and loops that handle repetitive tasks. which make working with your programs easier. which enable you to reuse commonly used portions of programs to save development time. In Lesson 2.

organizing a program into subprograms results in code that's easier to understand and to maintain. and then add instructions to repeat the subprogram as many times as necessary. look for opportunities to break it up into subprograms. suppose you have a program that frequently needs to calculate the average of three numbers. but you'll find it easier to understand and maintain if you use subprograms. and so on. suppose you have a chess program that draws the game board onscreen. this average3 function definition looks similar to the following: real function average3(real number1. which don't. and var3 as input. Some commonly used terms are subroutine. you can create a subprogram to draw a square at a programmable location with a programmable image. you have a candidate for a subprogram. and subroutines or procedures. For example. or invoke it. When you write the code to run a subprogram. In pseudocode. var2. var3) Now you need to tell the operating system what the average3 function is. and then store the resulting value in the variable called avg. Whenever your program has to repeat certain steps. open files. Programming languages make a distinction between functions. and. avg = average3(var1. such as count the number of characters in a string. You do that by defining the function. you only have to change the subprogram in one place rather than changing the same code multiple times throughout your program. You might think you can remember what all the bits in that great monolithic block of code do. It would be tedious for you to write the instructions to draw 64 individual squares with or without the chess piece images. you call the subprogram. Defining a function For this example function. if you discover a faster way to draw images.A subprogram is a relatively small chunk of code that you can use repeatedly in other parts of your program. real number2. and function. you tell the operating system which type of value the function is going to return. For example. Once you get rolling on writing a program. in most languages. In the function definition. Most programming languages have bundled or included subprograms or functions that enable you to do certain kinds of work. var2. Without subprograms. which return a value to the calling program. In all but the simplest cases. the three numbers). If your code gets longer than a page or so. method. Instead. it's easy to find yourself with a single chunk of code that's pages long. what information you have to give the function (in this case. You can write a function that averages the three numbers. and what the function should do. you would then call this function with code similar to: This tells the operating system to execute the instructions in the average3 function with the values in the variables var1. Different programming languages use different terms when talking about subprograms. creating and modifying large programs would be nearly impossible. procedure. real number3) average3 = (number1 + number2 + number3) / 3 end function . It's also easier to improve your code.

In the previous example. it tells the computer to define a function called average3 that requires three real values as input and returns a real value as output. Most programming languages use syntax similar to the following for calling functions. and assigns the result to a variable that has the same name as the function. return (number1 + number2 + number3) / 3 . or the longest string in an array of strings. In this case. you'd write an instruction such as: the_avg = average3(31.This pseudocode defines the function by stating which type of value it returns and what types of values it needs to be given when you call it. new_age = current_year . divides by 3. for example. The following is an example of a subroutine that calculates an age and prints it: subroutine show_age(integer current_year. This convention of designating the value returned with a variable that has the function's name is used in BASIC and related languages. and number3 are the parameters.8. Calling functions and subroutines After you write a subprogram. both as input parameters and as returned values. Some languages make no distinction between subroutines and functions. The function adds the three numbers together. Subroutines are often used to perform operations such as writing text to the screen or to a file.year_born print "Your age is:" new_age end subroutine show_age You can call this subroutine and provide it with the current year and the year in which someone was born. number2. 29. 22. you might write a subroutine to find the largest number in an array of numbers. number1. To call the average3 function you wrote earlier. you need to call (or run) it from within your larger program. Subprograms with complex variables Recall from Lesson 2 that you can have a variable that contains other variables. For example. It's called a local variable. Arrays are a common example used with subprograms.7) . In JavaScript. you can define a function as having a returned value or having no returned value. integer year_born) integer new_age.5. The definition of the subroutine would state that it takes the name of an array variable as a parameter. a return command is used in code that looks similar to the following: The values (variables) that you give any type of subprogram when you call it have a special name called parameters. It does the subtraction and prints the value to the screen. however. Defining subroutines Subroutines are called similar to functions. your program doesn't have to send a return value as output. In other languages such as Java. Note that the variable new_age that's defined and used inside the subroutine can only be used inside show_age.

you provided the three numbers to be averaged as literal numbers in the call statement. you can place comments between special character sequences */ At this point. C/C++ doesn't. Now that you've learned the basics of building and calling a function or subroutine. /* In many languages. Putting together complex computation by combining simpler parts in the form of subprograms is essential to programming. this happens all the time. That's covered in the next section.   . In the next section. you could provide variables by name or a mix of variables and literal numbers. call show_age(this_year. you can place them between special character sequences: ` a comment in Visual Basic One of the marks of a good programmer is providing clear comments that help future users of your code understand its intent. you'll learn another important concept: how to get data in and out of your subprograms. you could write something similar to: Some programming languages require the use of a special instruction (such as call) to run a subroutine. This is a good time to talk about a good programming practice -. use the hash character for a comment: // in C any text following // is a comment And Visual Basic uses an apostrophe: # a comment in Perl or Unix shell In some languages. you know how to create and call a subroutine or function and properly document your program. This is usually done by a special character sequence. to call the show_age subroutine. if you have a lot of comments that need to stay together. 1972) A comment about comments   You can embed a call to a function or subroutine in another function or subroutine. In fact. In this example using the C convention. other languages let you state the name of the subroutine as an instruction. Alternatively.In this example. All programming languages provide a syntax for putting notes in your program that the computer just skips over. you need to know how to properly document them. Fortran is an example of a language that requires a call statement. the computer ignores all text after the double slash: Other languages. even in simple programs.commenting your code. For example. like Perl and Unix shell.

In a real programming language. which you store in a variable called to get information into a program. number2. and number3. the_avg end program When you run the program. It then asks in sequence for two more numbers. the program prints the value of the variable the_avg and ends. you might use this syntax: In this case. number2. There's an obvious counterpart to the print statement. and output at work. "set the variable the_avg equal to the value the function average3 returns when given number1. different languages have a different name for the print statement. and then prints it: real function average3(real number1. Because average3 is a function. Finally. number2. For example. input. The convention for an input command is to accept characters from the keyboard until the Enter key is pressed. and calculate the average. The program then calls the function average3. This area of programming is called IO. it prints the first messages asking you for a number. real number3) average3 = (number1 + number2 + number3) / 3 end function program do_average print "This program will ask for three numbers. which is the input statement (again. It asks the user for three numbers. passing it the parameters stored in number1. When you type in a number. They're omitted here for simplicity's sake. known by other names in other languages). it returns a value that you store in another variable called the_avg. calculates the average. it stores that number as number1. at which point all of the accumulated characters are interpreted as the age variable. let's write a simple program in pseudocode that uses the average3 function along with some user input and output. and how to get the results out. number3) print "The average is :". you would have to include statements to declare your variables.Using input and output Previous lessons have glossed over something important -. you tell the operating system to print the message. real number2. print "How old are you?" input (age)   As with any statement. a simple statement called print was included to tell the computer to print text to the screen. and stores them as number2 and number3. "How old are you?" and then read in something the user types. to ask the user's age. Exploring other kinds of input and output . To see subprograms. and number3"." print "Enter the first number:" input (number1) print "Enter the second number:" input (number2) print "Enter the third number:" input (number3) the_avg = average3(number1. In the programming example in which a person's age is calculated. You could state the effect of the function call as. so don't be surprised when you see another name for it later. You use this statement to tell the computer to get some data from the user.

your computer might be sending or receiving data over a network and running other programs. As a programmer. it might be significant to the program that controls that part of the screen. You've probably seen this in action on Web pages where a slight movement of the mouse causes an image to change. print "Enter the first number:" input (number1) Moving a mouse around generates a huge number of events. every time the mouse pointer points to a new screen location. In every case. and your program interprets these events according to the input statement rules. you can write a program that reads a mailing list from a file and prints holiday card envelopes on a printer. For example. You move your mouse over an image and it changes. all forms of input and output have universal requirements. The operating system interprets the hardware actions of moving a mouse or pressing a key as an event that's passed to your program. Lesson 5 includes an introduction to HTML and other markup languages. don't worry about the following examples. you don't have to worry about these details because the operating system simplifies everything by means of a concept called event oriented programming. For example. You'll learn about GUIs in the next section. Code describing input must state where it's coming from and the variables where the input is to be stored. and Linux operating systems. the event contains information on exactly where it happened: Mouse has entered your working area Mouse has moved with no button pressed Mouse has moved with a button pressed Mouse has left your working area A familiar example of a mouse event Imagine you're browsing a Web page. Mac. your computer might have many processes going on. if your program has executed the following statements: The operating system hands your program events that contain the characters that are typed on the keyboard. Discovering graphical user interfaces and input events   Twenty years ago. such as the tags that include images in a . a discussion of input and output would have stopped here. The following are some examples of mouse events your program might receive. Your program must describe output in terms of where it's going and exactly what data is to be output. HTML is secondary to the discussion about events. As you sit at your computer screen using the graphical interface of a Web browser. If you haven't worked much with HTML. In addition to keeping track of your input by keypress or mouse movements. In addition to controlling the way a Web page looks.Naturally there are other kinds of input and output besides printing to the screen and accepting keyboard input. the conventions of HTML allow for attaching a JavaScript function to the page so that it can respond to events. however. You can define properties for certain HTML tags. But modern programmers have to deal with GUIs (graphical user interfaces) as found in Web browsers and the Windows. What happened is the Web browser got a mouse event and called a function written in a scripting language.

there's no main program. and then give a function call for two events: onMouseOver and onMouseOut. The tag that starts . the corresponding function is called.1 . save it as plain text (not a word processor format) in a file named Example.jpg"> Creating a fun example   You provide a name for this image (SwapImage). and an input form. the second occurs when you move the mouse out again. the HTML tags create a page that has a title. The first event occurs when your mouse pointer moves into the image area. In the following example. a line of text. When JavaScript appears in a Web page.   <html> <head><title>Example with Input and Events</title> <script language="javascript" type="text/javascript"> function doReverse() { var s = ctrl. If you want to copy the following and play with it.){ ctrl. <img src="picture.length .html. each part is discussed in detail. Now for an example that's not only fun but also demonstrates many of the programming concepts you've learned in the last three lessons. the real main program is the browser. i-.charAt( i ).value += s. After presenting the entire code.value = "" . giving the image a name and attaching calls to functions written in JavaScript.value . it's time to pull all the pieces together." value="Reverse" /> </form> </p> </body> </html> The first two lines tell the browser how to show the title of the page. i >= 0 . It states that the image is to be taken from a particular file: You can add extra information to this tag.msg. // erase input field for( i = s.jpg" name="SwapImage" onMouseOver="functionA(SwapImage)" onMouseOut="functionB(SwapImage)"> Now that you're familiar with essential subprogram topics. } } </script> </head> <body> <p>Type something then press Reverse <form name="ctrl"> <input name="msg" type="text" size="40" value="" /> <input name="doit" type="button" onclick="doReverse(). Here you have a basic HTML tag for adding an image to a page. and JavaScript provides added functions that are called by the browser when events occur. to provide instructions to the browser on what to do when the mouse is moved over or away from that The next section explores a fun programming example.msg. When the event occurs. resulting in something similar to the following: <img src="picture. The programming language is JavaScript embedded in a Web page. // get input ctrl.msg.

it automatically adapts the variable to the type of value being stored in it. and the button is named doit. 3. Get the contents of the msg variable by looking inside of value. Put the contents of that variable in the local variable named s. To get the last character in the string. The following shows how you could describe the way this line of code works: var s = ctrl. 1. you have to address the individual parts using the names established in the form. Following that. This is an example of weak typing. The page has a short bit of text followed by a form. In the tag that creates the button. // get input Next there's a statement that puts an empty string in value. Figure 3-1: The Web page with text typed into the form. the code that says: tells the browser to execute the doReverse function when it gets a mouse click on the button. 2. . concentrate on how this function works. the text input field is named msg. The form named ctrl is an example of a complex variable made up of simpler parts. Instead. The text in the area between the <body> tag and the </body> tag is what the browser uses to create the page display. where the form consists of a single text input field and a button.<script tells the browser that one or more JavaScript functions are going to be defined in the text that ends with </script> so it doesn't try to display that text. These names identify those tags as variables as far as JavaScript is concerned. onclick="doReverse(). To get the text from the text input box." How the doReverse function works The first line of the function is: The definition of the doReverse function is enclosed in curly braces. strings in JavaScript are the same way. Remember what you learned in Lesson 2 about arrays having the first item at position zero? Well. For now. Get the variable named msg from ctrl.msg. When you type into the text field named msg. however. Note that the form is named ctrl. Figure 3-1 shows the display with some text typed into the form. 4. following the C convention. the keypress events sent by the operating system to the browser are interpreted as characters and are added to the field and displayed. which illustrates a number of things you've already learned. which you learned about in Lesson 2. you have the code that puts the characters back into the form in reverse order.value . The next lesson discusses the conventions found in C family languages. Get the variable named ctrl from the page. you have to use an JavaScript doesn't require you to declare the variable s as being of any particular type.

index equal to the length of the string minus one. The statement that controls the for loop states:

In plain language you would say, "starting with an index that points to the last character in the string s, subtract one every time through the loop, as long as the index is zero or positive."
for( i = s.length - 1 ; i >= 0 ; i-- ){

The next statement:

says, "add the character in the i'th position in the string and to those already in the value variable. On every cycle, the for loop uses the next smaller index to work backwards through the string." The browser displays the changed content of the variable, and you end up with the text field filled with the reversed string, as shown in Figure 3-2.
ctrl.msg.value += s.charAt( i );

Figure 3-2: The Web page as it appears after clicking the Reverse button. See how to create the JavaScript example and run it. (1.5 MB)

Although this example is simple, it illustrates an important programming concept you'll use repeatedly in more complex programs.

Moving on

Assignment #5

In this lesson, you were introduced to the important programming concept of subprograms and how they're used. You saw some common uses of input and output programming commands, and you got a quick introduction to how modern GUI programming uses events for user input in JavaScript. Lesson 4 looks at some more traditional programming languages, and shows you what it takes to create a complete program in one of those languages. Before you move on, complete the assignments and quiz for this lesson.

For this assignment, you'll add comments to the following sample function used in Lesson 3: Add your name, today's date, and a brief description of the function, and show the comment codes for each of these programming languages:
real function average3(real number1, real number2, real number3) average3 = (number1 + number2 + number3) / 3 end function

C Perl or Unix shell Visual Basic

Solution C:

The following are possible solutions: Perl or Unix shell: Visual Basic:

// <your name>, <date>, function averages three real values and assigns the result to the average3 variable

Quiz #3
  A) B)   A) B)   A) B)     A) B) A) B)   C) D) C) D) C) D) Call

# <your name>, <date>, function averages three real values and assigns the result to the average3 variable

Question 1: Which of the following are alternate names for subprograms, depending on the language? (Check all that apply.) Question 2: Which of the following describe how to invoke a function? (Check all that apply.) Question 3: Which of the following can generate a user input event to a program? (Check all that apply.) Question 4: True or False: A Web page display is static and can't be changed by user input. True // ` # False Press a key on the keyboard. Display a typed letter on the screen. Click the mouse on a Web page form. Move the mouse out of the program display area. Call it from a larger program. Put it in a comment. Use an event on a Web page to trigger it. Call it from another subprogram. Function Method Subroutine

` <your name>, <date>, function averages three real values and assigns the result to the average3 variable

Question 5: Which of the following character sequences denote comments in a program, depending on the language? (Check all that apply.)

C, C++, C# and Java computer programming languages
C) D) /* … */

Some of the most popular full-featured programming languages today are C, C++, C# and Java. In this lesson, you'll learn a brief history of these languages and how to structure simple programs using them.  

Introducing the C programming language

Welcome back. In previous lessons, you were introduced to the basic structures of programming, such as conditional statements, variables, input/output, subroutines, and more. Now you're going to look at a group of languages that have been highly important in the history of computing and are the dominant languages in much of computing today.


For simplicity, these are referred to as the C family of languages, because they have the C language in their background. The language called C was developed in the 1970s as a powerful and portable language usable at both the systems and applications level. Systems-level programming deals with the nitty-gritty details of hardware and operating systems, whereas applications-level programs run on top of operating systems and deal with user tasks. The languages in this family share the following characteristics: The core of the language is compact and depends on libraries to achieve functionality. As you might recall from Lesson 1, a library is a collection of programs and subroutines, and programs must specifically declare (specify or define) the libraries to be used. Variables and functions must be declared with type information, and the language (usually) pays attention to the declared type in all subsequent uses. There's a simple way to create complex variables that represent a collection of simpler variables. Programs are built of short statements written in plain text using the equal sign (=) to assign values to variables and expressions that look similar to standard algebra. These statements are included in modules that you can compile separately.

The history of the C language

The C language was developed with the original Unix operating system and still has some elements (such as terse abbreviations for commands) in common with it. Because of C's power and flexibility, it's become one of the most widely used computer languages, and compilers are available for a large number of different systems. However, because C programs are usually platform-specific, moving a program written for a Mac, for example, to a PC might take a bit of work and requires the use of a platform-specific compiler. When talking about computer languages, platform generally refers to a particular combination of hardware and operating system. You might see a product for the Windows platform, the Mac platform, or the Linux x86 platform. This distinction breaks down a bit in terms of Java, because it runs on so many combinations of hardware and operating system.

The C language has been standardized, in terms of basic syntax and standard libraries. The Free Software Foundation offers C compilers for a large number of operating systems. The power and flexibility of C come at a price, however. Complex C programs can be difficult to debug; there are a number of errors commonly made by novice (and even experienced) programmers that can be hard to find. In addition, the sheer complexity of many C programs makes them susceptible to viruses and hacker attacks -- it's fairly easy to add and hide virus code in a large and poorly structured C program. Basically, it's easy to shoot yourself in the foot with C.

History of the C++ language

C++ (pronounced "C plus plus") builds on the C language as the name indicates. Because C++ contains all of C, C++ compilers compile strictly C programs without difficulty; however, the opposite isn't true.

there were no languages that made communication over networks easy and portable. a class of programming languages in which the variables and functions used by the programmer are packaged in objects. Bjarne Stroustrup. When you see news reports of newly found security problems in some operating system. and use of the name Java is still controlled by Sun. working at Bell labs. Similar to C.C++ popularized the idea of OOP (object-oriented programming). Java incorporates many security features that make fatal bugs less likely. As OOP is a vital part of programming these days. and network connectivity easier. Thinking of programs this way helps to control the complexity of very large programming projects. So. if you have the JVM installed on a Windows system. it's possible to write a program that writes data all over itself and crashes. For example. This is where Java comes into play. In particular. In speculating on what kind of language would be required. However. they wanted to make memory management. They felt strongly that the future of computing would depend heavily on interconnected (networked) computers and small computing objects communicating with each other. it can run on the JVM under any operating system without recompilation. In addition to the free open source libraries. Java achieved more rapid adoption than any other language up to that time because it was perfectly positioned to catch the rising interest in the Internet. known as a buffer overflow. you'll see that term frequently. History of the Java language Researchers at Sun Microsystems were doing "blue sky" research in the early 1990s. When you see references to ANSI C++. they liked the syntax of C and the idea of OOP. the root cause might well be this sort of problem. there are also commercial libraries you can license. for example. you can use it to execute Java programs compiled on a Macintosh and vice versa. but decided that many conventions in C++ would have to be removed or revised to make a more bug-resistant language. Java code executes within the JVM (Java Virtual Machine). and it was designed with network communication in mind. Sun has always made Java implementations available for free. When you compile a Java program. The Java language specification was developed by Sun Microsystems. the syntax and standard libraries of C++ are under the control of a standards committee of ANSI (American National Standards Institute). One of the great strengths of C and C++ is the enormous number of libraries of already debugged code available for your free reuse. Sun has involved many individuals and industry partners in the subsequent development of the language and standardization proceeds through an organization called the Java Community Process rather than ANSI. Unfortunately. C++ also inherits from C the many possibilities for hard to find bugs. At that time. History of the C# language . multithreading (the ability to run multiple tasks simultaneously). and this policy has stimulated a huge community of programmers to create their own freely available resources. started development of C++ in the early 1980s as described in a short history. The major technical advance made by the Java team is the concept of platform independence. it means an implementation that adheres to the standard.

C uses int to indicate an integer number. The opening curly brace { starts the content of the main function.h> int main() { printf("Hello. The following section looks at the C program in detail. In this case. .h. you have to list the libraries you want to use. If you want to dig deeper into this problem. so the programmer must be careful to ensure that the header files match the library that's being used. First released as part of the Microsoft. Alternatively. Also by convention. The line #include <stdio. } This code illustrates many important elements about the C family of languages. you can also use a trial version of Microsoft Visual Studio (or the always free Microsoft Visual Studio Express) to write C# code.h> tells the compiler that you're going to use the standard IO library. In discussions about commercial computing applications. world" are famous exercises for learning any language. let's move on to building a real program in C.therefore. terminated with N). C++. and C#. By long-standing convention. Now that you're familiar with the history of C.A relative newcomer to the game is Microsoft's C# (pronounced "C sharp"). Programs that do nothing more than display the words "Hello. stdio stands for STandarD Input/Output. Using a library Libraries are essential to getting anything done in C. C# includes a native Boolean (binary) data type. However. Libraries in C and C++ are organized by means of header files that are usually named by some sort of acronym for what they do. you can download and install the open source DotGNU package that includes a C# compiler. C# is an OO (object-oriented) programming language that starts with the basic building blocks of C++ and adds some important features. world!\n"). return 0.h -.NET initiative in 2000. C# uses a platform-independent compiled code format that may be transferred from system to system. Exploring the contents of a C program What does I18N stand for? #include <stdio. header file names end in . It. C programs are written with a function named main that's executed when the program runs. This stands for Internationalization. is usually the first task most programmers try to do with a new language they learn. Program conventions By convention. At the start of a C program. (the letter I. this function must return an integer value used to indicate whether any errors are encountered. and the closing curly A header file contains information on how the various functions in a library are named and the parameters they take. whereas C++ requires you to use an integer for this purpose. C# doesn't use header files to include code like C and C++. you might run into the acronym I18N. if you're willing to get your hands dirty. Header files are separate from the actual library code they describe. or the problem of making sure your application can handle the character sets and language conventions of languages in use all over the world. Some of the major differences between C++ and C# are: The most common way to use C# is by purchasing a copy of the Microsoft Visual C# package. start at the UNICODE organization that was created to standardize character sets. stdio. followed by 18 letters. or something similar to it. Java. Here's the world's simplest C program that actually performs an action:   Like Java.

There's similar notation. just as you saw with the JavaScript function in Lesson 3. a = ( b + c ) * ( d + e ) . which is the convention for not having any error. you can attach the symbols ++ or -. Type character char integer int Abbreviation Size in C/C++ Size in Java 8 bit or 16 bit 16 bit or 32 bit Always 32 bit Always 16 bit Although Java has exact definitions about variables. C also has some convenience notations that won't be familiar from algebra. // called post-increment . In the second statement. as in the following: In words. then the computer adds 1 to b. then puts that incremented value in the a variable. C family programming languages expect variables to be declared with a type that indicates the kind of data the variable holds. Now programmers have to worry about I18N. Having this knowledge in advance lets the compiler create more efficient code. so more bits are needed to represent more different characters. Table 4-1 summarizes the points that cause the most trouble: Table 4-1: Some differences in variable types among C family languages. One reason for the difference is that C has been used for many different sized computers and never got standardized in areas related to computer hardware limitations. When C got started. the computer adds 1 to the current b variable. that statement says multiply the sum of b and c and by the sum of d and e. Also by convention. each complete code statement is terminated by a semicolon. the multiplication is performed before the addition. storing the result in a. Characters in Java always use 16 bits because Java attempts to provide for the character sets used in writing a large fraction of the languages in use in the world today. C variable types In contrast with typical scripting languages. C family arithmetic expressions should look familiar. statement declares that the value returned by the main function is zero. The return 0. // called pre-increment a = b++ . some important points about type declaration in C and C++ vary between a variable. C also assigns relative precedence to arithmetic operators so that if an expression is ambiguous. The statement printf("Hello. such as a + b * c.brace } shows the end of the function. practically all programming was done with the small character set used in English. the current value of b is taken and assigned to a. The C family of languages uses pairs of curly braces to enclose logical blocks of code statements. C arithmetic expressions If you remember your algebra. C uses parentheses to enforce the order of evaluation. world!\n"). such as the following: In the first statement. is a call to the printf function in the stdio library with a string constant. called a = ++b . For example.

show(). subtracts values. However. AWT stands for Abstract Windowing Toolkit or. the index n starts at zero and is incremented with every cycle: That would work as long as the buffer array was created large enough to hold the data. it's time to get a taste for another language. Two widely recommended books for learning the basics of C or C++ are Ivor Horton's Beginning C++ by Ivan Horton and Schaum's Outline of Programming with C++ by John R. and that readData is supposed to return a value of -1 to signal that the last data has been read. as its name indicates. while( (ch = readData() != -1 ) { buffer[ n++ ] = ch . To write the C code to handle even the simplest window is complicated.and post-decrement. The final * indicates you may use any class in that library. . To create a running program. The next section takes a look at a simple Java programming example. For example. Dissecting a simple Java program   Now that you have a C programming example under your belt. In C. add( new Label("Hello World". The following code looks plausible. Annoying Windowing Toolkit. An important driving force for the adoption of OO languages has been the rise of GUIs starting in the 1980s. what happens then is that the data gets stuck in the middle of whatever happens to follow the array in memory—a buffer overflow. int n = 0 . the code starts with an import line that tells the computer you're going to use a library called java. Just as the use of subprograms enabled early C programmers to start with a library of reliable functions.*. } } Similar to the other C family languages.pre. setSize( 200. } public MyFrame(String title ){ super( title ). you write your entire program as a logical unit called a class. Here's the complete Hello World program in Java: import java.awt. which. Label.CENTER )). All of the code for a class is contained in a single text file and is compiled by the Java compiler into a single file of computer instructions. you've made no provision for detecting that n has reached the end of the array. } Getting a C/C++ programming environment set up and compiling even simple programs is beyond the scope of this course. It's the cause of many mysterious bugs in C and C++ programs and is exploited by virus writers. In Java. if you're having a hard time with it. the Java runtime environment creates one or more objects using the compiled code as a template. using the correct OO language lets you start with some complicated capabilities. suppose you want to fill an array called buffer with the successive values returned from a function called readData. public class MyFrame extends Frame { public static void main(String[] args){ MyFrame mf = new MyFrame("MyFrame"). mf.awt. all reliably debugged and documented. 120 ). Hubbard. You'll frequently see the post-increment notation used in conjunction with arrays to automatically increment the array index.

. it can't run a program. Extending a class means to create a new class that inherits (gets by default) the attributes and methods of the class being extended. The other parts of that main function declaration are glossed over here to avoid getting bogged down in detail. The MyFrame constructor The remaining code in MyFrame is a constructor.Next you get to the most important line Inheritance provides one of the most significant benefits of OOP -. Your MyFrame class can use functions and variables from a complete hierarchy of classes. your class is able to use all of the cool capabilities that Frame provides. You don't see a show function defined in the MyFrame class because you inherit that function from Frame.the ability to easily reuse code. mf. At this point the object has been created. the main function: Similar to C. It says to use the MyFrame class as a template to create a new object. all the way back to the most primitive Java class called Figure 4-1 shows a screen shot of running the MyFrame program in Windows. or minimize it because MyFrame inherits all of those capabilities from Frame. the convention is that programs start by executing a function named main. You can drag that window around the screen. } The second line creates a variable of the MyFrame type that's named mf and says to create a new MyFrame object to store in mf. Because MyFrame extends Frame.awt library and is the typical starting point for Java programs that need a GUI window. Okay. public static void main(String[] args){ MyFrame mf = new MyFrame("MyFrame").the class declaration.the string representing the title that you want the graphic window to display: public MyFrame(String title ){ super( title ). The line mf. It has one parameter -. which is a special method for initializing a new instance of a class. You'll come back to this in later lessons. but not yet shown onscreen. Look at the next chunk of code in MyFrame. This says that your program is going to be in a class named MyFrame and that it's going to extend a class named Frame. back to the code. says to call the show function that belongs to the MyFrame class. The Frame class comes from the java. Figure 4-1: The window created by a MyFrame object. The keyword new that appears in this line is unique to OO languages. If the Java runtime can't find a main function. which inherits from another class called Window. just like that. resize it.

Although it looks similar to a function declaration. In the next section. 120 ). but you can add functionality by defining more functions in the MyFrame code. In particular. setSize( 200. setForeground(Color. setSize( 200.*. you can modify the background and text color by modifying the code example from the previous page as follows: import java. } This is accomplished by the super( title ). the MyFrame code gets access to a bunch of interesting variables and functions related to its appearance and behavior.CENTER )). the line setSize( 200. You don't inherit any method from Frame that shows a message because a Frame is intended to hold other GUI components that do handle messages. a constructor is in a special category. line that calls a constructor in the Frame class. All of the classes from which MyFrame inherits. setBackground(Color. Constructors always get invoked by the new keyword and carry out a special set of instructions. After that. public class MyFrame extends Frame { public static void main(String[] args){ MyFrame mf = new MyFrame("MyFrame").awt. } } This produces the window shown in Figure 4-2. Label. 120 ). you create a Label object and then add it to the Frame. Using the new keyword. you call the Label constructor with a message and a special constant that tells the new Label to show the message centered in the area it occupies in the Frame.awt library you To get the words "Hello World" displayed. calls a function (inherited from Frame) to set the size in pixels of the space MyFrame takes up onscreen.yellow). add( new Label("Hello World". it calls a version of the Frame constructor that takes a title string parameter. have to be called to build a MyFrame object. add( new Label("Hello World". . it doesn't do anything but show up on the desktop display. Label. 120 ).CENTER )). Of course. By extending Frame. Note that it doesn't declare a returned variable. } public MyFrame(String title ){ super( title ). Here's a short list: Background color Foreground (text) color Screen position and size Default font used by the label Whether or not the user can resize the window How the mouse cursor appears when it's over the window The icon that shows up on the tool bar when the window is minimized   For you'll look at ways you can extend this example to perform more complex functions. all the way back up the hierarchy to Object. The Label class is part of the java. mf. Enhancing the Java example   That's all it takes to create a custom version of a GUI window display.

C#. Quiz #4   A) B)   A) B) Challenge exercise Try building a program in the language of your choice following one of the tutorials or using open source code as a base. you made a start on the features of OOP with an emphasis on programs for graphical user interfaces. Add the Web sites you find most useful to a "Programming Resources" folder in your favorites or bookmarks list in your Web browser. and is a major part of the rich. complete the assignment and quiz for this lesson.awt library. much more. After a quick look at a program in the most primitive of this group. or Java can draw on both free and commercial libraries that cover a huge number of topics. visual nature of most high-end user-friendly programs. and/or Google Code. Programmers who use C. Question 2: True or False: There are aspects of C++ that are in C but not the other way around. Here are some of the elements you could create: And there's more. False False . the Apache Software Foundation. Labeled push-buttons Check boxes or radio buttons Scrollbars Text entry boxes or areas Drop-down selection lists Images A menu bar with drop-down menus You could build a user interface by adding GUI elements created from classes in the java. or find your own favorite resources. you'll leave the topic of OOP to look at the markup languages HTML and XML.Figure 4-2: The modified MyFrame window. GUI programming is a complex and interesting endeavor. Before you move on though. C++. In Lesson 5. True True Question 1: True or False: C was developed on the Windows operating system and still has some things in common with it. Browse the open source code offerings and programming tutorials offered at SourceForge. Moving on Assignment #6 This lesson introduced you to an important group of programming languages that got started with C.

Function Routine Class True Constructor Java C++ C C# Understanding markup languages Beginning programming for the web False A majority of programs written today are designed to work on the web. such as HTML.  Question 3: Which of the following programming languages compile into platform-independent code? (Check all that apply. and Java. It's extremely likely that you'll run into XML marked up documents more and more. Who invented hypertext? Just a little history Throughout programming history. whose approach is considerably more sophisticated than what HTML provides.   In Lesson 4 you learned about some of the most popular and widely used programming languages today. You're probably familiar with the way HTML controls the appearance of a marked up Web page and the possible hypertext link interactions a user can have with the page. A famous example comes from the programming field. PHP and JSP. so this lesson takes a detour into markup country before continuing with programming languages. separates the markup information from the document data. You can use hypertext to move from one section of a page to another or from one Web page to another. such as < and >.) A) B)   A) B)     A) B) C) D) C) D) Question 4: What's the name of the logical unit that comprises an entire Java program? Question 5: True or False: To extend a class means to create a new class that inherits the attributes and methods of the class being extended. a hyperlink is an example of hypertext. which are important to Web technologies. which is important in the interpretation. the idea of hypertext was actually invented years before the Web by the visionary Ted Nelson. Markup languages control interpretation of data. C#. The use of the HTML for Web pages was an important development that made the World Wide Web feasible and incredibly useful. Much programming effort is devoted to creating or interpreting marked up documents. This lesson focuses on markup languages. However. . The other highly significant markup language in modern computing is XML. You'll also learn how XML exchanges data among different systems. and storage of all sorts of data. In Web programming. A special character set. such as C++. many programmers tried to create platform-independent markup languages designed to control the exact appearance of printed text in electronic form. where computer scientist Donald Knuth got annoyed with the poor quality of the typesetting of mathematical expressions in the first Hypertext is a string of characters or a graphic that's linked to other text or a location on a page. Interpretation of this extra information naturally requires programs specifically adapted to the particular markup language. In this lesson. you'll learn about web programming technologies and languages. transmission. You use a markup language to add extra information to a text document to control the interpretation of the data it contains.

Note the special markup starting with <!-. The preceding example includes extra spaces that indent lines of code to better illustrate how lines are enclosed by pairs of tags. future versions of HTML that are closer to the XML standard will have to keep tags in lowercase. indenting isn't an HTML requirement. which tell a Web browser how to treat the text between the tags. </html> tag pair. and the programs you use to display and edit SGML documents are very large. .volumes of his monumental series of books on programming algorithms. The basic idea. the markup language of the Web. </head> and <body> . however. Figure 5-1 shows the HTML Web page coding example displayed in a Web browser. The <head> . The head and body elements are nested. however. not an element. which means contained. which evolved into SGML.</p> <!-. let's move on to the most common markup language in use today: HTML. GML. He set about to create a typesetting markup language to improve the situation. HTML tags can be uppercase or lowercase to be interpreted correctly by Web browsers. </body> tag pairs form the head and body elements respectively. such as aircraft manufacture. which are the only elements that can appear directly inside the root element. . The <html> . . . There's that tie-in between markup languages and programming again. called TeX. was invented at IBM to make the creation of complex program documentation easier. The direct forerunner of HTML and XML was SGML (Standard Generalized Markup Language).this is a comment --> </body> </html> The parts enclosed in the < and > pairs are HTML tags. SGML is widely used in industries that have large technical documentation problems. so why not start using lowercase now? The entire document is enclosed in the <html> . The first is called the openingtag and the second is the closingtag. .and ending with --> character sequences. This is a comment. . You can use a simple HTML page to get a grasp of several important principles:   <html> <head> <title>A really simple page</title> </head> <body> <p>This is the body text in a paragraph. The language he invented. . SGML is a highly complex language. and won't be displayed by a browser. </html> tag pair forms the root element of the document. However. . It enables you to keep one master document that can be processed (by various programs) in a number of ways to meet a number of different needs.   Working with HTML tags and elements Now that you're familiar with the history of markup languages. inside the html or root element. is widely used in publishing today. served as an inspiration for HTML. .

the <p> . . although Web browsers aren't strict about this. Many W3C projects are related to standardizing and improving the information carried by markup languages. and there's a determined effort to create a version of HTML that follows the XML rules. Tag pairs and empty tags When using HTML tag pairs to define elements. You'll learn about XML later in the attempt to make the resources presented on the Web more directly usable by programs. HTML adopts a convention for empty tags that's contrary to that used in XML. </p> tag pair must be completely inside the <body> . and establishes a clear roadmap for future HTML extensions. . any nested tags inside the pair must be closed before the element closing tag appears. In the example. XML. reflecting the incredibly rapid rate of innovation in the World Wide Web as thousands of ideas jostle for acceptance. It's this strict control over what can appear where in an HTML document that makes it possible for Web pages to be displayed in different Web browsers without too much variation. being extensible. Many W3C standards are in a nearly constant state of revision. The HTML specification clearly defines which types of elements can appear inside other elements. It'd be advantageous to programmers if both HTML and XML followed the exact same rules for forming tags. The W3C (World Wide Web Consortium) has a standard called XHTML that accomplishes this.Figure 5-1: Example of a Web page appearing in Microsoft Internet Explorer. Tag attributes An opening tag can have additional information called attributes that take the form of name="value". </body> tag pair. The DOM (Document Object Model) is a W3C standard defining how scripting languages and programs can address and modify the various elements of HTML and XML documents. <input name="msg" type="text" size="40" value=""/> HTML standardization and the DOM The W3C is the organization responsible for defining the specifications for HTML and creating many other Web-related standards. In contrast. and element locations. doesn't have this sort of standardization. and as a singleton such as the <br> tag that causes a break in the text. Unfortunately. Singleton tags are also referred to as empty tags because they don't enclose anything. HTML tags can appear in two ways -.paired as in the previous example. . . fonts. Typical uses for attributes are to set color. You already saw these in action in Lesson 3 where an input element in a form was defined with the following empty tag: Conventions dictate that the value of an attribute always be enclosed in quotes. One of the most fascinating projects is the Semantic Web -. An HTML document that adheres to this rule is said to be well formed. .

} } The notation that this code uses to address the value attached to the form field named msg in the form named ctrl is using the DOM.getDay() == 0 || today.msg.write("<p>Look busy."Monday". A Date object has functions that can interpret that time instant as various parts of a calendar date. The today variable is interesting because it's an object that contains complete information about the instant the object was created. } </script> </body> </html> Figure 5-2: An example of client-side dynamically created Web page content. } else { document."Tuesday". "Wednesday". // erase input for( i = s. ctrl. You can also use JavaScript to add content to an HTML page as it's being loaded on the client (called client-side scripting). The code in the head defines two variables -. The following is an example in which the Web browser executes the script in the <body> element.charAt( i ). You might see the term DHTML (Dynamic HTML) applied to pages that use JavaScript to change the appearance of a Web page on the fly.write("<h1>Today is " + dayName[ today. read on to learn how HTML and scripting languages work together."Saturday"). the JavaScript code is in two pieces -.msg.getDay() ] + "</h1>" ).write("<p>Goof off all day.</p>").getDay() == 6 ){ document. The DOM enables JavaScript to address many elements and properties of an HTML page. and the today variable.length + 5 . Figure 5-2 shows the results displayed in a Web browser.value += s. Note that in this example. i >= 0 . and one in the <body>.an array of day names.msg."Thursday".value = "" . Here's a portion of the JavaScript used in the Lesson 3 example of responding to an event:   function doReverse() { var s = ctrl. .value .Understanding how HTML and scripting languages work together   Now that you're familiar with HTML in the <head> element of the page. if( today. <html> <head><title>Weekly Planner</title> <script language="javascript"> dayName = new Array ("Sunday". today = new Date . and the script writes the entire contents of the body. </script> </head> <body> <script language="javascript" type="text/javascript"> document.){ ctrl.</p>")."Friday". i-.

A program on the server side doesn't have these limitations. it actually creates a small Java program that outputs the HTML and adds in the current date. The basic idea of server-side scripting languages is that when the server is called upon to send a file.util. The document object has ways of addressing all parts of the page. Usually. and the function call write says to output this text at the current writing point of the page. these special tags form a kind of scripting language. Here's an example of a PHP page that prints a random . whether they're named or not. Figure 5-3: Server-side dynamic content from JSP. the document is the way the DOM refers to the object that contains the entire page. you'll take a look at two server-side scripting languages: PHP and JSP. resulting in the Web page shown in Figure 5-3. On the client side.write statements. See how to use the JavaScript Weekly Planner script. people immediately figured out that it would be cool to combine the static content of a page with dynamic data created on the fly. a scripting language is limited to what it can do by Web browser security settings. When HTML was first developed. The if statement checks to see if the day of the week is 0 (Sunday) or 6 (Saturday). ASP. PHP. and JSP.Date"%> <%= new Date() %></h1> <hr/> </body> </html> When a JSP-capable Web server sees a request for that page. it looks at the file type to see if that file gets special processing. As is typical in technological revolutions. (1. it's based upon the popular Perl scripting language used commonly on Unix systems for text processing. Some of these developments survived. The following is a simple example marked up with JSP tags that start with <% and end with %>:   <html> <head><title>Dynamic Page Content Example</title> </head> <body> <h1>The time now: <%@ page language="java" import="java. In the document. many different approaches were tried. Essentially. PHP is another common server-side scripting language.7 MB) It's important to distinguish between code that executes in the Web browser or client environment and that which operates on the Web server. Instead of being based on Java (as is the case with JSP).   Working with JSP and PHP In the next section. a marked up file will have plain HTML with special tags that produce output from the scripting language. iHTML (inline HTML). some have been replaced.The code in the body of the page uses the getDay function to get the day of the week and then uses that to compose the text that gets written to the body of the HTML page. Cold Fusion. the || symbol is what JavaScript uses for the Boolean logic OR. All of these different schemes were based on some kind of markup language mixing special tags with the HTML tags and using special processing programs on the Web server. But you might recognize one or more in this list: serverside JavaScript.

such as the Microsoft Office 2007 suite. <Br/> . and <BR/> are three different tags. These names are reserved for future expansion of the standard. You can invent your own tag vocabulary to apply to your own particular problem. An XML document that has tags nested correctly and conforms to a few other requirements is said to be well formed. With simple markup tags. Learning XML basics Similar to HTML. all tags used like HTML tags must be in lowercase. The XML standard was derived by simplifying SGML and eliminating much complexity and inconsistencies that make working with SGML a full-time job. so only <br/> would produce a text break in an XHTML compliant browser. The following is an example: <?xml version="1.   All tag names in XML are case sensitive. In XHTML.0"?> .number between 1 and 100 in the user's Web browser: <html> <head><title>Random Number Generator</title> </head> <body> <h2> <? srand(time()). similar to the <% and %> tags in JSP. In XHTML. Another name requirement is that general users must not use tag names beginning with x or X. your XML formatted documents can be processed with standard toolkits that are available in many languages. so <br/> . so a program reading XML can be sure that it doesn't have to look for a matching closing tag. Scripting languages using specialized markup on the server side are an essential part of the modern Web. The W3C sponsored the XML development effort because they realized the true potential of the Web for communication could only be reached if people had a flexible way to describe just about any kind of data. a complete XML document usually begins with a statement in a specialized format that states the version of the standard it conforms to. however. has spread well beyond the Internet and can now be found in many computing applications. Empty tags in XML are required to end with the /> character sequence. you're ready to dive into XML basics. The use of XML. and a few basic rules. $random_number = (rand()%100)+1.   Now that you've explored PHP and JSP essentials. That topic is covered next. print("Your randomly assigned number is $random_number"). XML is a markup language that follows a standard defined by the W3C. The difference is that the standard only defines the syntax conventions. As long as you follow the rules. ?> </h2> </body> </html> Notice that the PHP code is separated from the rest of the page by the <? and ?> tags. you can access databases or draw on resources distributed all over the Internet to create a custom page for your customer. XML has the same requirement for the nesting of tag pairs that HTML does. the <br> tag must be written <br/> to comply. Although it's not required.

your program is handed an object that contains the whole document. An example XML document Suppose you want to store all of the text in one of these lessons as an XML document. Reformat the document as a series of small pages in WML (Wireless Markup Language). when creating and editing. and any search engine can help you locate XML tutorials. Why would you want to do that? The following section takes a look at some possibilities. Complete details on XML formatting are beyond the scope of this course. In the building objects approach. Reformat the document in the widely used PDF (Portable Document Format).more paragraphs go here --> </page> <!-. Reformat the document as a series of HTML pages. and building objects that contain entire elements. </paragraph> <!-.. XML is a markup language that follows a standard defined by the W3C. organized so you can rapidly locate any part of it. The following is a skeleton of the document structure you could use. This is essentially the document object model approach used in JavaScript manipulation of a Web page. for example. You can find the formal documents at the W3C Web site. The content and arrangement of elements in a valid XML document conform to a specification in a DTD (Document Type Declaration) or an XML Schema. but it can never be valid and not well formed. There are basically two approaches: parsing into separate tags and parts of elements. An XML document might be well formed and not valid. The difference is that . Your code has to decide what to do with each part of the document on the fly. In the separate parts approach.more pages go here --> </lesson> Discovering data manipulation with XML   That sure looks very similar to the HTML you might use to display the lesson. XML documents can be valid. you get to make up your own. one per <page> element. but instead of using standard HTML tags.   . used by WAP-enabled cell phones. showing just the first page and leaving out the bulk text: <?xml version="1.In addition to the concept of well-formedness. a parsing program takes the document apart at the points where tags appear and hands the programmer the separate parts in the order of the original document.0"?> <lesson number="5" author="Chapple"> <title>Beginning Programming for the Web</title> <page pagetitle="Learning XML Basics"> <paragraph>Similar to HTML. Reformat the document as a single HTML page. It's handy when your program has to access various parts of the document repeatedly. Store each <page> element in an XML-enabled database.. Build a table of contents for the lesson by extracting the pagetitle attributes from the <page> elements.. This approach is particularly good if your program has to extract a small chunk out of the whole document. for example. The following are some tasks that can be done by processing the XML document representing this lesson: Libraries of code for processing XML documents exist in many computer languages. extracting the pagetitle attributes to build a table of contents.

org applications provide the option of using XML for documents. such as the Internet. and almost all creators of content for the Web need to know the basics of creating XML documents. XML versus EDI Corporations have been using EDI (Electronic Data Interchange) formats to send documents such as bids. Before you move on. A Web service is a set of tools that's accessible from a network. data gets transmitted in a compact form using esoteric codes that can't be read by humans. You could have a program that automatically searches all vendors for the best price and availability for a particular part. suppose vendors of auto parts provide their entire catalog as Web services. You also got an indication of how marked up documents can be treated as objects. Both the request and the response are formatted as XML documents that can be read and interpreted by programs. and processing XML documents in addition to its proprietary formats. Having corporate data in XML format makes it easy to communicate with your customers through Web services or to generate the content of your corporate Web site. This move by Microsoft was necessary because more and more businesses were using XML as a standard for document storage and interchange. . it makes more sense to use human-readable XML formats. Popular Web services include remote procedure calls and SOA (service-oriented architecture). If you pay any attention to the business news. For example. and something called RESTful Web services. The idea with a Web service is that a company provides a special sort of Web server that responds automatically to requests for particular kinds of data. is a suite of open source applications similar to Office productivity applications. almost all programmers need to know the basics of processing XML. The big problem with EDI formats has been that because they were created when transmission speeds were slow and long distance connectivity was expensive. and invoices back and forth for years. XML-enabled Office applications Microsoft Office 2003 and later versions are capable of reading. writing. it's easy for both humans and programs to understand the process. By using XML. OpenOffice. Lesson 6 delves into storing data in memory as well file manipulation and memory management. OpenOffice. orders. Like the Office suite. you know that something called Web services is a hot topic. and showed how markup languages are intimately involved with today's programming tools. Now that connectivity is inexpensive and transmission rapid. For users of Linux and those who don't want to pay Microsoft's licensing fees. complete the assignment and quiz for this lesson. Moving on Assignment #7 This lesson introduced you to features of the markup languages HTML and is a viable alternative.XML and the future of programming Web services It's safe to say that in the future. and has a well-defined set of functions it can perform on request.

0"?> <lesson number="5" author="Chapple"> <title>Beginning Programming for the Web</title> <page pagetitle="Learning XML Basics"> <paragraph>Similar to HTML.xml extension:   <?xml version="1.this is a comment --> </body> </html> Remember. (In Microsoft Internet Explorer. XML is a markup language that follows a standard defined by the W3C.more pages go here --> </lesson> 1. Save the file with an . or any text editor of your choice. Pick a fairly simple Web page on the Internet. 2. Investigate the code and compare it to the rendered page in your browser to see if you can determine what each tag does. . you can name the XML tags anything you like. The difference is that . Manually convert the file to XML using the following example as a reference and save it with an . Use the following HTML markup code as a starter to create a personal Web page for yourself that includes at least two short paragraphs and comments: <html> <head> <title>My Web Page</title> </head> <body> <p>This is the body text in a paragraph...more paragraphs go here --> </page> <!-. HTML-Kit. and are revolutionizing the way programs are delivered to end users. 2.html extension. or another program of your choice) and in your Web browser..and XML-based Web pages in a Web browser. For this assignment: Challenge exercise Assignment #8   For this assignment: Web services are emerging as a significant modern technology. 1.) 2. Use Windows Notepad. 1.htm or . and view the source to see the mixed data text and markup that creates the page. Experiment! 1. select View > Source to view source code. for example.</p> <!-. </paragraph> <!-. HTML-Kit.The best way to learn about markup languages is to experiment with examples. View your HTML. 3. Save the source on your own computer as an HTML file. take the W3Schools Web Services Tutorial or research this topic on your own. To learn more about Web services. Open the file with an editor (Notepad.

.) Question 2: True or False: All tag names in XML are case sensitive.Quiz #5 A) B)     A) B) A) B)   A) B)   A) B)   C) D) Question 1: Which of the following terms describe a markup language tag? (Check all that apply. HTML and XML. file manipulation and memory management. Imagine a room full of Fastrand memory drums rumbling like a power plant and holding less data than a single hard drive in a modern notebook PC. initially. enabling any programs you create to work with it. to discuss how a computer reads and saves data. You'll wrap up the lesson by examining databases -. True PHP JSP <? ?> False ASP Attribute SGML Paired Singleton Question 3: Which of the following are server-side scripting languages? (Check all that apply.which make heavy use of a computer's reading and writing abilities -. memory has always been one of the dominant factors. you'll learn the important programming concepts of data storage. the first Univac stored data as vibrations propagating through thin columns of mercury. Early computers used some bizarre methods of data storage.   Different types of computer memory In the technological saga of the computer revolution.and the base language that supports them. for example. This lesson segues from languages.   Lesson 5 focused on Web-related and scripting markup languages: mainly. You'll also learn how programs interact with databases to efficiently retrieve and store large quantities of data.) C) D) C) D) C) D) Question 4: Which tag marks the beginning of PHP code? Question 5: Which language is commonly used to create Web services? XML HTML OML BASIC <% %> JavaScript How to remember stuff Reading and storing computer data In this lesson.

The following table lays out the territory for further exploration. Now. Medium Nonvolatile Gigabytes Query systems such as SQL to terabytes Nonvolatile Many Creating. Flash memory. Even the slightest loss of power can cause these transistors to forget everything. hard disk storage. As a programmer. called cache memory. DVD. directly on the CPU chip. computers remember data with a variety of technologies. tape Fairly fast Nonvolatile Kilobyte to Specialized according to hardware megabyte Modern CPUs have a chunk of high-speed memory. or holds your digital camera pictures in a memory stick. you need to understand what these technologies imply. the limitation of the speed of light became significant and computer designers concentrated on keeping memory as close as possible to the CPU. This improves the overall speed by having needed data in the fastest possible memory. and writing megabyte files with serial and random access to many gigabytes Flash memory is a special kind of transistor-based memory that can hold a value after the power goes off. Data is moved to and from the main chip memory by CPU logic that tries to predict what the program is going to want next.Programmer has no way to influence hundreds of kilobytes (thousands of bytes) Programming Techniques Main chip memory Flash memory Hard disk memory Network database Table 6-1: Characteristics of various kinds of memory. and writing files on file gigabytes systems with serial and random access to several methods terabytes Many Allocating space for variables. There are several varieties of removable media in use these days. The language you use has a lot to do with how you manage this memory. .As CPUs (central processing units) got faster and more compact. Memory CPU cache Speed Ultra fast Fast Fast Volatility Volatile Volatile Capacity Limited -. Hard disk memory stores data as magnetic patterns that can be read or written under the control of your operating system. Removable Varies media: CD. reading. as the operating system makes it appear identically to a hard disk. USB flash drive. especially megabytes arrays and objects (millions of bytes) Nonvolatile From File systems -. It's the operating system's responsibility to present this data to your program in the form of a file system. which is a method of organizing stored data so that it's easy to retrieve. reading. The programmer is usually able to access this memory easily. and removable media are collectively called nonvolatile storage because continuous power isn't required to hold the data. as you'll learn later in this lesson.creating. from CDs/DVDs to USB flash drives. Main chip memory uses an enormous number of tiny transistors to hold the bytes that your program uses for program code and data. Your operating system generally handles the hardware differences and presents the programmer with a consistent file system interface. This is the memory that holds your favorite TV channel settings when the power goes off.

bytes and word size Historically speaking. if you try to dimension some large array with statements such as the following. you have to explicitly request memory from the operating system for something such as the large arrays of numbers in the previous example. however. you forget to return the memory to the control of the operating system. In fact.particularly if the database management is handled by someone other than you -. However. through bad programming practice or an error. there are many programs of various sizes sharing memory so the amount available for any one program is reduced. a byte is a unit of measurement equal to eight bits.explicit memory management and automatic memory management. Fortunately for computer users.or 64-bit (4. If. you find the program fails mysteriously: This is because your computer doesn't have an unlimited amount of space in main memory to store data. Although the original microcomputers read and wrote to memory one byte at a time. punctuation. These details are hidden from the programmer. Explicit memory management Games with complex graphics CAD (computer-aided design) Web servers and other utilities that service many users and run for long periods Using C. In terms of data storage. and characters in English text. Eventually the operating system refuses to give you any more memory and .the programmer's life is greatly simplified. and you run into trouble when you request the space to store 20 million numbers. and the fundamental unit that you work with is still the byte. Bits. dim verticesX(10000000) dim verticesY(10000000) The following are some of the types of programming that require a lot of memory: This brings us to the topic of memory management. You run into two types of memory management in programming languages -. if you're running a typical Windows or Mac desktop. you can represent all of the numerals. You must also explicitly tell the operating system when you're done using it. You must also ensure you don't have two parts of your program trying to use the same memory for different purposes.When storing data in a database -. designs have converged on using an 8-bit byte as the basic unit of memory. A memory leak means your program keeps requesting memory but never gives it back to the operating system. your program experiences what's called a memory leak. with some left over for special characters.   Managing main memory Now that you have a good overview of computer memory. computer designers have tried many different ways to organize memory. let's turn our attention to managing main memory. which is either a 0 or 1. The simple programs you've seen in the lessons so far enable you to easily store variables in memory. a bit is equal to one binary digit. One reason for this convergence is that with 8 bits. modern CPUs read and write in 32.or 8byte) chunks.

In object-oriented programming. each object is responsible for managing the data it contains. In the next section. Java detects this fact by a process called garbage collection. and the memory is reclaimed automatically. the operating system hides the hardware details that are vastly different between a hard disk and CD. All you have to do is stop using a variable. the garbage collection process looks at all the parts of your program and determines all the objects that are still in use. Every other object is considered garbage. requesting memory from the operating system is handled behind the scenes by the object creation mechanism.   A file system supports locating data stored on the hardware by a directory system and file name. Essentially. Suppose you need to read the 10th line of text in a file named myfile. The amount of memory naturally depends on how complicated the object is. It also keeps track of handy bookkeeping information such as the file size. you'll examine an important part of computer memory: how information is read from memory. Your operating system is responsible for managing the stored data on your computer's nonvolatile storage media so that your programs can treat the data in a consistent way.txt in the c:\documents . Memory leaks can be subtle and hard to find. which is why modern object-oriented programming languages such as Java and C# provide for automatic memory management. A memory leak problem can be one of the most frustrating things in all of computing. or requests more from the operating system and builds a Date object there. Sequential file reading There are two fundamentally different ways of reading and writing files -. Automatic memory management In object-oriented programming languages. The memory used is isolated from other parts of the program and access is controlled by the object. your programming language provides methods that bridge the gap between the operating system and the variables in your program. In other words.the program fails. the date the file was created. the last time it was modified. and which users have permission to read and/or write data to the file. the Java program either uses some memory space it has already reserved. new Date() Examining file reading methods   When your program is no longer using the object. and presents a consistent interface called a file system. Sequential access means the opened file acts like a stream of bytes that has to be read in sequence. You saw the mechanism in action using JavaScript in Lesson 5.sequential access and random access. The following code says to create a new Date type object: When that code is executed. In turn.

and so on. the exact contents of the file are delivered to your program without interpretation. Instead. Using a special character to start the name of a variable that stands for a file is a common convention. you have to open it first. The variable that refers to a file is sometimes called a file handle. When a file is opened. That position could be . you have to close it to free operating system resources and enable other programs to use them. To read from a file. and Unix and Linux systems use just LF. It assumes the data is text with each line terminated by one or more control characters. Unfortunately. This difference creates an annoying requirement for a translation program when transferring files between systems. Control characters By convention. You might also see the term newline for the character or character sequence that terminates a line. When reading a file you must always consider the possibility that the file isn't as long as you expect. it's assumed that the READ command would read an entire text line into the string variable. your read command has to designate an array of bytes to receive the data and explicitly say how many bytes to read. CR returned the print head to the start of the line. ring bells on teletypes. In this example. after reading nine lines. Reading in binary mode Programming languages also provide a mode of file reading that doesn't try to find lines of text terminated by a newline marker. to refer to the file. When you're done with the file. commonly denoted as the EOF condition. the next read operation would start at the beginning of the 10th line. Early computers used a number of special control characters to control printers.CR and LF -. The following is some pseudocode that's representative of all computing languages: OPEN "c:\documents\myfile. not every operating system uses the same combination.txt" AS #input DO READ #input INTO astring IF EOF PRINT "hit end of file" BREAK INCREMENT linenumber UNTIL linenumber EQUALS 10 IF NOT EOF use the astring variable CLOSE #input This pseudocode illustrates several important features that all programming languages use: In the pseudocode example. the file read pointer (an address or reference to a location in the program) would be positioned at the 10th line. In the example. For this to work. Opening a file and reading it in this manner is called working in the text mode. Windows systems use two characters -. hitting EOF before the 10th line causes the program to break out of the loop. you read 10 lines into the astring variable with each successive line replacing the previous one. In this binary mode. With sequential access you have to read and discard everything in the file up to the point where the data you want lives. You must provide for detecting the end of the file. At that moment. The command that reads the file specifies where to put the data. The characters in common use for end-of-line indication are called CR (carriage return) and LF (line feed). That's actually a common convenience in programming languages because processing text files is a common problem. This example assumes the READ command reads a single line of text into a string variable. Random access file reading In the sequential reading example. The operating system ensures that you're allowed to open that file and causes a fatal error if you're not.folder. #input in the example. and LF advanced the paper one line. Back in the days of teletypes. the programmer uses a variable. the file must use a convention for special character or characters signaling the end of the line.Macintosh uses just CR. certain characters known as control characters are used to indicate the end of the line.

One way to do this is to use the same record size. Now that you have a good understanding of reading files from disk. the following three lines of code write a single line of text to a file named out because only the println command automatically adds a line terminator. This makes it easy to test your program with writing to the screen and then switch to writing to a file. The language regards the screen or printer as just another place to send a stream of characters. opening a file with an existing file name can cause the previous contents to be overwritten. if you're writing a file of addresses and want to put the entire address on one line. If your record design changes. recordBuffer ) OPEN "checks. OPEN "theoutput. For example.dat" FOR RANDOM AS #ranf SEEK #ranf TO chkNum * checkRecordSize READ #ranf recordBuffer CLOSE #ranf RETURN In another part of the program. you have to write a program that can read all of the old records and write a new file with the new record sizes. In other words. Using random access becomes increasingly helpful as files get larger. there would have to be routines that pick the characters out of the recordBuffer and then interpret them in terms of your check records. you don't have to write a single PRINT command to do the whole thing. Database technology absolutely depends on random access because the files are so large. but is limited by the fact that after you've decided on a record size for a file. you can't change it. World" CLOSE #out   You have to be careful about the conventions each particular programming language has with respect to writing complete text lines. the syntax computer languages use for writing text data to files is similar to that used for writing to the screen or printer. In the following pseudocode for a subroutine to read a record. every time. you need to understand whether or not the language automatically writes a line terminator character sequence with every PRINT statement. there is usually a syntax for opening a file in append mode so that new data is written at the end of the file. You still have to open the file and use a special variable to refer to it as shown in the following pseudocode: In most languages. it's time to take a look at storing data on a file system using sequential file writing.described with an integer as the nth byte in the file. Just think how much harder it'd be to read the last 100 bytes in a 10 MB file by sequential reading instead of seeking a file position equal to the size of the file minus 100. similar to the first element of an array is in position zero. When reading and writing with random access. in Java. the variable recordBuffer is an array of characters that has a fixed size so you can calculate where to read: FUNCTION readCheck( chkNum. you must know exactly where the data starts in the file. . where the first byte in the file is at position zero. But you do have to be careful when choosing the syntax for the particular language you're using.txt" AS #out PRINT #out "Hello. however. For example. That's covered in the next section.   Discovering file writing methods Generally.

providing data for each column.dat" FOR OBJECT WRITING AS #obj WRITE #obj userPref CLOSE #obj Working with databases   When reading and writing objects. Some object-oriented languages. state. your query would match the names between the two tables to find A good example of a Web site with a database behind it and that uses programming to help the Web pages talk to the database is an online store. Using SQL. In this case. street address. Later you can read the object back in and resume working with it. Rather than get into programming language specific issues. " + city + " . Modern relational database systems organize data into what are called tables. but it would still be quite simple. You enter information about what you want to buy. let's move on to a dataintensive subject: working with databases. Most modern database systems (products such as Oracle. For example.print( lastName + ". you must complete the entire row. and Microsoft SQL Server) can process a special type of language. or ask it to return information. To insert information into a database table. Assuming you have designed your program so that all user settings are contained in a single object named userPref. This capability can be extremely handy. the pseudocode for saving that object in a file named userWB. " + firstName + " . where to ship your purchases to. let's look at the query language itself. you can retrieve specific information from a table. mySQL. and ZIP code from the address table for every name in the flyer mailing table whose last mailing date is older than one month from the current date. Database systems are useful. You use these languages to query the database. out. You can also perform queries that are more complicated.print( streetAdr + ". provide convenience methods that enable you to write the entire contents of a complex object to a file. Exactly how these queries are created and used in your program depends on the facilities in the language you're using. out. and each column stores a particular type of information. you can't change the definition of what goes in the object and still be able to use objects saved with the old definition. For example. city." ).println( phoneNumber ). such as the ZIP code for everyone in an address table whose last name is Smith. you can't just pick one cell where one row and one column meet and then write in the value. Websites and databases Introducing the Structured Query Language Almost every database today uses SQL. Think of a table as a ledger or as a spreadsheet: you have rows and columns. suppose you're writing a program that has a number of personal preference settings for each user.dat is as simple as the following: The real code in Java or C# would be a little longer because you have to take into account the various errors that could happen. Now that you understand methods of reading and writing data. called a query language. Using query languages. and how to pay for them through fields . To make an entry.Writing and reading whole objects out. you can have your query return the name. Databases are an effective way to store data efficiently in a form that's accessible to a wide variety of users and applications. you write instructions called queries to return the exact information you need. OPEN "userWB." ). such as Java and C#. but what makes them powerful is the ability to retrieve information out of them in an organized manner. You want to be able to read the settings when the user starts the program and then save them whenever the user changes them.

Note that column_name doesn't have to be the same as the one you're returning. It can INSERT new rows of data. as discussed earlier in the flyer mailing example. shipped. (If your code states WHERE some_column = 2. an UPDATE statement modifies data already stored in the database.. in different tables. and billed accordingly. The full statement looks similar to this: If you're not filling every column in a specific order in your insert. The information you enter moves through the Web page to a database so your products can be packaged. You can also use a WHERE clause to specify which rows are updated. SELECT statement Use a SELECT statement to retrieve values from a database. you have to additionally specify which values are destined for which column. or DELETE a row from the table. SELECT data from the table. SELECT column_name FROM table_name WHERE column_name = someValue UPDATE statement As the name implies. you don't have to get back a whole row of data. for example. There are four basic tasks that SQL can perform on a database table. Look at each of these four tasks. specify which tables you're modifying. INSERT statement You can use an INSERT statement to insert a row of data into a table. value2) INTO table_name on the Web. You can add multiple conditions to the WHERE clause by using AND or OR and then adding more conditions. To do this.the address for the names it identifies in the flyer mailing table. You can also add other specifications to this statement.. can be used to identify other data based on its relationship to it. and which columns of data you want to update. INSERT (value1. .) The UPDATE statement uses the following syntax: DELETE statement UPDATE table_name SET column_name = new_value WHERE conditions . UPDATE data. There are many ways this statement can be extended to do different tasks and perform more complicated comparisons. Programming and databases make all this possible. you need to specify what table you're adding data to and what data you're adding. To perform an INSERT operation. The ability to match data from different tables in this manner is what distinguishes a relational database from a flat database. You can specify which values you want returned. every row with a value of 2 for some_column will be updated. A typical SELECT statement uses the following syntax: The WHERE clause is how you specify what data you want returned. such as the name in the previous example. Pieces of data. SQL accommodates flexible logic in matching information such as this. A common SQL convention is for keywords and instructions to be capitalized.

. or between mobile devices. What happens when you read a file that isn't in text format? If you need additional help. 3.A DELETE statement removes rows from a database. you'll practice creating SQL statements. Assignment #10   Alan Weber Mary Barnett In this assignment. Moving on Assignment #9 This lesson covered the important programming concepts of data storage. Here's the syntax for a DELETE statement: SQL also includes other ways to modify these queries. DELETE FROM table_name WHERE conditions . you have to remove an entire row at a time. Because databases require information to be stored in rows. . There's much more that can be done. Display the vendors whose representatives have "er" in their names. complete the assignment and quiz for this lesson. file manipulation. Your ordering database has several tables. including one called vendors. Assume you have a specialty foods Web site and buy products to resell from a variety of vendors. Consider the following: 1. Specify which table from which you want to remove rows and what conditions describe the rows you want to delete (using a WHERE clause). 2. ContactName Company Jacob Berner Jackie Drissell Farm Fresh Snacks NE Jacob's Best Weber Fine Foods Gourmet Delights Region City NE SW NW New York City Tuscon Seattle Baltimore Write SQL statements to produce the following results: Challenge exercise Think about a data management topic that you encounter at work or school and come up with a database solution to help manage that issue. but most SQL is built around these four basic commands. Lesson 7 examines an aspect of modern computing that's related to the data storage and retrieval techniques you saw in this lesson. You also learned the essentials of database programming. Before you move on. Try this program on various small files you find on your system.. and memory management. you can have it sort the output of a person and address alphabetically by name. Delete the Farm Fresh Snacks entry. which manipulate database data. Instead of reading and writing data on a local computer. Write a program to read text files line by line and print each line to the screen. For example. A small portion of the vendors table follows. read the tutorial sections on writing files in Liberty BASIC or find additional information on the Web. Display the contact names and companies of all vendors in the Northeast region. you communicate across a local network or the Internet.

You have to write code to interpret that data as variables. DELETE FROM vendors WHERE Company = 'Farm Fresh Snacks' Question 2: Which of the following types of memory retain data when a computer's power is off? (Check all that apply.Solution Sketch the tables with column names on paper. To display the vendors whose representatives have "er" in their names: 1.) C) D) C) D) C) D) Question 3: In modern relational database systems. To display the contact names and companies of all vendors in the Northeast region: 1. or use a spreadsheet program to create the tables and columns. data is organized into ______. The solutions are as follows: 1. Question 4: Which of the following isn't a SQL instruction? INSERT DELETE SELECT ALPHABETIZE UPDATE groups tables chunks sections CD Flash memory Hard disk Cache memory True False . To delete the Farm Fresh Snacks entry: The types of tables would you use in your database Columns of data would you store in each table SELECT ContactName. Company FROM vendors WHERE Region = 'NE' SELECT * FROM vendors WHERE ContactName LIKE '%er%' Quiz #6   A) B)   A) B)   A) B)   A) B) E) Question 1: True or False: All programming languages provide only for reading binary data.

This lesson focuses on programs that help you communicate across networks -. for that matter) have now standardized on a single set of protocols: TCP/IP (Transmission Control Protocol/Internet Protocol). Networks come in all shapes and sizes. that all changed. there was no Internet back then. Let's get started. However. Networks enable computers to communicate with each other. but external connections were limited. and other devices dedicated to ensuring that you're able to get data from any given location on the network to any other location in an efficient manner. composed of a hierarchy of smaller networks including specialized backbone networks that move data between smaller networks. you learned how a computer reads and saves data. These protocols define the language used by computers to communicate with each other and serve as a worldwide standard. The three most common types of network are: To communicate on the same network. In the early days of networking. In the next section. enabling any programs you create to work with it. such as a building. switches. After all. A company might have had a LAN connecting all of its internal systems together. routers. From the perspective of a programmer. You also explored databases and the foundation of most database languages: SQL. send email and interact with mobile devices. Internet: This is a network of networks. LAN (local area network): This is two or more computers in a geographically small area. The specifics of networking are beyond the scope of this course.and between mobile devices. With the evolution of the Internet. They're made up of cables. Now it's commonplace to sit in your living room and interact over a network with a computer in another part of the country or even on a different continent.locally and the Internet -. That communication is easy because all computers on the Internet (and most LANs and WANs. This lesson covers basic networking concepts and programs that retrieve data from the internet. let's move on to more specific examples. you'll learn how to retrieve data from the Internet within your programs. such as a factory or campus. It's easier for you to use your computer to visit a Web page on a server located in China than it is to visit your corner store. WAN (wide area network): This type of network is spread over a larger area. many different protocols were in use in different organizations. . This lesson concentrates on interesting tasks you might do with a program to connect to the Internet. you do need to know how to write programs that leverage the Internet to share information. you don't need to worry about the details of TCP/IP networking -the mechanics behind getting data from Point A to Point B are for network engineers to worry about. computers must speak the same network language (or protocol).  Question 5: Which of the following SQL instructions modifies data that's already stored in a database? A) B) E)   C) D) Networking computers Programming for networks and mobile devices SELECT UPDATE INSERT DELETE ALPHABETIZE Knowing how to make computer programs that communicate with other systems over the web is essential today. a WAN provides connections between LANs using technology more suited to longer distance transmission. Usually. There simply wasn't a need for a single standard network protocol.   Now that you're familiar with the basic concepts of networking. linked with high-speed connections.   In Lesson 6.

pl: This says that you want a response from the timer. To keep the example only have to deal with TCP/IP and URLs at the programming level. The following example demonstrates connecting to a well-known site run by the United States government to provide accurate Figure 7-1: US Naval Observatory Master Clock Time Web page.Retrieving data from the internet No matter which hardware you're using to connect to the Internet -. cable. tycho.dial-up modem. take a look at the US Naval Observatory Master Clock Time Web page in your browser. DSL (digital subscriber line). which happens to be a script in the Perl scripting You're going to see a Java program example that connects to that computer.not a particularly good practice for anything larger than this example. and is also known as a URI (Uniform Resource Identifier). The following table shows some common Internet protocols and how they're used. and then captures the output. You know this is a military network site because of ". accesses that timer. Symbol Protocol http: ftp: telnet: HTTP (Hypertext Transfer Protocol) Terminal Emulator FTP (File Transfer Protocol) Used for Web resources including hyperlinks Standard utility for file transfers Character-by-character terminal emulation for remote access   Table 7-1: Common Internet script. The standard is maintained by the W3C. as discussed in Lesson 6. This program is similar to sequential file reading.a protocol plus some form of address. A URL (or This is the Internet address of a particular computer. You'll see that it produces a page containing the current time in various time zones. except that you use a URL instead of a local file function. or optical fiber -. as shown in Figure cgi-bin/timer.usno. optionally followed by additional data. http://tycho. if you prefer) is composed of at least two parts It uses the following URL: The parts of this URL are: http: This declares the protocol used.usno. Before you get started. the program accomplishes everything in a single method -. Here's a look at a Java program that'll access this Web page (the line numbers are for reference only): . A simple internet example Java is an ideal language for experimenting with grabbing information off the Internet because it was designed from the beginning to be network". A URL is a standardized way of addressing resources on the Internet.

pl <title>What time is it?</title> <h2> US Naval Observatory Master Clock Time</h2> <h3> <br><br>June 16.usno. 10: } 11: try { // 12: URL theUrl = new URL( args[0] ). you could create a program that retrieves the current time from the Naval Observatory and uses it to decide whether to sound an alarm.out. You could easily extend this program to do all sorts of interesting Line 23: The code would get executed if the statements between try (line 11) and catch (here on line 23) cause an error.1: package com. line 8 of the program will display an error message.pb .close(). 19: ch = in.* . 23: }catch(Exception e){ // 24: System. 14: conn. things can get a lot more complicated than that simple ("Problem " + e.println("Done"). java com.* . Line 17: This line reads characters from the stream one at a time and writes them out until it reaches the end. 20: } 21: in. Naturally. with the URL on the command line: you get the following response: Line 6: This is the way a Java program gets information from the command that started it. Line 11: This block of code starts with try and ends with catch (on line 23). // 13: URLConnection conn = theUrl. If there's nothing there. 07:43:28 PM MDT <br><br>June 15. // note 3: import java.out. It's part of Java's error notification system.out. 09:43:28 PM EDT <br><br>June 15.print((char)ch ). 17: while( ch != -1 ) { // 18: System. 01:43:28 UTC <br><br>June 15. 9: System. . 22: 4: public class UrlExample{ 5: public static void main( String[] args ){ 6: if( args. 15: InputStream in = namely the URL. For example. This object behaves the same way when reading from the connection as it would when reading from a local file. The connection is represented by an URLConnection object that gets created on Line 13. Talk about an accurate alarm clock.UrlExample http://tycho.length < 1 ){ // 7: System.out.toString() ). The program expects to see an array of strings that have at least one item.println( 8: "Program expects a URL on the command line"). to connect to. // 16: int ch = in.getInputStream().pb.connect(). such as not being able to contact the URL. 2: import java.exit(1). Line 15: The InputStream object represents the way Java reads streams of Line 12: This statement creates an object that knows how to create a connection to another computer using a URL. 25: } 26: } 27: } The following describes some of the significant parts of the code: When executing a program such as this. 06:43:28 PM PDT </h3> Done Isn't that cool? That's all it takes to grab information from a computer on the Internet. where the end is indicated by getting a -1 from the InputStream. 08:43:28 PM CDT <br><br>June

The basic building block of e-mail is a protocol known as SMTP (Simple Mail Transfer Protocol). As with other").com. if you're sending a message to mike@mycompany. . Your local SMTP server has two main responsibilities: accepting messages from you and other local users and routing them across the Internet and receiving messages from other SMTP servers on the Internet that are intended for local users. Designing a simple email program You don't need to worry about the mechanics of SMTP to create e-mail programs.they don't appear in the actual program. Once your message reaches your local SMTP server. 7: $smtp->datasend("To: recipient@yourcompany. the computer uses SMTP to connect to your local mail server. It then connects to that server using SMTP and passes along the message. If you're at home. You'll often want to use your programs to send e-mail directly to recipients based upon the program's output. line numbers have been added for clarity of explanation -.myhost. your local mail server would check a database to determine that the mail server for mycompany. Your program just needs to know how to compose an e-mail message and get it into the hands of your local SMTP server. If you're at work. A few situations in which you'd want to do this include: In this section. 8: $smtp->datasend("\n"). 10: $smtp->dataend(). When you send an e-mail from your computer. 1: use Net::SMTP. Email basics Sending a receipt to a customer after the program processes an order Sending a notification to system administrators when a program detects a disk that's almost full Delivering alerts to programmers when programs result in an error   Before you begin creating a program. it's likely that the mail server is run by your ISP (Internet Service Provider). 3: $smtp->mail("sender@mycompany. 6: $smtp->datasend ("From: sender@mycompany. that server looks at the recipient's e-mail address and performs a lookup to identify the appropriate SMTP server that should receive the message for delivery to the\n"). For example. 5: $smtp->data().mycompany.\n"). SMTP is responsible for routing messages around the Internet and ensuring they reach their intended destinations. Once you deliver it to your local"). 2: $smtp = Net::SMTP->new('smtp.Sending email from your programs   Now that you've learned how to retrieve data from the Internet within your program. 4: $smtp->to("recipient@yourcompany. it's that server's responsibility to ensure that it's correctly routed across the Internet into the e-mail box of the intended'). let's turn our attention to sending electronic mail in the next section. you'll take a look at how you can send e-mail from within your programs using a simple example in the Perl programming is a system known as smtp. it's likely that this mail server is run by your employer and resides on your corporate network. 9: $smtp->datasend("My program likes to send e-mail!\n"). you need to understand a little background about how e-mail works. 11: $smtp->quit. let's take a look at a simple program written in the Perl programming language that connects to a local SMTP server and creates a short message for delivery to a remote

The smtp->dataend() command indicates you're done creating the body of the message.The following describes some of the significant parts of the code: Interacting with mobile devices   You've now learned how to design a program that interacts with the network: both for retrieving data and sending e-mail. They specify the sender (in the mail command) and the recipient (in the to command) of the message.myhost. You repeat the from and to addresses here so they appear in the e-mail at the receiver's end. You'll need to replace "smtp. you'll learn how programs work with a special class of devices: mobile phones and PDAs (personal digital assistants). but they also introduce complexities for Web" with the name of the SMTP server used by your organization or ISP. Although mapping programs are available across the Internet using any type of Web browser.   . and the smtp->quit() command closes the connection to the mail server. Lines 5-11: The remainder of the program creates the body of the message. Consider the application displayed on a common smartphone shown in Figure 7-2. There's a new trend you should consider when designing network connectivity and Web-based programs: the proliferation of mobile computing devices such as PDAs and smartphones. The major challenge you need to overcome is simple screen real estate. These devices bring extraordinary power to the hands of travelling users. Lines 3 and 4: These two lines create the "envelope" for the e-mail message. Line 1: This command loads the Net::SMTP library that enables Perl to send e-mail. In the final section of this lesson. Line 2: This line opens a connection to your mail server. a programmer must use special programming techniques to render a similar amount of data on the small screen of a mobile device.

Maybe you'd like to write an application that checks a store's Web site for the availability of this holiday season's hard-to-find toy and notifies you when it's . you could develop an application in which a user clicks a button on his or her smartphone.Figure 7-2: A map application on a smartphone. It also gave you a short overview of how you can design programs to work on mobile devices. Another major difference that's just beginning to emerge on the mobile computing front is locationawareness. Before you move on. Assignment #11 Moving on This lesson covered how programs interact in a networked environment. complete the assignment and quiz for this lesson. In Lesson 8. and you'll get an overview of tools and techniques used by professional programmers. For example. Think about an application of interest to you that uses network capabilities. You'll learn about applications you can use to develop mobile device applications in Lesson 8. Perhaps you'd like to write a program that retrieves stock quotes from the Internet and sends you an e-mail alert when a certain stock reaches a certain price target. compares those to a database of coffee shops (or whatever is desired). and sends the user directions from his or her current location to the nearest coffee shop. the phone transmits GPS coordinates to a Web server. you'll get some practical advice on programming from a seasoned programmer. Newer smartphones and PDAs have built-in GPS (global positioning system) sensors and applications might make use of that data.

True LAN False WAN Question 2: Which type of network connects computers spread across a large university campus with locations in several places throughout a city? C) D) C) D) C) D) C) D) Question 3: What's TCP an acronym for? Intranet Internet Question 4: Which protocol sends e-mail across the Internet? Question 5: What's the major challenge to developers of Web applications for mobile devices? Bandwidth Data entry Portability Screen size HTTP FTP SSH SMTP True Communication Protocol Truly Confusing Protocol Transmission Control Protocol Transparent Connection Protocol Understanding programmers and the digital revolution Discovering your future as a professional programmer This final lesson begins with a short but important discussion of where programming might fit into your future. I have gotten pretty good at programming in (C. but the most interesting jobs require competence in additional fields.Quiz #7   A) B)   A) B)   A) B)   A) B)   A) B)   in stock. Question 1: True or False: The Internet is a network of networks. Computing is such an integral part of society that there are many people who program daily   Get an introduction to the world of professional programming. Many programming discussion group postings read something similar to: "Okay. Whatever the application. whatever).   . sketch out the details and write a program in the language of your choice. composed of a hierarchy of smaller networks including specialized backbone networks that move data between smaller networks. starting with a survey of various kinds of digital systems. C#. Java. now where can I get a job?" Knowing only a single programming language might get you a position as a trainee. Python. C++. The class ends with a discussion of the environments and tools you work with as a professional programmer.

You might see this field referred to as embedded computing because the computers are an inseparable part of these gadgets. In some cases. which you have looked at several times in this course. Being able to write a program to assist them in their real work is simply part of their total professional competence.are running programs written by somebody. If you like to program games but don't relish working on the monsters that PC games have become. is for you. and telephone capabilities. and related technologies.but don't consider themselves programmers. but you can't go wrong by studying the C family of languages back in Lesson 4. With all that activity. desktop utility. Adobe Flash. A wide variety of languages are used in scientific computing. an astonishingly large market for cell phone games has arisen in the last few years. tools. Internet services . Programming robots can involve anything from electrical engineering to artificial intelligence. Programming really small things It might not be obvious. which combines both programming and artistic sensibility. You don't need to spend big bucks to get started. Highly portable computing power Computer users are having a convergence of computing and communicating power in the form of portable devices that combines Web browser. are widely used in modern electronics. maybe this field is for you. Robots Robotics is currently another field that might interest you. Scientific computing Practically all scientific fields involve moderate to heavy use of computer power -. robot programming can even get you involved in space exploration. especially in the commercial world. Dynamic web pages and the arts Human interface design. Because of general standardization on Java as a widely supported language on such devices. Java applets can create a dynamic effect on a Web page that simply can't be approached by any other technology. just to name a few. If poorly designed Web pages and ghastly interfaces make your artist's soul cringe. text messaging. is all about perception and emotional impact. The hot technologies in this area are JavaScript. The smallest computers. and manufacturers that use microcontrollers.from thermostats to microwave ovens -. naturally there are highly specialized Web sites where you can learn more about jobs. but all of those digital gadgets in your life -. either. earthquake prediction. e-mail handler. On the serious side. You should regard programming ability in some language or languages as just part of your total package. maybe Web design. Lego makes a low-priced but highly capable robot kit that can be programmed in Java. called microcontrollers. and climate modeling. Computing power is essential to genome sequencing.from computerized lab instruments using embedded computing power to the largest supercomputer complexes doing climate modeling.

During the initial explosion of interest in Java. as well as a full-featured string class. No matter which language you're using. The STL contains a wide assortment of mathematical and functional tools. Object-oriented language libraries One big advantage of OOP is the ease with which you can make use of library functionality. You might find that someone has already written the exact subroutines or class libraries that you need. or you can extend a library class. Sun created so many different APIs that most people became confused as to what is a standard part of the language and what is an add-on library. or shopping carts. As a refresher. Accessing libraries and reusing code   Those are certainly some exciting technologies. why not you? As more commerce and information retrieval moves to the Web. more job opportunities are created. As discussed in earlier lessons. by extending Frame. have to be programmed by somebody -. auctions. In Lesson 4. which extends the parent class as needed. You have basically two ways to make use of an OOP library: you can create instances of a library class. inheritance is using one class as a starting point for another class. You'll often see the word "interface" used when talking about language libraries. Frame is an example of a library class designed to be easily extended. The next section covers how reusable code makes your life easier.All Web sites that use dynamically created Web pages. such as portals. and the good news is you don't need to create all of the code to implement them. For example. A graphical user interface represents the boundary between the user and a computer. the starting version of Liberty BASIC is limited in certain areas and doesn't permit the creation of stand-alone programs. you inherit the variables and functions that make it easy to create a new user interface. A common nomenclature for referring to libraries is API (Application Programming Interface). J2ME (Java 2 Micro Edition): A set of libraries suitable for people working with small systems. . you created a new Java class MyFrame by extending a library class named Frame. Sun finally got wise and created three editions of Java: Many other commercial language vendors follow a similar approach and have editions at various levels. Having these tools available for use can save incredible amounts of time. and a programming interface represents the boundary between your program and library functions. such as cell phones J2SE (Java 2 Standard Edition): A set of libraries suitable for most programming J2EE (Java 2 Enterprise Edition): A set of libraries suitable for those working on the largest scale of commercial Web sites and other applications The C++ language has seen the STL (Standard Template Library) become a standard part of the language. there are a tremendous number of resources available to make your job   Standard libraries Many modern languages come with extensive libraries of their own.

you know that two good examples are SourceForge and the Apache Software Foundation.NET family of languages. For instance. Google Code is another popular and ever-growing Web site with about 50. Tool running capability: The editor enables you to define jobs that can be run without leaving the editing environment. Examining programming tools and writing utilities   There are many Web sites where these projects are coordinated. For example. which one did you use and did you like it? Post a message to the board and share your experience with your . Have you had enough exposure to programming that you've used an IDE? If so. You'll learn more about IDEs shortly. which is why they're called open source. Raymond. home of the widely used Apache Web server and many other projects in many languages. Now that you've learned about reusing code.000 open source projects. Open source libraries The Internet has made it possible for people from all over the world to involve themselves in creating programs and programming libraries in astonishing profusion. Label. The products of these projects are usually freely available to anybody who wants to use them.CENTER )).Other libraries are designed with self-contained functionality that you can plug into programs where needed. In the C family of languages. Probably the most famous open source product is Linux. Many vendors of programming languages have extensive online reference material for their programming libraries. let's turn our attention to the next section. If you completed the assignment for Lesson 4. but first consider editing programs with a separate application. where we look at integrated development environments. programmers can use their favorite editing environment with a separate compiler and debugger. such as Liberty BASIC. the programming language comes complete with a built-in editor and the capability to save program files. or use an IDE (Integrated Development Environment). Every programmer creates a programming environment to suit the needs of particular projects. Online information Having a connection to the Internet is similar to having a nearly infinite library at your command. but you'll find that search engines are a big help. Here you can find both general articles on programming techniques as well as specific details on the libraries available for the . editors designed specifically for programming can provide some helpful functionality and are less expensive than a full-featured IDE. continuing with the MyFrame example. Project organization: The editor enables you to define a project file that remembers all of the files you're using as well as your custom settings. one starting point to navigate Microsoft's huge supply of technical information is the MSDN Library site. and makes it easy for beginners to learn. SourceForge now hosts over 180. the following line created an instance of the Label class. Some features to look for include: Have you used an IDE? Syntax color-coding: The editor is aware of key words used in the programming language you are writing and can color code the various elements.000 open source projects. customized with the text message and positioning instruction. add( new Label("Hello World". and get help from the programming community. test. Opening the project file puts you back at the point you were working on when you closed the project. In some cases. you have to act as your own librarian to locate the resources you need. Although it's certainly possible to edit a Web page (including JavaScript) with the Notepad application that comes with Windows. Typical jobs might include compiling the program or copying files. Its development is discussed in the thought-provoking "The Cathedral and the Bazaar" essay by Eric S. try. Unfortunately.

Nonetheless. C++. You might be surprised at the number of mistakes TIDY can find in Web pages. The main disadvantage is that it's rather expensive. Versions for embedded devices such as cell phones are especially popular. If you're programming applications for desktop use. you can then see the instructions the IDE has written that causes those graphical components to be drawn. C/C++. C++. using IDEs in this way has become common in recent years. Many programming tasks. powerful IDEs include: Many of the modern IDEs provide tools for generating graphics instructions. This is a useful feature when you're trying to figure out which statement draws an incorrect line in a complicated graphic. it's easy to try the program on your . when dealing with the HTML markup language. and are ideal for students. PHP. for example. Some modern IDEs provide tools to help write this code for you. particularly if you want to use the IDE's tools to generate more instructions after you've modified what it's created. Specialized programming utilities There are many other utilities that the programmer can call on for assistance in accomplishing various chores. These environments usually. and many more programming languages.NET family. and Java programming on all desktop environments. and so on) or writing C code to interface with a SQL database. As you can imagine. C#. you usually have to customize the code later. Put it all together with IDEs classmates. Some of the most popular examples of modern. Special personal versions of these tools that run on both Windows and Linux are available for free downloading. or has an error in a long mathematical function or method. are complex but tend to be written in standard ways. It includes wizard-driven screens that walk you through program setup step by step. You can use a "lite" version called Visual Studio Express. for example. you can run a program line by line. combine a customized text editor for entering code and tools for debugging. For example. Borland IDEs: Borland makes IDEs for Java. as the graphics used in most programs have grown more complex and programming projects try to get more accomplished in less time. such as programming graphical interfaces (windows. Visual Studio: This widely respected IDE from Microsoft provides the same working environment for C#. buttons. Free or low-cost student versions of some products are available. In most IDEs. or let you program in freeform. Many IDEs do more than just lets you work with Java. toolbars. you can use HTML-Kit to create and edit Web pages and HTML TIDY to check for correct usage of markup tags. and a number of other Microsoft languages in the . The debugger can display the value of variables as they change when statements are executed. and Delphi programming plus many design tools. at a minimum. After you've drawn your graphical components. WebSphere Studio: The latest IDE for Java and JavaScript programming from IBM emphasizes development of Web services. you also lose some control over how you can rearrange the program later. IDEs are very popular tools for writing programs. For example. JavaScript. it's often easier to have an IDE write hundreds of lines of code to draw an application's window than it is to do it yourself. walking through the instructions as they're processed (called tracing or stepping through a program). you can actually drag and drop graphical components from a palette onto a drawing board that represents what becomes the finished user interface.You might find a programmer's editor called UltraEdit32 to be exceptionally useful because it has all of these features. When you have the IDE write a lot of the code. CodeWarrior: This line of IDEs from Metrowerks is for C. NetBeans IDE: This power-packed tool by NetBeans. Visual Basic. which is available as a free download. The catch is that to have your interface actually do anything other than trivial tasks (such as just being displayed).

Figure 8-1: The wireless toolkit user interface building the games project. however. It provides a desktop interface. as shown in Figure 8-1. you can load it into the cell phone emulator and run it. All of the emulated cell phone buttons work as expected to control the program. things get tricky because a cell phone doesn't offer much debugging help. that lets you control a development project that targets a cell phone environment. as shown in Figure 8-2. A good example is the Sun Java Wireless Toolkit. Enlarge image When the program has compiled without error. Figure 8-2: The games project running in an emulator. if you're programming for an environment such as a cell phone. The emulator is the savior of countless hours of cell phone developer time.development system. . A cell phone emulator creates a virtual cell phone on your desktop where your program can be run under more control.

Fortunately. Since the mid-1990s. 5.that's a great place to start learning more. Some great places to explore are:   Programming is a field that continues to grow. and much more IEEE: A membership-based. See how to use the Sun Java Wireless Toolkit. To get a feel for a cell phone development emulator: 1. podcasts. and services Dr. 3. Select a demo in the phone interface (if more than one is listed). The best way to learn is by pursuing something that interests you. changes in hardware and software. complete the assignment and quiz for this lesson to reinforce important lesson topics. Open the software. New computer hardware and faster processors make things possible that wouldn't have even been considered a few years before. online communities. Before you move on. select File > Open Project. groups. such as downloadable source code. It's safe to say that the field of computer programming will keep growing. and inevitably. or mathematical programming in C -. (1. click Run on the toolbar. and then click the large Select button in the middle of the phone interface. and new technologies are appearing every day. highly regarded technology standards institute that provides a source of technical and professional information. and the growth of the Internet all make programming a challenging field. there's far more to cover. computers. 2. Run through the demo to see how it works. newsletters.Learning more   Now that you've learned about some emerging programming technologies. and then select a demonstration project from the Open Project dialog box. Internet-related technologies have been developing at a furious pace. resources. 4. conferences and other events. New languages. an extensive publications list. Today's most popular languages are being enhanced and improved at a rapid rate. articles. you now have a feeling for what programming is and the areas in which you want to learn more. that's especially true. and more Assignment #12 You've been introduced to a lot of material in this course. In a field as diverse as programming. the final section of this course looks at opportunities to expand your horizons even further. the Internet also provides Web sites and user groups you can use to keep up with all the current technology. Dobbs' Journal: Offers a portal of resources geared toward programmers. Quiz #8   . If something you saw particularly interested you -. hardware. Hopefully. blogs. Moving on Programmers Resource : Provides a developers' forum in addition to articles and code snippets for many programming languages ACM (Association for Computing Machinery): Offers links to SIGs (Special Interest Groups).interactive Web pages with JavaScript.2 MB) Being a programmer means you never stop learning. and operating systems to learn. When the demo loads. Download and install the Java J2ME Wireless Toolkit. A cell phone emulator window appears. meaning there'll be more languages.

) C) D) Visual Studio ASP CodeWarrior WebSphere True False Erase feature Syntax color-coding Project organization Tool-running capability Mainframe computers Mobile computers Enterprise servers Medium-sized desktop computers API ASP CGI STL © 2003 .Question 1: Which of the following are ways that programmers reuse code? (Check all that apply.) A) B)   A) B)   A) B)     A) B) A) B)   C) D) C) D) C) D) Question 2: If you're using the J2ME libraries. Inc. such as Notepad? (Check all that apply.2010 Powered. what kind of hardware is your program probably going to run on? Question 3: What kinds of functionality of an ordinary programming editor aren't found in a simple text editor.) Question 4: True or False: Adobe Flash is a type of dynamic Web page technology. Question 5: Which of the following are examples of IDEs? (Check all that apply. .

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer: Get 4 months of Scribd and The New York Times for just $1.87 per week!

Master Your Semester with a Special Offer from Scribd & The New York Times