15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

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

66<br />

“Curly Bracket” Languages<br />

True portability with Java<br />

Although C and C++ programs are supposed to be portable — you can copy<br />

and run them on other computers — they’re not really. Sometimes, you have<br />

to make minor changes to get a C/C++ program to run on another computer,<br />

but more often, you have to make major changes.<br />

So that’s why Sun Microsystems created the Java <strong>programming</strong> language.<br />

Like C++, Java is also based on the C language, but includes several features<br />

to make Java programs safer than C or C++ programs. Specifically, Java isolates<br />

the programmer from directly accessing the computer’s memory. This<br />

reduces the power of Java somewhat, but translates into safer programs that<br />

(hopefully) won’t crash as often as C/C++ programs do.<br />

Perhaps the most important feature of Java is its portability. Rather than<br />

attempt to compile a Java program into machine language <strong>for</strong> different types<br />

of processors, Java compiles Java programs into an intermediate file <strong>for</strong>mat<br />

called bytecode or pseudocode (also called p-code).<br />

To run a Java program that’s compiled into bytecode, you need a free program,<br />

or a Java virtual machine (VM). As long as a computer has a Java VM,<br />

it can run a Java compiled bytecode program.<br />

Like most promises made by computer scientists, Java programs aren’t always<br />

portable. It’s perfectly possible to write a Java program correctly, compile it to<br />

bytecode <strong>for</strong>mat, and make the program run perfectly on a specific computer<br />

and operating system. But copy that same bytecode program to another computer,<br />

and suddenly, the Java program doesn’t run correctly. The problem can<br />

occur when the Java VM, on the other computer, has errors in it. So although<br />

Java programs are more portable than C/C++ programs, they still aren’t 100<br />

percent portable.<br />

Besides creating full-fledged programs, like word processors or spreadsheets,<br />

Java can also create smaller programs, or applets, which can be used<br />

to create interactive Web pages.<br />

So if you’re looking <strong>for</strong> a <strong>programming</strong> language that makes <strong>programming</strong><br />

safer and more portable, consider Java. Java programmers are in demand<br />

almost as much as C/C++ programmers, and the similarities between Java<br />

and C/C++ make it relatively easy to understand after you know C. (Or you<br />

can study Java first and then study C/C++ later.)<br />

Safer <strong>programming</strong> with C#<br />

Microsoft took one look at C/C++ and decided they could create an improved<br />

language, which they dubbed C# (pronounced C-sharp).

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

Saved successfully!

Ooh no, something went wrong!