PROGRAMMING
Programming is the process of taking an algorithm and encoding it into a notation, a programming language, so that it can be executed by a computer. Although many programming languages and many different types of computers exist, the important first step is the need to have the solution. Without an algorithm there can be no program.
Algorithms describe the solution to a problem in terms of the data needed to represent the problem instance and the set of steps necessary to produce the intended result. Programming languages must provide a notational way to represent both the process and the data. To this end, languages provide control constructs and data types.
Control constructs allow algorithmic steps to be represented in a convenient yet unambiguous way. At a minimum, algorithms require constructs that perform sequential processing, selection for decision-making, and iteration for repetitive control. As long as the language provides these basic statements, it can be used for algorithm representation.
All data items in the computer are represented as strings of binary digits. In order to give these strings meaning, we need to have data types. Data types provide an interpretation for this binary data so that we can think about the data in terms that make sense with respect to the problem being solved. These low-level, built-in data types (sometimes called the primitive data types) provide the building blocks for algorithm development.
For example, most programming languages provide a data type for integers. Strings of binary digits in the computer’s memory can be interpreted as integers and given the typical meanings that we commonly associate with integers (e.g. 23, 654, and -19). In addition, a data type also provides a description of the operations that the data items can participate in. With integers, operations such as addition, subtraction, and multiplication are common. We have come to expect that numeric types of data can participate in these arithmetic operations.
The difficulty that often arises for us is the fact that problems and their solutions are very complex. These simple, language-provided constructs and data types, although certainly sufficient to represent complex solutions, are typically at a disadvantage as we work through the problem-solving process. We need ways to control this complexity and assist with the creation of solutions.
source: http://interactivepython.org/courselib/static/pythonds/Introduction/WhatIsProgramming.html
DEFINITION OF PROGRAMMING LANGUAGE
-it is a set of formal instruction used for produce various kinds of output and used for create programs that implement specific logorithm
- there are thousend of different programming language have been created mainly in the computer field and many more still created every year.
TYPES OF PROGRAMMING LANGGUAGE
APL
Named after the book A Programming Language (Iverson, Kenneth E., 1962), APL is an array programming language. It can work simultaneously on multiple arrays of data. It is interpretive, interactive and a functional programming language.
AutoIt
It is a freeware automation language for Microsoft Windows. It’s main intent is to create automation scripts that can be used for the execution of certain repetitive tasks on Windows.
BASIC
Developed by John George Kemeny and Thomas Eugene Kurtz at Dartmouth in 1964, it is an acronym for Beginner’s All-purpose Symbolic Instruction Code. It was designed with the intent of giving the non-science people an access to computers.
Eiffel
It is an object-oriented programming language that is ISO-standardized and used to develop extensible and reusable software. It is a development platform for many industries such as finance, aerospace and video gaming.
Forth
It is a structured imperative programming language, which bases its implementation on stacks. It supports an interactive execution of commands as well as the compilation of sequences of commands.
C++
It consists of a combination of high-level and low-level language features and is hence considered as a middle-level programming language. Bjarne Stroustrup of Bell Labs developed C++ as an extension of the C language. Originally known as ‘C with Classes’, it came to be known as C++ from 1983. It is a multi-paradigm language that supports procedural programming, generic programming, object-oriented programming, and data abstraction.
programming paradigm
-way in which computer language look at the problem to be solved.
procedural=a way of approach in problem solving based on module of function,.
object oriented=a way of approach in problem solving based on the concept of an object that combine both data and the function into a single units.
logic=a way of approach in problem solvingh based on idea of answering question through search for solution from a knowledge base.
language translator
-any program that is not written in machine language looks at the problem to be solved.
assembler=translate program written in assemblyb language in to machine language.
compiler=translate the enitre source program into machine language before executing it.
interpreter=translate and execute one instructiom at a time into machine language.
-way in which computer language look at the problem to be solved.
procedural=a way of approach in problem solving based on module of function,.
object oriented=a way of approach in problem solving based on the concept of an object that combine both data and the function into a single units.
logic=a way of approach in problem solvingh based on idea of answering question through search for solution from a knowledge base.
language translator
-any program that is not written in machine language looks at the problem to be solved.
assembler=translate program written in assemblyb language in to machine language.
compiler=translate the enitre source program into machine language before executing it.
interpreter=translate and execute one instructiom at a time into machine language.
JAVA
It is a general-purpose computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. Compiled Java code can run on all platforms that support Java without the need for recompilation. It is a very popular language of the modern times.
SOURCE;
https://medium.com/web-development-zone/a-complete-list-of-computer-programming-languages-1d8bc5a891f
JAVA PROGRAMMING LANGUAGE
Step 1: Make a File
1. Navigate to your My Documents folder in a file explorer.
2. In that window right-click hover over new and click on "Text Document" this will create a file name "New Text Document" with the name highlighted, so you can rename it.
3. Click away from the document it because we will rename it later.
2. In that window right-click hover over new and click on "Text Document" this will create a file name "New Text Document" with the name highlighted, so you can rename it.
3. Click away from the document it because we will rename it later.
Step 2: Write the Framework of Your Progam
1. Open your newly created text document.
2. Inside your file type "class MyFirstProgram {"
Do not forget the curly brace because this tells the computer where the meat of your program is.
3. Press enter twice to create to new lines and then type "}" this tells the computer that everything that makes up this program has been entered.
4. At this point your program should look like the attached picture for this step.
Understanding The Code:
At this point we can actually generate the program. The only problem is it won't do anything. In fact if you tried to run the program an error message will appear that says "Error: Main method not found in class MyFirstProgram, please define method as: " and then shows a specific line of code. We will be writing in that line of code in the next step since it is an important part of the program to understand.
We are using a specific programming language called Java, and as with most languages Java has a very specific way of organizing and expressing itself this organization is called the code's syntax and must be followed or the program cannot be generated by the compiler. What we did was set up the basic framework of this program.
Every Java program is composed of Classes and Methods. Classes are more commonly known as Objects and provide us with a way to organize our code. Classes store information and instructions, our program is going to be a single class with a single instruction, or method. An easy way to think of it is that classes are an entire keyboard where the methods are the individual keys on the keyboard. Right now our program is just a empty class (A keyboard with no keys). We know this, and more importantly the compiler knows this because the first word we typed says "class".
After reading the word class Java's syntax dictates that we need to state the programs name (a label on the key), in this instance we will name our program "MyFirstProgram". We will name it this because it is descriptive of what our program is: our first one! An important thing to note is that most programming languages will not allow spaces the names of things. This is because the use of empty space withing code helps the compiler understand what is going on.
The compiler, reading in the name of our class, expect us to show some way of denoting what part of our file constitutes the class itself to do this we use curly braces ("{" "}") to denote where it starts ("{") and where it ends ("}"). Since our file does do this when we pass it through the compiler, the compiler will produce a program, but since our class has no methods to use (keys to press) an error will be produced.
2. Inside your file type "class MyFirstProgram {"
Do not forget the curly brace because this tells the computer where the meat of your program is.
3. Press enter twice to create to new lines and then type "}" this tells the computer that everything that makes up this program has been entered.
4. At this point your program should look like the attached picture for this step.
Understanding The Code:
At this point we can actually generate the program. The only problem is it won't do anything. In fact if you tried to run the program an error message will appear that says "Error: Main method not found in class MyFirstProgram, please define method as: " and then shows a specific line of code. We will be writing in that line of code in the next step since it is an important part of the program to understand.
We are using a specific programming language called Java, and as with most languages Java has a very specific way of organizing and expressing itself this organization is called the code's syntax and must be followed or the program cannot be generated by the compiler. What we did was set up the basic framework of this program.
Every Java program is composed of Classes and Methods. Classes are more commonly known as Objects and provide us with a way to organize our code. Classes store information and instructions, our program is going to be a single class with a single instruction, or method. An easy way to think of it is that classes are an entire keyboard where the methods are the individual keys on the keyboard. Right now our program is just a empty class (A keyboard with no keys). We know this, and more importantly the compiler knows this because the first word we typed says "class".
After reading the word class Java's syntax dictates that we need to state the programs name (a label on the key), in this instance we will name our program "MyFirstProgram". We will name it this because it is descriptive of what our program is: our first one! An important thing to note is that most programming languages will not allow spaces the names of things. This is because the use of empty space withing code helps the compiler understand what is going on.
The compiler, reading in the name of our class, expect us to show some way of denoting what part of our file constitutes the class itself to do this we use curly braces ("{" "}") to denote where it starts ("{") and where it ends ("}"). Since our file does do this when we pass it through the compiler, the compiler will produce a program, but since our class has no methods to use (keys to press) an error will be produced.
Step 3: Setup the "main" Method
1. On the second line of your program press Tab and type "public static void main(String[] args) {".
2. Press enter twice, then tab again and type "}".
3. Your program should now look like the picture.
Understanding the Code:
What we just wrote is the "main" instruction, or method, of our program. The "main" method of a class is quite literally the main instruction of a program. When a class contains a "main" method it allows a program to be executed. This is because when a java program is run it the first thing a computer looks for is a method named "main" and follows out all the instructions within that method. Since there are no instructions within main right now, running the program will cause nothing to happen.
In front of the main method's name are three words. These words describe specific attributes of the method. The first word describes who can use the method, and since this is the main method it must be available for everyone to use so it says "public."
The next word is optional and describes when the method can be used. The specific details of word requires a deeper knowledge to fully understand so it the author will leave it up to the reader to investigate thing more on their own to gain this understanding.
The last word described what sort of object the method produces. In this case we do not want to produce anything so we state "void" so the computer knows not to be expecting anything at the end of the instruction.
Next to main we have a left parenthesis some code and a left parenthesis followed by the curly braces. The curly braces again describe where this part of the program starts and ends. The code inside the parentheses denotes the inputs of the method or what the method expects to receive from whomever using it. In this case it expects to receive an array (denoted by "[]") of Strings to run, or, in other words, it expects to receive a list of words. They are usable by the method under the name "args" which is shorthand for "arguments". When the main method is called by a computer it puts all the words that are after it into that list and hands them over to the program.
We don't need any arguments for this program so don't worry about it, but still keep the input argument in there because your computer will get confused if it isn't.
2. Press enter twice, then tab again and type "}".
3. Your program should now look like the picture.
Understanding the Code:
What we just wrote is the "main" instruction, or method, of our program. The "main" method of a class is quite literally the main instruction of a program. When a class contains a "main" method it allows a program to be executed. This is because when a java program is run it the first thing a computer looks for is a method named "main" and follows out all the instructions within that method. Since there are no instructions within main right now, running the program will cause nothing to happen.
In front of the main method's name are three words. These words describe specific attributes of the method. The first word describes who can use the method, and since this is the main method it must be available for everyone to use so it says "public."
The next word is optional and describes when the method can be used. The specific details of word requires a deeper knowledge to fully understand so it the author will leave it up to the reader to investigate thing more on their own to gain this understanding.
The last word described what sort of object the method produces. In this case we do not want to produce anything so we state "void" so the computer knows not to be expecting anything at the end of the instruction.
Next to main we have a left parenthesis some code and a left parenthesis followed by the curly braces. The curly braces again describe where this part of the program starts and ends. The code inside the parentheses denotes the inputs of the method or what the method expects to receive from whomever using it. In this case it expects to receive an array (denoted by "[]") of Strings to run, or, in other words, it expects to receive a list of words. They are usable by the method under the name "args" which is shorthand for "arguments". When the main method is called by a computer it puts all the words that are after it into that list and hands them over to the program.
We don't need any arguments for this program so don't worry about it, but still keep the input argument in there because your computer will get confused if it isn't.
Step 4: Write Your Instruction
1. On the empty line in the middle of the program press tab twice and type "System.out.println("Hello, World!");"
Understanding the Code:
This instruction will cause the sentence "Hello, World!" to appear where we will be executing the program from.
This part of any program is where we're telling the computer to do something. The heart of programming lies in being able to do this. Write this line of code and you've essentially done it. "System.out" is the first part of this instruction we need to understand. System is a class readily available at any time anywhere. Appending ".out" to System allows gives us access to a class contained in System that gives us access to the computer's output. Calling the "println" method from out will write (or print) the text passed to the method to the available output. In our case this will be the command line.
Understanding the Code:
This instruction will cause the sentence "Hello, World!" to appear where we will be executing the program from.
This part of any program is where we're telling the computer to do something. The heart of programming lies in being able to do this. Write this line of code and you've essentially done it. "System.out" is the first part of this instruction we need to understand. System is a class readily available at any time anywhere. Appending ".out" to System allows gives us access to a class contained in System that gives us access to the computer's output. Calling the "println" method from out will write (or print) the text passed to the method to the available output. In our case this will be the command line.
Step 5: Save Your Program
1. In your text editor click on "File" then select "Save As..."
2. In the dialogue window that appears next there is a drop down selector labeled with "Save as type:" it should currently have "Text Documents (*.txt)" click on the selector and select "All Files".
3. By "File name:" change the name of the file to "MyFirstProgram.java".
4. Click Save.
2. In the dialogue window that appears next there is a drop down selector labeled with "Save as type:" it should currently have "Text Documents (*.txt)" click on the selector and select "All Files".
3. By "File name:" change the name of the file to "MyFirstProgram.java".
4. Click Save.
Step 6: Install the Java JDK
1. Go to http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html click on the agree radio button.
2. Click on the download for Windows x86 .
3. Once the download is finished open the file and follow the setup. All the default options will work.
This step installs the Java JDK, or Java Developer's Kit, which gives us access to the Java compiler and the command that allows us to run Java programs.
2. Click on the download for Windows x86 .
3. Once the download is finished open the file and follow the setup. All the default options will work.
This step installs the Java JDK, or Java Developer's Kit, which gives us access to the Java compiler and the command that allows us to run Java programs.
Step 7: Copy the Path to the Java Tools
1. Open up your window file explorer and navigate to your computer's main directory (where you find your CDs and USB sticks).
2. Double click on "Local Disk" which typical has a "(C:)" following it.
3. Double click "Program Files"
4. Highlight any fold and press the "j" key.
5. This should take you to you a folder named "Java" open it.
If you cannot find the "Java" folder go back to "Local Disk" and open "Program Files (x86)". If you still can't find it repeat Step 6.
6. You will be presented with two folder options open the folder starting with "jdk" in lowercase.
7. Open the folder titles "bin".
8. Click on the file path, but not on any part of the path.
9. This should highlight path like in the picture.
10. Press "crtl" and "c" at the same time this will copy that path (the path tells the computer where that directory is).
2. Double click on "Local Disk" which typical has a "(C:)" following it.
3. Double click "Program Files"
4. Highlight any fold and press the "j" key.
5. This should take you to you a folder named "Java" open it.
If you cannot find the "Java" folder go back to "Local Disk" and open "Program Files (x86)". If you still can't find it repeat Step 6.
6. You will be presented with two folder options open the folder starting with "jdk" in lowercase.
7. Open the folder titles "bin".
8. Click on the file path, but not on any part of the path.
9. This should highlight path like in the picture.
10. Press "crtl" and "c" at the same time this will copy that path (the path tells the computer where that directory is).
1. Navigate to your My Documents directory in you file explorer.
2. Create a new folder (right click hover over "New" and click on "Folder")
3. Name it "MyFirstProgramFolder" (as soon as the folder is made type out the name).
4. Drag your "MyFirstProgram" file to the folder. Do not enter the folder.
5. While holding shift right click on "MyFirstProgramFolder" and select "Open command window here...". Like in the picture.
6. The command prompt should now be open like in the second picture.
2. Create a new folder (right click hover over "New" and click on "Folder")
3. Name it "MyFirstProgramFolder" (as soon as the folder is made type out the name).
4. Drag your "MyFirstProgram" file to the folder. Do not enter the folder.
5. While holding shift right click on "MyFirstProgramFolder" and select "Open command window here...". Like in the picture.
6. The command prompt should now be open like in the second picture.
Step 9: Compile the Program
1. Once in the command prompt type ' " '
2. Right click in the window and select "Paste".
3. The path you copied from step 7 should appear. If not, just repeat step 7 without closing the command prompt and try again.
4. With the path pasted type ' " '
5. Type "\javac MyFirstProgram.java".
6. The command prompt cursor should go to the next line and look similar to the picture.
What's Going On
You just compiled your program. This means that your computer now has access to a file with instructions it can understand.
2. Right click in the window and select "Paste".
3. The path you copied from step 7 should appear. If not, just repeat step 7 without closing the command prompt and try again.
4. With the path pasted type ' " '
5. Type "\javac MyFirstProgram.java".
6. The command prompt cursor should go to the next line and look similar to the picture.
What's Going On
You just compiled your program. This means that your computer now has access to a file with instructions it can understand.
1. Without closing the command prompt press on the up arrow key.
2. This should bring up the compile command you just executed.
3. Press delete just the Java tools directory remains (with the quotes).
4. Type "\java MyFirstProgram" to run your program.
The result this time should be similar to the previous step, but this time a line of text should be printed out saying "Hello, world!" Just like the picture.
For an extra challenge change the message that is printed by editing your MyFirstProgram.java file and repeating the last two steps to run your modified program.
2. This should bring up the compile command you just executed.
3. Press delete just the Java tools directory remains (with the quotes).
4. Type "\java MyFirstProgram" to run your program.
The result this time should be similar to the previous step, but this time a line of text should be printed out saying "Hello, world!" Just like the picture.
For an extra challenge change the message that is printed by editing your MyFirstProgram.java file and repeating the last two steps to run your modified program.
SOURCE : https://www.instructables.com/id/How-to-Make-Your-First-Computer-Program/
Comments
Post a Comment