Programming language
A programming language is a type of written language that tells computers what to do. Examples are: Python, Ruby, Java, JavaScript, C, C++, and C#. Programming languages are used to write computer programs and computer software. A programming language is like a set of commands that tell the computer how to do things.
Usually, the programming language uses real words for some of the commands (e.g. "if... then... else...", "and", "or"), so that the language is easier for a human to understand. Like any normal language, many programming languages use punctuation. To make a program, a programmer writes commands in their chosen programming language and saves the commands to a text file. This text file is called source code. Some programming languages, such as Python and JavaScript, can be read by the computer right away. If not, the source code has to be compiled, which means that the computer translates the source code into another language (such as assembly language[1][2] or machine language) that a computer can read, but which is much harder for a person to read.
Computer programs must be written very carefully. If a programmer makes mistakes, then the program might then stop working, which is called "crashing". When a program has a problem because of how the code was written, this is called a "bug". A very small mistake can cause very serious bugs.
Types of programming languages very most
[change | change source]There are many types of programming languages. Most programming languages do not follow one type alone, so it is difficult to assign a type for each language. The examples of each type are given in each section below because they are the best well-known examples of that type.
High-level vs. low-level
[change | change source]High-level programming languages require less knowledge about the hardware compared to low-level programming languages. This is because high-level programming languages abstract away the hardware the program is running on. Many high-level languages require an interpreter to run the source code on the hardware in real time. On the other hand, low-level languages usually convert the whole source code to machine code before running, because the source code is so close to the hardware that it is easy to do so.
Declarative vs. Imperative programming
[change | change source]Declarative programming languages[3] describe a "problem" but they usually do not say how the problem should be solved. The problem description uses logic, and "solving" the problem often looks like automatically proving a system of logical axioms. Examples for such programming languages are Prolog,[4][5][6][7] XSLT, LISP[8] and SQL.[9]
Imperative programming languages describe a system of state changes. At the start, the program is in a certain state, and the computer is given steps to follow, in order to perform an action. Following the steps causes the program to "change state".
In general, declarative programming languages are safer and shorter. Imperative programming languages are more common, because they are easier to use.
Functional vs. Procedural
[change | change source]Functional programming[10][11] looks at programming like a function in mathematics. The program receives input, together with some information, and uses this information to create output. It will not have a state in between, and it will also not change things that are not related to the computation.
Procedural programs specify or describe sets of steps or state changes.
Stack-based
[change | change source]Stack-based languages look at some of the program's memory like a stack of cards. There are very few things that can be done with a stack. A data item can be put on the top of the stack. This operation is generally called "push". A data item can be removed from the top of the stack. This is called a "pop". You can look at the item at the top of the stack without removing it. This is called a "peek".
If a program is written as "push 5; push 3; add; pop;" it will put 5 on the top of the stack, put 3 on top of the 5, add the top two values (3 + 5 = 8), replace the 3 and 5 with the 8, and print the top (8). Examples for programming languages that are stack-based are the languages Postscript[12] and Forth.[13]
Object-oriented
[change | change source]Object-oriented programming languages[14][15][16] place data and functions that change data into a single unit. This unit is called an "object". Objects can interact with each other and change another object's data. This is usually called encapsulation or information hiding.[17] Most modern programming languages are object-oriented, or at least allow this style of programming. Examples of this are Java,[18][19] Python,[20] Ruby, C++,[21][22][23] C#[24][25] and other C languages.
Flow-oriented
[change | change source]Flow-oriented programming sees programming as connecting different components. These components send messages back and forth. A single component can be part of different "programs", without the need to be changed internally.
Scientific computing
[change | change source]Some of the languages above can be used for scientific computing. For example, C++[26] and Python[27][28] are also used in this way. On the other hand, there are some languages that has scientific computing as their main purpose. The following are some examples:
- MATLAB[29][30][31] - made by MathWorks
- GNU Octave, Scilab - open source versions of MATLAB
- R (programming language)[32][33][34][35][36][37] - widely used in the field of statistics
- Wolfram Mathematica[38][39][40][41] - made by Wolfram Research
Document creation
[change | change source]LaTeX[42][43] and SATySFi are programming languages which helps document creation.
Rules most
[change | change source]Every programming language has rules about what it can and can not do. These include:
- Correct numbers (types of numbers, and how large or small the numbers can be)
- Words (reserved words, case-sensitivity)
- Limits on what the programming language can do
Most languages have official standards that define the rules of how to write the source code. Some programming languages have two or more standards. This can happen when a new standard replaces an old one. For example, the Perl 5[44] standard replaced Perl 4 in 1993. It can happen because two people made two standards at the same time. For example, there are several standards for APL.
Object-Oriented Programming
[change | change source]Object-Oriented Programming (sometimes shortened to OOP) is a form of programming where all parts of the program are objects. Objects are pieces of memory with the same structure that can be used again and again. A bank account, bitmap, or hero from a video game could all be objects within a program. Objects are made up of properties (pieces of information the object stores) and methods which are things the object can do. A Dog object might have properties like height and hairColor. Its methods might include bark() and wagTail().
All objects are created from templates called classes. You can think of a class as a mold from which objects are made. The class defines all the properties and methods that its objects will have. Objects created from a class are called instances of the class. A class can extend another class, which means that it takes all the properties and methods of the class but can add its own.
Here is an example of what a class might look like in a programming language:
class Dog extends Mammal { // These are properties: String breed = "Collie" String type = "Herding Dog" // These are methods void wagTail() { //Do some wagging } void bark() { // Do the barking here } }
Notice that the Dog class extends the Mammal class, so all dogs will have the properties of a mammal, like hairLength, and methods, like eat() or sleep().
Object-oriented programming is used in many of today's most popular programming languages, such as Java, C#, Objective-C,[45] C++, Python, Ruby,[46] Javascript,[47] and ActionScript.[48][49]
Examples
[change | change source]Example of Visual Basic
[change | change source]Here is a simple program written in Visual Basic (a language made by Microsoft[50][51][52]):
Dim Input
Input = InputBox("How old are you?? - Code")
If Not IsNumeric(Input) Then
MsgBox & Input & "That's not a number!"
ElseIf Input < 0 Then
MsgBox "You cannot be less than zero years old!"
ElseIf Input > 100 Then
MsgBox "That's old!"
Else
MsgBox "You're " & Input & " years old."
End If
This program asks the user his or her age and responds based on what the user typed. If the user typed something that is not a number, the program says so. If the user typed a number less than zero, the program says so. If the user says he or she is older than 100 years old, the program says "That's old!". If the user typed a correct age, the program says back to the user how old he or she is.
Example of Python
[change | change source]Here is a program that does the same thing as the program above, but in Python:
try:
age = int(raw_input("How old are you? "))
except ValueError:
print ("That's not a number!")
else:
if age < 0:
print ("You cannot be less than zero years old!")
elif age > 100:
print ("That's old!")
else:
print("You're %s years old." % age)
Example of C#
[change | change source]The same thing as the program above, but in C#:
using System;
public class Hello
{
public static void Main()
{
Console.WriteLine("What is your age?");
int age;
if (!int.TryParse(Console.ReadLine(), out age))
Console.WriteLine("That's not a number!");
else if (age < 0)
Console.WriteLine("You cannot be less than zero years old!");
else if (age > 100)
Console.WriteLine("That's old!");
else
Console.WriteLine("You're {0} years old.", age);
}
}
Example of Haskell
[change | change source]The same thing again, but in Haskell:
import Text.Read
main = do
putStrLn "What is your age?"
input <- fmap readMaybe getLine
putStrLn $ case input of
Just age | age < 0 -> "You cannot be less than zero years old!"
| age > 100 -> "That's old!"
| otherwise -> "You're " ++ show age ++ " years old."
Nothing -> "That's not a number!"
References
[change | change source]- ↑ Mazidi, M. A., & Mazidi, J. G. (1997). 80x86 IBM PC and Compatible Computers: Assembly Language, Design, and Interfacing; Volume I and II. Prentice Hall PTR.
- ↑ Irvine, K. R. (2003). Assembly language for Intel-based computers. Prentice Hall.
- ↑ Lloyd, J. W. (1994, September). Practical Advtanages of Declarative Programming. In GULP-PRODE (1) (pp. 18-30).
- ↑ Clocksin, W. F., & Mellish, C. S. (2012). Programming in Prolog: Using the ISO standard. Springer Science & Business Media.
- ↑ Sterling, L., & Shapiro, E. Y. (1994). The art of Prolog: advanced programming techniques. MIT Press.
- ↑ Nilsson, U., & Małuszyński, J. (1990). Logic, programming and Prolog. Chichester: Wiley.
- ↑ Apt, K. R. (1997). From logic programming to Prolog (Vol. 362). London: Prentice Hall.
- ↑ Bobrow, D. G. (1964). The programming language LISP: Its operation and applications. E. C. Berkeley (Ed.). MIT Press.
- ↑ Hursch, C. J., Hursch, J. L., & Hursch, C. J. (1988). SQL, the Structured Query Language. Tab Books.
- ↑ Bird, R. S., & Wadler, P. L. (1988). Functional programming. Prentice Hall.
- ↑ Wadler, P. (1992, February). The essence of functional programming. In Proceedings of the 19th ACM SIGPLAN-SIGACT symposium on Principles of programming languages (pp. 1-14).
- ↑ Geschke, C. M. (1986). PostScript®-A Page Description Language. it-Information Technology, 28(6), 370-376.
- ↑ Kail, P. (1985). Forth programming language. SOFTWARE WORLD., 16(3), 2-5.
- ↑ Budd, T. (2008). Introduction to object-oriented programming. Pearson Education India.
- ↑ Wegner, P. (1990). Concepts and paradigms of object-oriented programming. ACM Sigplan Oops Messenger, 1(1), 7-87.
- ↑ Stefik, M., & Bobrow, D. G. (1985). Object-oriented programming: Themes and variations. AI magazine, 6(4).
- ↑ Petitcolas, F. A., Anderson, R. J., & Kuhn, M. G. (1999). Information hiding-a survey. Proceedings of the IEEE, 87(7), 1062-1078.
- ↑ Campione, M., & Walrath, K. (1998). The Java Tutorial: Object-Oriented Programming for the Internet (Book/CD). Addison-Wesley Longman Publishing Co., Inc..
- ↑ Wu, C. T. (2006). An Introduction to object-oriented programming with Java TM. McGraw-Hill Incorporated.
- ↑ Lutz, M. (2013). Learning python: Powerful object-oriented programming. "O'Reilly Media, Inc.".
- ↑ Lafore, R. (1997). Object-oriented programming in C++. Pearson Education.
- ↑ Pohl, I. (1993). Object-oriented programming using C++. Addison-Wesley.
- ↑ Lee, R. C., & Tepfenhart, W. M. (1997). UML and C++: a practical guide to object-oriented development. New Jersey: Prentice Hall.
- ↑ Farrell, J. (2013). Microsoft Visual C# 2012: An Introduction to Object-Oriented Programming. Cengage Learning.
- ↑ Clark, D., & Sanders, J. (2011). Beginning C# object-oriented programming. Apress.
- ↑ Aberth, O. (1998). Precise numerical methods using C++. Academic Press.
- ↑ Johansson, R. (2018). Numerical Python: Scientific Computing and Data Science Applications with Numpy, SciPy and Matplotlib. Apress.
- ↑ Bressert, E. (2012). SciPy and NumPy: an overview for developers. "O'Reilly Media, Inc.".
- ↑ Quarteroni, A., Saleri, F., & Gervasio, P. (2006). Scientific computing with MATLAB and Octave. Berlin: Springer.
- ↑ Gander, W., & Hrebicek, J. (Eds.). (2011). Solving problems in scientific computing using Maple and Matlab®. Springer Science & Business Media.
- ↑ Barnes, B., & Fulford, G. R. (2011). Mathematical modelling with case studies: a differential equations approach using Maple and MATLAB. Chapman and Hall/CRC.
- ↑ Crawley, M. J. (2012). The R book. John Wiley & Sons.
- ↑ Dalgaard, P. (2008). Introductory statistics with R. Springer.
- ↑ Maronna, R. A., Martin, R. D., & Yohai, V. J. (2019). Robust statistics: theory and methods (with R). John Wiley & Sons.
- ↑ Ugarte, M. D., Militino, A. F., & Arnholt, A. T. (2008). Probability and Statistics with R. CRC Press.
- ↑ Bruce, P., Bruce, A., & Gedeck, P. (2020). Practical Statistics for Data Scientists: 50+ Essential Concepts Using R and Python. O'Reilly Media.
- ↑ Kruschke, J. (2014). Doing Bayesian data analysis: A tutorial with R, JAGS, and Stan. Academic Press.
- ↑ Maeder, R. E. (1991). Programming in mathematica. Addison-Wesley Longman Publishing Co., Inc..
- ↑ Stephen Wolfram. (1999). The MATHEMATICA® book, version 4. Cambridge University Press.
- ↑ Shaw, W. T., & Tigg, J. (1993). Applied Mathematica: getting started, getting it done. Addison-Wesley Longman Publishing Co., Inc..
- ↑ Marasco, A., & Romano, A. (2001). Scientific Computing with Mathematica: Mathematical Problems for Ordinary Differential Equations; with a CD-ROM. Springer Science & Business Media.
- ↑ Datta, D. (2017). LaTeX in 24 Hours: A Practical Guide for Scientific Writing. Springer.
- ↑ Van Dongen, M. R. (2012). LATEX and Friends. Springer Science & Business Media.
- ↑ Till, D., & Till, D. (1996). Teach yourself Perl 5 in 21 days. Sams Pub..
- ↑ Kochan, S. G. (2011). Programming in objective-C. Addison-Wesley Professional.
- ↑ Flanagan, D., & Matsumoto, Y. (2008). The Ruby Programming Language: Everything You Need to Know. "O'Reilly Media, Inc.".
- ↑ Haverbeke, M. (2014). Eloquent JavaScript: A modern introduction to programming. No Starch Press.
- ↑ Sanders, W., & Cumaranatunge, C. (2007). ActionScript 3.0 Design Patterns: Object Oriented Programming Techniques. "O'Reilly Media, Inc.".
- ↑ Tapper, J., Talbot, J., & Haffner, R. (2004). Object-oriented Programming with ActionScript 2.0. New Riders.
- ↑ Pattison, T., & Box, D. (2000). Programming distributed applications with COM+ and Microsoft Visual Basic 6.0. Microsoft Press.
- ↑ Schneider, D. I. (2013). An introduction to programming using visual basic 2012. Prentice Hall Press.
- ↑ Stephens, R. (2010). Visual basic graphics programming (Vol. 81). John Wiley & Sons.