Notes On JAVA 10.2005.2: "Why Java?"
Notes On JAVA 10.2005.2: "Why Java?"
For most of these notes I am indebted to: Cadenhead, R (1999): Sams Teach Yourself JavaTM 2 in 24 Hours (Indianapolis: Sams Publishing). The key to learning how to program is to start with the right language. The programming language you choose often depends on the tasks you want the computer to accomplish. Each language has things it is well suited for and things that are difficult, or perhaps impossible, to do with the language. Many people used some form of the BASIC language when they are learning how to program because BASIC is good for learning how to write programs. It was invented in the 1960s to be easy for students and beginners to learn (the B in BASIC stands for Beginners Beginners All Symbolic Instruction Code), but its easy to fall into some sloppy programming habits with the language. Those habits can make it more difficult to write complex programs later. Microsoft Visual Basic (VB) combines the ease of BASIC with some powerful features to aid in the design of Windows based software. VB has been used to write thousands of sophisticated programs for commercial, business, and personal use. VBScript, a form of VB, is for small programs than run in conjunction with web pages. However, VB programs can be slower than programs written in other languages, such as Borland C++. This difference is especially noticeable in programs that use a lot of graphics games, screen savers, and the like. Because of that, game programmers and other multimedia developers dont use VB to create graphical programs such as Age of Empires or Quake. Java was developed by Sun Microsystems and the first version was released in 1995. Developer James Gosling was unhappy with the way C++ was working on a project he was doing (writing software for small appliances), so he created a new processor-independent language that did the job better. Although Java may be more difficult to learn than a language such as VB, it is a lot easier than many others. It is a good starting point for several reasons. One of the biggest advantages of learning Java is that you can use it on the World Wide Web. Java programs are used to create animated graphics, present text in new ways, play games, and help in other interactive efforts. Another important advantage is that Java requires an organised approach for programs to work. The language is very particular about the way programs must be written, and it balks if programmers do not follow all of its rules. It is most important to remember that Java is case sensitive and that System is not equal to SYSTEM or system. You might have heard that Java is an acronym that stands for Just Another Vague Acronym. You might also have heard that it was named for the developers love of coffee, especially the percolating product from a shop near Suns offices. Actually, the story behind Javas naming contains no secret messages or declarations of liquid love. Instead Java was chosen because it sounds cool, beating suggestions such as WebRunner, Silk, Ruby, and others. Its development name was Oak, after the tree outside Goslings office window. Its a matter of contentious debate whether Java is superior to other programming languages. The amount of attention paid to the language today shows that it has a large number of adherents and more than 1000 books have been published about it since its introduction. Regardless of whether Java is the best language, it definitely is a great language to learn today. There are numerous resources for Java developers on the Web, Java job openings are increasing, and the language has become a major part of the Internets past, present and future. The newest version of the language, Java 2 (released 1998), includes numerous enhancements that make Java into a worthy competitor to more established languages such as Microsofts Visual C++ and Borland Delphi. Learning Java (or any other programming language) makes it much easier to learn subsequent languages. Many languages are similar to each other, so you wont be starting from scratch when you start learning a new one. For instance, C++ programmers find it fairly easy to learn Java (and vice versa!) because Java borrows a lot of its structure and ideas from C++ (The elements hardest to learn and hardest to use correctly have not been taken over!). C++ (Cplus-plus) in turn was an enhancement of the C programming language, developed by Bjarne Stroustrop and others at Bell Laboratories.
Page 2 of 3
Q A
Is C++ harder to learn than Java? Its a matter of personal opinion, but Java does seem more approachable for beginners than C++. The previous language and its predecessor, C, are widely regarded as programmers languages, meaning that they were designed for the needs of experienced programmers. There are a lot of features in C and C++ that make them faster and more powerful during program creation, but these features often come at the expense of understandability. Java takes a more simplified approach to programming than C++ and is probably a better place to start. (Rogers Cadenhead)
Java is unusual in that it requires both a compiler and an interpreter (See Notes 10.2005.1). The text-based program (also known as source code) is saved with the .java extension. The compiler then creates a class (saved as .class) in bytecode. The bytecode is platform independent, i.e. it can be run on any operating system Windows, Mac, DOS, UNIX, Linux or Solaris. However, the specific operating system has to be equipped with a Java interpreter (the JVM Java Virtual Machine) that then interprets the class and runs it on the specific machine. Remember: Computers can only follow machine language instructions (in binary code). As each type of machine has its own machine language, a program compiled for Windows will not work on a Mac (and vice versa). Java, being a non-proprietary programming language, has many editors by different companies. Often they apply different colours to different types of words (usually reserved words), assist you with the spelling of these special words and may even help with the layout of your program. Most of these special editors come with a compiler. You might want to download the Java Development Kit (JDK) from Sun Microsystems web page. Dont be shocked, however, if you find that you have to run the Java programs from the command line (DOS prompt C:\>) if you use JDK. Or you can use the Ready to program with Java technology by Holt Software provided by your school. Ready is combined with a compiler (IBMs Jikes compiler can be changed) and offers error detection and correction. Ready is a true IDE (Integrated Development Environment) as it lets you compile and run the program without leaving the editor. It also offers templates (known as Boilerplates) for specific program types i.e. Applications and Applets. Although extensive, the help program does not provide examples, however. Another (expensive) option is SunSoft Java WorkShop, an advanced programming tool from Javas developers, Sun Microsystems, as well as Borlands JBuilder or Symantecs Visual Caf. There have been three major releases of the Java language: (Seasons relative to the USA) Fall 1995: Java 1.0 A version best suited for use on the WWW that showed potential for expansion into other types of programming. Spring 1997: Java 1.1 An upgrade to the language that included numerous improvements to the way user interfaces are created and handled. Fall 1998: Java 2 More than three times as large as Java 1.0, with enhancements that make the language a worthy competitor to other general-purpose programming languages. Ready uses Java 1.1, whereas you can obtain the JDK 1.4 to support Java 2. The latest version is J2DK 1.5. Running JDK from the DOS prompt: (assuming there is a folder/directory in C:\ called JavaWork where all the Java programs are being saved to, and that a program called program1.java has been created and saved) C:\JAVAWORK>javac program1.java C:\JAVAWORK>java program1 // "javac" = Java compile // no message = compiled successfully // runs the program
Page 3 of 3
Some useful web sites: http://java.sun.com http://java.sun.com/products/JDK http://www.javaworld.com http://www.javaworld.com/javaworld/books http://javaboutique.internet.com http://javaboutique.internet.com/tutorials http://www.javaranch.com (A good site for relative beginners) http://www.developer.com http://www.prefect.com/java24 http://oss.software.ibm.com/developerworks/opensource/jikes http://www.freewarejava.com http://www.cs.uct.ac.za/ http://jars.com [jars = Java Applet Rating System] http://sunsite.unc.edu/javafaq/javafaq.html [for Frequently Asked Questions] http://www.intelligence.com/java
_________________________________________________ mb