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.

Chapter 2: Java and C#<br />

In This Chapter<br />

Understanding the C#/Java program structure<br />

Declaring variables and using operators<br />

Branching and looping statements<br />

Creating data structures and objects<br />

The Java language was meant to build upon the success of C++, but with<br />

added safety features and true cross-plat<strong>for</strong>m capabilities. Unlike C++,<br />

which gives programmers access to every part of the computer (along<br />

with the equal capability of screwing up every part of the computer), Java<br />

restricts access to the computer hardware. Although this limits Java’s flexibility,<br />

it provides greater stability and reliability of Java programs.<br />

The most appealing feature of Java is its cross-plat<strong>for</strong>m capabilities. Although<br />

porting a C++ program to run on other operating systems is possible, it’s<br />

rarely easy or painless. Theoretically, Java lets you write a program once and<br />

then run it on multiple operating systems, a feature often described as Write<br />

Once, Run Everywhere (or more whimsically, Write Once, Test Everywhere).<br />

Sun Microsystems developed Java and in response to Java’s popularity,<br />

Microsoft developed a similar language with equivalent goals — C#. Like Java,<br />

C# is meant to build upon the C++ language while providing safety features to<br />

make it harder to write programs that could crash an entire computer.<br />

To make <strong>programming</strong> easier, C# relies on the .NET framework. The idea<br />

behind .NET is to shield the programmer from the complexities of the operating<br />

system. Theoretically, the .NET framework can be ported to other<br />

operating systems, so C# could run on any operating system that can run<br />

the .NET framework. Realistically, .NET runs only on Windows, although<br />

programmers are trying to port the .NET framework <strong>for</strong> Linux too.<br />

Although C/C++ remains the most popular <strong>programming</strong> language on the<br />

planet, both Java and C# are poised as <strong>programming</strong> languages of the future.<br />

Java is popular because it’s plat<strong>for</strong>m independent, so Macintosh and Linux<br />

users can take advantage of Java. C# is most popular among Windows programmers<br />

because Microsoft has positioned C# as the future <strong>programming</strong><br />

language <strong>for</strong> Windows.

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

Saved successfully!

Ooh no, something went wrong!