Latest Post


Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991. The target of Java is to write a program once and then run this program on multiple operating systems. The first publicly available version of Java (Java 1.0) was released in 1995. Sun Microsystems was acquired by the Oracle Corporation in 2010. Oracle has now the steermanship for Java. In 2006 Sun started to make Java available under the GNU General Public License (GPL). Oracle continues this project called OpenJDK.
Over time new enhanced versions of Java have been released. The current version of Java is Java 1.8 which is also known as Java 8.
Java is defined by a specification and consists of a programming language, a compiler, core libraries and a runtime (Java virtual machine) The Java runtime allows software developers to write program code in other languages than the Java programming language which still runs on the Java virtual machine. The Java platform is usually associated with the Java virtual machineand the Java core libraries.
The Java language was designed with the following properties:
  • Platform independent: Java programs use the Java virtual machine as abstraction and do not access the operating system directly. This makes Java programs highly portable. A Java program (which is standard-compliant and follows certain rules) can run unmodified on all supported platforms, e.g., Windows or Linux.
  • Object-orientated programming language: Except the primitive data types, all elements in Java are objects.
  • Strongly-typed programming language: Java is strongly-typed, e.g., the types of the used variables must be pre-defined and conversion to other objects is relatively strict, e.g., must be done in most cases by the programmer.
  • Interpreted and compiled language: Java source code is transferred into the bytecode format which does not depend on the target platform. These bytecode instructions will be interpreted by the Java Virtual machine (JVM). The JVM contains a so called Hotspot-Compiler which translates performance critical bytecode instructions into native code instructions.
  • Automatic memory management: Java manages the memory allocation and de-allocation for creating new objects. The program does not have direct access to the memory. The so-called garbage collector automatically deletes objects to which no active pointer exists.
  • The Java syntax is similar to C++. Java is case-sensitive, e.g., variables called myValue andmyvalue are treated as different variables.

    1.2. Hello world Java program

    // a small Java program
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello World");
        }
    }

    1.3. Java virtual machine

    The Java virtual machine (JVM) is a software implementation of a computer that executes programs like a real machine.
    The Java virtual machine is written specifically for a specific operating system, e.g., for Linux a special implementation is required as well as for Windows.
  • Java programs are compiled by the Java compiler into bytecode. The Java virtual machine interprets this bytecode and executes the Java program.

    1.4. Java Runtime Environment vs. Java Development Kit

    A Java distribution typically comes in two flavors, the Java Runtime Environment (JRE) and theJava Development Kit (JDK).
    The JRE consists of the JVM and the Java class libraries. Those contain the necessary functionality to start Java programs.
  • 1.5. Development Process with Java

    Java source files are written as plain text documents. The programmer typically writes Java source code in an Integrated Development Environment (IDE) for programming. An IDE supports the programmer in the task of writing code, e.g., it provides auto-formating of the source code, highlighting of the important keywords, etc.
    At some point the programmer (or the IDE) calls the Java compiler ( javac ). The Java compiler creates the bytecode instructions. These instructions are stored in .class files and can be executed by the Java Virtual Machine.



What Is Computer Programming?


Introduction 
Today, most people don't need to know how a computer works.  Most people can simply turn on a computer or a mobile phone and point at some little graphical object on the display, click a button or swipe a finger or two, and the computer does something.  An example would be to get weather information from the net and display it.  How to interact with a computer program is all the average person needs to know.
But, since you are going to learn how to write computer programs, you need to know a little bit about how a computer works.  Your job will be to instruct the computer to do things.
    proc-ess / Noun:
    A series of actions or steps taken to achieve an end. 

    pro-ce-dure / Noun:
    A series of actions conducted in a certain order.

    al-go-rithm / Noun:
    An ordered set of steps to solve a problem.
   
Basically, writing software (computer programs) involves describing processesprocedures; it involves the authoring of algorithms.  Computer programming involves developing lists of instructions - thesource code representation of software  The stuff that these instructions manipulate are different types of objects, e.g., numbers, words, images, sounds, etc...  Creating a computer program can be like composing music, like designing a house, like creating lots of stuff.  It has been argued that in its current state it is an art, not engineering. 
An important reason to consider learning about how to program a computer is that the concepts underlying this will be valuable to you, regardless of whether or not you go on to make a career out of it.  One thing that you will learn quickly is that a computer is very dumb, but obedient.  It does exactly what you tell it to do, which is not necessarily what you wanted.  Programming will help you learn the importance of clarity of expression.
 A deep understanding of programming, in particular the
 notions of successive decomposition as a mode of analysis
 and debugging of trial solutions, results in significant
 educational benefits in many domains of discourse,
 including those unrelated to computers and information
 technology per se.
     (Seymour Papert, in "Mindstorms")
   
 It has often been said that a person does not really
 understand something until he teaches it to someone else.
 Actually a person does not really understand something
 until after teaching it to a computer, i.e., express it
 as an algorithm."

     (Donald Knuth, in "American Mathematical Monthly," 81)
   
 Computers have proven immensely effective as aids to clear
 thinking.  Muddled and half-baked ideas have sometimes
 survived for centuries because luminaries have deluded
 themselves as much as their followers or because lesser
 lights, fearing ridicule, couldn't summon up the nerve to
 admit that they didn't know what the Master was talking
 about. A test as near foolproof as one could get of whether
 you understand something as well as you think is to express
 it as a computer program and then see if the program does
 what it is supposed to. Computers are not sycophants and
 won't make enthusiastic noises to ensure their promotion
 or camouflage what they don't know.  What you get is what
 you said.
    (James P. Hogan in "Mind Matters")
   
But, most of all, it can be lots of fun!  An associate once said to me "I can't believe I'm paid so well for something I love to do."
Just what do instructions a computer understands look like?  And, what kinds of objects do the instructions manipulate?  By the end of this lesson you will be able to answer these questions.  But first let's try to write a program in the English language.



PROGRAMMING USING THE ENGLISH LANGUAGE

Remember what I said in the Introduction to this lesson?
   
      Writing software, computer programs, is a lot like
      writing down the steps it takes to do something. 
         
Before we see what a computer programming language looks like, let's use the English language to describe how to do something as a series of steps.  A common exercise that really gets you thinking about what computer programming can be like is to describe a process you are familiar with.
      Describe how to make a peanut butter and jelly sandwich.
   
Rather than write my own version of this exercise, I searched the Internet for the words "computer programming sandwich" using Google.  One of the hits returned washttp://teachers.net/lessons/posts/2166.html.  At the link, Deb Sweeney (Tamaqua Area Middle School, Tamaqua, PA) described the problem as:
      Objective: Students will write specific and sequential steps
   on how to make a peanut butter and jelly sandwich.

      Procedure: Students will write a very detailed and step-by-step
   paragraph on how to make a peanut butter and jelly
   sandwich for homework. The next day, the students will
   then input (read) their instructions to the computer
   (teacher). The teacher will then "make" the programs,
   being sure to do exactly what the students said...
   
When this exercise is directed by an experienced teacher or mentor it is excellent for demonstrating how careful you need to be, how detailed you need to be, when writing a computer program.  A demonstration of this exercise is available on YouTube.
Programming in a natural language, say the full scope of the English language, seems like a very difficult task.  But, before moving on to languages we can write programs in today, I want to leave on a high note.  Click here to read about how Stephen Wolfram sees programming in a natural language happening.




ProGRAMMING USING A BLOCKS ENVIRONMENT

A little less than fifteen years ago, Mitchel Resnick and friends at MIT introduced a programming environment called Scratch.  It provides a new approach to teaching computer programming through a graphical user interface that eliminates the possibilty of making certain mistakes common in text-based programming.



Figure 1.1
Programs are constructed by connecting blocks, each representing some functionality available in the system.  Figure 1.1 shows a simple program that asks the person running it for their name and then says hello.  Color is used for categories that the blocks belong to.  Notice that the ask block and the corresponding answer block are the same shade of blue.  The shapes of the blocks determine where they can be placed to form an acceptable program.  The rounded green join block fits into a rounded hole in the violet say block.
One of Scratch's strengths is the ease with which students can construct games and animated simulations and stories.  Another strength is the Scratch website itself which provides access to many tutorials and a community of users with programs they've written.  To learn more about Scratch, visit theScratch Wiki.
Blocks-based programming is a great way to get started.  But, as the size of the programs you want to write grows or you need a feature not available in Scratch, it's time to switch to text-based programming.

PROGRAMMING LANGUAGES - HIGH-LEVEL LANGUAGES

Almost all of the computer programming these days is done with high-level programming languages.  There are lots of them and some are quite old.  COBOL, FORTRAN, and Lisp were devised in the 1950s!!!  As you will see, high-level languages make it easier to describe the pieces of the program you are creating.  They help by letting you concentrate on what you are trying to do rather than on how you represent it in a specific computer architecture.  They abstract away the specifics of the microprocessor in your computer.  And, all high-level languages come with large sets of common stuff you need to do, called libraries.
In this introduction, you will work with two computer programming languages: Logo and Java.  Logo comes from Bolt, Beranek & Newman (BBN) and Massachusetts Institute of Technology (MIT).  Seymour Papert, a scientist at MIT's Artificial Intelligence Laboratory, helped Wally Feurzeig at BBN design Logo in the 1970s.  More research of its use in educational settings exists than for any other programming language.
Java is a fairly recent programming language.  It appeared in 1995 just as the Internet was starting to get lots of attention.  Java was invented by James Gosling, working at Sun Microsystems.  It's sort-of a medium-level language.  One of the big advantages of learning Java is that there is a lot of software already written ( see: Java Class Library) which will help you write programs with elaborate graphical user interfaces that communicate over the the Internet.  You get to take advantage of software that thousands of programmers have already written.  Java is used in a variety of applications, from mobile phones to massive Internet data manipulation.  You get to work with window objects, Internet connection objects, database access objects and thousands of others.  Java is the language used to write Android apps.
So, why do these lessons start with the Logo programming language?
No other computer programming language has the depth of research as Logo, based on its use in educational settings.  It's roots are in the development of interactive learning environments.  Wally Feurzeig was researching the use of a timeshared computer to improve teaching mathematical concepts while at BBN (Bolt, Beranek, and Newman).  The question he wanted to answer was whether kids would embrace the new technology and learn using it.  With some success demonstrated using an existing programming language, Wally contracted Seymour Papert to help with Logo's design. Seymour wrote the functional specification for Logo.  Daniel Bobrow then wrote the first Logo interpreter.  Since these early days, hundreds of books and research papers have been written about its use in the classroom.  Cynthia Solomon, who started MIT's Logo Group with Dr. Papert, has put together a comprehensive website on Logo: logothings.wikispaces.com.
I like using the Logo language to teach introductory programming because it is very easy to learn.  The faster you get to write interesting computer programs the more fun you will have.  And... having fun is important!  But do not let Logo's simplicity fool you into thinking it is just a toy programming language.  Logo is a derivative of the Lisp programming language, a very powerful language still used today to tackle some of the most advanced research being performed.  Brian Harvey shows the power of Logo in his Computer Science Logo Style series of books.  Volume 3: Beyond Programming covers six college-level computer science topics with Logo.
Both Logo and Java have the same sort of stuff needed to write computer programs.  Each has the ability to manipulate objects (for example, arithmetic functions for working with numbers).  Each lets you compare objects and do a variety of things depending on the outcome of the comparison.  Most importantly, they let you define named procedures.  Named procedures are lists of built-in instructions and other named procedures.  The abstraction of naming stuff lets you write programs in a language you yourself define.  This is the stuff that programming is really all about, as you will see.
Just to give you a feel for what programming is like in a high-level language, here's a program that greets us, pretending to know English.
    print [Hello world!]
   
This is one of the simplest programs that can be written in most high-level languages.  PRINT is a command in Logo  When it is performed, it takes whatever follows it and displays it.  The "Hello world" program is famous; checkout its description on Wikipedia by clicking here.
In addition to commands, Logo has operators that output some sort of result.   Although it's a bit contrived, here is a program that displays the product of a constant number (ten) and a random number in the range of zero through fourteen.
    print product 10 (random 15)
   
In this source code, the PRINT command's input is the output of the PRODUCT operator.  PRODUCTmultiplies whatever follows it by whatever follows that and outputs the result.  So, PRODUCT needs two inputs.  RANDOM is an operator that outputs a number that is greater than or equal to zero (0) and less than the number following it.  So, PRODUCT gets its second input from the output of RANDOM.
Confusing?

Figure 1.2 shows a plumbing diagram, a graphical representation of how all these procedures fit together.




Still confusing?  Don't worry, we will get into the details of Logo operators in lesson 8.
Finally, here's a snipet of advanced Logo source code, just to give you a feeling for what it looks like.  This is a procedure definition for selecting the maximum number from a list of numbers.
                        
    to getMax :maxNum :numList 
      if empty? :numList [output :maxNum]
      if greater? (first :numList) :maxNum [output getMax (first :numList) (butfirst :numList)]
      output getMax :maxNum (butfirst :numList)
      end 
                        
   
Again, do not worry if you do not understand exactly how this procedure works.  It will be a while before you will be writing anything like this.  But, I want you to see that the words that make up the program's instructions and the instructions themselves are similar to English sentences, e.g., the first line and a half in the procedure are similar to the sentences:
    If the list of numbers to process is empty then output the maximum number processed.
    If the first number in the list is greater than the maximum number processed so far then ...
   
So, a high-level programming language is *sort-of* like English, just one step closer to what the language a computer really understands looks like.  Now let's move on to what a computer's native language looks like when it is given a symbolic representation.

PROGRAMMING LANGUAGES - ASSEMBLER LANGUAGE

One abstract layer above a computer's native language is assembler language.  In assembler language, everything is given human-friendly symbolic names.  The programmer works with operations that the microprocessor knows how to do, with each given a symbolic name.  Objects in the microprocessor and addresses of stuff in the computer's memory can also be given meaningful names.  This is actually a very big step over what a computer understands, but still tedious for writing a large program.  Assembler language instructions still have a place for little snipits of software that need to interact directly with the microprocessor and/or those that are executed many, many, many times.
Table 1.1 is an example of DEC PDP-10 assembler language, a function that returns the largest integer in a group of them, named NUMARY.  The group contains NUMNUM members.




Hopefully this gives you feel for how primitive computer instruction sets are.  I'm not going to go into the details of every instruction.  If you want to go through it in detail on your own, the PDP-10 Machine Language is detailed here.
A few points I want to expose you to are the general kinds of things being done.
  1. moving objects (numbers) into the computer's registers - very fast temporary storage,
  2. decrementing the value in a register,
  3. comparing the contents of a register to some value in the computer's memory, and
  4. transfering control to an instruction that's not in the standard sequential order - down the page.
So, as you've seen, higher-level programming languages provide similar functionality and in a form that is closer to the English language. 
But there is a problem with assembler language - it is unique for every computer architecture.  Although most deskside and notebook computers these days use the Intel architecture, this is only recently the case.  And... a variety of computer architectures are commonly used in game systems, smart phones, tablets, automobiles, appliances, etc...
Ok, we are almost at a point where I can show you machine language, the *native* language of a computer.  But for you to understand it, I'm going to have to explain how everything is represented in a computer.

INSIDE COMPUTERS - BITS AND PIECES

 Your computer successfully creates the illusion that it
 contains photographs, letters, songs, and movies. All it
 really contains is bits, lots of them, patterned in ways
 you can't see.  Your computer was designed to store just
 bits - all the files and folders and different kinds of
 data are illusions created by computer programmers.

 (Hal Abelson, Ken Ledeen, Harry Lewis, in "Blown to Bits")
   

Basically, computer instructions perform operations on groups of bits.  A bit is either on or off, like a lightbulb.  Figure 1.3_a shows an open switch and a lightbulb that is off - just like a transistor in a computer represents a bit with the value: zero.  Figure 1.3_b shows the switch in the closed position and the lightbulb is on, again just like a transistor in a computer representing a bit with the value: one.







Author Name

Contact Form

Name

Email *

Message *

Powered by Blogger.