I. Introduction to Computer Science
A. What is computer science?
Is it just science or is it just computers? Do you imagine a dark room with a glowing monitor and a person tearing her hair out? In fact, computer science is actually an art and skill. With practice and time, computer science can be easily picked up to aid you in life. Computer science or CS is everywhere.
It doesn’t matter if the first grader next door is able to program. Anyone can learn how to program! Even if you have zero knowledge in programming, after completing our specially designed “crash course,” you will pick up computer science easily and realize programming is simply a tool. Learning how to use the tool effectively is a part of computer science.
For example, given a hammer and nails, you can construct a simple doll house. Everyone can use a hammer but using it effectively is different. Is it possible given the knowledge to build a doll house and you are able to build a dog house? Sure! How about a real full-sized house? You have the concepts... just apply them! Computer science is a problem solving course. If you love problem solving, this is the topic just for you. If you are a little shy, keep reading on! You will find out computer science is actually a fun and rewarding topic to explore.
All you really need is a computer to program! It does not have to have several gigabytes of RAM and a thousand kilobytes. Any computer equipped with the right software will do because of the standards (ANSI) has brought us. In fact, you could write programs with a simple text editor! Most of the programming kits you see today are basically a fancier version of a word processor.
What do you really need?
a text editor
the software needed to turn the text you write into a program
a good attitude and an open mind!
Some of today’s programming languages:
BASIC - the simplest and easiest language to learn
C/C++ - still very popular and widely used, this is a structured language. Will C and C++ fade out? Not likely but it will start morphing into other forms to fit applications.
Java - a simpler form of C++ and object oriented, it is beginning to become popular and several colleges have started using Java instead of C++ for their CS courses.
We will use Java in this website. C/C++ and Java are very similar and if you master one language, you can pick up the other quite rapidly.
True story: I was able to help people debug Java programs even without learning it! All I did was apply the fundamentals of computer science. Trying to learn Java... however... is a different story.
What will you get out of this?
We hope that you will have picked up the ability to program and possibly, begin to venture into different areas of programming... Games, applications, anything is possible! Keep and open mind, be ready to push your limits of your knowledge, and you will be surprised at what you can accomplish.
B. History of Java
In 1990, James Gosling and Mike Sheridan began work on Sun Microsystems’ next project: The Green Project. Sun’s goal was to produce a robust programming language that would be completely object-oriented (more on that in Chapter 3: Object-Oriented Programming), based partly on C++. In 1991, James Gosling finished work on the original compiler (transforms the code a programmer writes into a program). The other team members were working on a runtime interpreter (takes the file the compiler creates and runs it...equivalent to executing any program) for Oak.
In 1994, the Green Project team felt the project was getting nowhere commercially. Thus, the project was held on pause, on the verge of being completely cancelled. The project was however saved when the “web” picked up popularity that year. The team realized that they had a platform-independent language on their hands (one that would work on all computers), one with potential. In 1995, the HotJava browser was released to the public. The HotJava browser was a pathway through which Sun Microsystems could display the power of Java.
In 1996, Sun formed the JavaSoft unit (http://www.javasoft.com), which was dedicated to the development of Java. JavaSoft released JDK 1.0 that same year. JDK stands for Java Development Kit. It provides necessary tools for programmers using Java. Soon, many companies bought licenses from JavaSoft to port the Java Virtual Machine (JVM; the JVM changes the file generated by the compiler into the machine’s code) to enable Java Programming on their operating systems. Thus, a programmer needs to know only Java, and using the same code he used to make a program in Windows, he can create the same program for UNIX, MacOS, or whatever operating system he wished to use.
C. Programming in Java
To program in Java, you need to download JDK 1.3.1 (version 1.4 is available one beta). This file is available for download at http://www.javasoft.com. Once you download the file, follow the instructions at the above website to install Java on your computer. If you are using Windows, you can use a program such as NotePad to write the code (save the file with a .java extension). Then, you need to enter DOS Prompt (i.e., shell mode). Navigate to the directory where your file is saved. Then, type “javac filename.java” to compile the code into a file with the .class extension. To execute the program, Type “java filenamehere.” Note that when executing the program, you should not include the extension in the end. Just make sure you are in the directory where you compiled the .java file. That’s it! That’s all you need to do to execute your Java programs.