Friday, 12 September 2008

Beginning Programming By Greg Perry - Part 3

Couple of Days back i started reading Beginning Programming Book By Greg Perry.

I wanted to share few important quotations i found from the next 5 chapters(9-10-11-12-13) from the book.

1) Subroutines improve a program’s accuracy as follows:
A program is easier to write and maintain when you group routine code together in subroutines. The subroutines help you focus on specific parts of the program that you need to change or fix if bugs exist in the code. When your whole program is comprised of small routines, in subroutines, you make your code more modular and you help ensure that code in one part of the program doesn’t affect code in another part of the program.

2) Java, developed by Sun Microsystems in the mid-1990s, changed the way that Web sites operate. Java is a programming language with language features similar to C++. Fortunately, Java also contains many language features that are similar to Liberty BASIC, such as the for loop, the if statement, and the while loop.

3) Sun and Java

In 1995, when Sun Microsystems created Java, Java was designed to be a better C++ than C++. Both C++ and Java are efficient programming languages that you can use to write almost any computer application. Java’s initial emphasis, though, was online Internet programming.Java was a small and efficient language with safeguards in place to add security to online programs that C++ simply couldn’t handle.Today, Java works in many environments; some programmers develop large, complex applications in Java, and those applications have nothing to do with the Internet. By making Java a lot like the C++ language already in use, Sun Microsystems helped to ensure a rapid acceptance and usage within the programming world.

4) You can write two kinds of Java programs:

• Java applets are small programs that travel with Web page code and execute on the Web user’s computer.
• Java applications are complete standalone programs that don’t require a Web browser to execute.

5) Whereas most language compilers, such as Liberty BASIC and Visual C++, turn programs into machine-dependent executable programs, Java development tools don’t go quite that far. All Java compilers compile your Java code into a special machine-independent module.The Java compiler first compiles the code into an in-between stage called bytecode. Your Java-enabled Web browsing software then translates this compiled bytecode into instructions
that your computer executes.

No computer can really read bytecode, but each computer’s Java-enabled browser can. In other words, given a Java applet’s bytecode, a PC can run the applet using a Web browser, and a UNIX-based minicomputer can run that very same bytecode by using its own Java-enabled browser such as Netscape. Each Web browser actually interprets the
machine-dependent bytecode and then translates that bytecode into machine-specific instructions that a particular computer can understand.

6) We’ll use the Java language to produce bytecode for a virtual machine, not a specific machine, because the bytecode is machine independent. A virtual machine is not a particular kind of computer but is an imaginary computer. Each computer must have a virtual machine interpreter to run Java code. The interpreter translates the compiled bytecode into specific instructions for that computer. Therefore, the Java compiler doesn’t have to compile for any one computer,just bytecode for an imaginary computer called the virtual machine. The bytecode is sent to the Web page that is to contain the applet, and when the end user requests that Web page, the user’s Web browser reads the bytecode and automatically interprets the bytecode into code readable by the user’s computer. The user is unaware that all this took place; the Web page is displayed and the executing applet is seen along with the rest of the Web page’s content.

7) Security Issues

Security should always be your concern when writing online applications. In practice, Java-enabled applets can be prone to security problems if the proper precautions aren’t in place. After all, when you visit a Java-enabled Web page, you aren’t always sure if an applet is running or what exactly an applet is trying to do to your computer’s disk or memory.

Fortunately, Sun Microsystems developed Java to be a network-based programming language.Therefore, security is inherent in the language, both for the developer and for the Internet user. What follows are some of the security-related protections built into the Java language:

• A Java applet is not allowed to venture into the end user’s memory areas where it doesn’t belong.
• A Java applet cannot create, read, rename, copy, or write files on the end user’s file system.
• A Java applet cannot connect to additional machines on the end user’s network.
• A Java applet cannot call system routines on the end user’s system

About the Author

Greg Perry has personally taught thousands of people how to program in the classroom and lectures, as well as impacted the computer world through the sale of more than two million computer books sold internationally.

He has been a programmer and trainer for the past 20 years. He received an undergraduate degree in computer science, followed by a master's degree in corporate finance. After working as a supervisor of financial systems for a Fortune 500 company, he turned to teaching at the college level, where he remained until he began to write full-time and lecture at programming conferences.

Some of his other book titles include Sams Teach Yourself Visual Basic 6 in 21 Days, C by Example, and several books in the 24 Hours series, including Sams Teach Yourself PCs in 24 Hours, Sams Teach Yourself Office in 24 Hours, and Sams Teach Yourself Windows Millennium in 24 Hours. He has also written articles for several magazines, including PC World and Data Training. He is fluent in several computer languages and speaks a little Italian as well.

No comments: