What is the programming language processing
Chapter 1: Programming languages
General basics of programming
This book is licensed under a Creative Commons license.
1.1 Structure and components
Information processing tools
If you take a close look at programming languages and compare them with one another, you will quickly see that there are great similarities. Programming languages consist of similar components. Once you have understood why these components exist and what their purpose is, it is no longer a problem to learn new programming languages later. The syntax, i.e. the technical terms, differ from programming language to programming language, but the underlying concepts that matter - with a few exceptions, of course - are not.
Why do you need programming languages? What is the point and purpose of programming languages? Programming languages are needed to develop computer applications. In general, computer applications can be reduced to the lowest common denominator: Computer applications process information. It doesn't matter whether you are dealing with a browser, a word processor, a computer game or a control system for nuclear power plants, in the end it is simply about processing information.
In order to develop computer applications that can process information, appropriate tools are required. Programming languages provide these tools.
Information can only be processed meaningfully if information can also be saved. Computer applications must be able to memorize information, for example in order to be able to access previously stored information later in the course of the program. If, for example, any complicated calculations would lead to an intermediate result, which is followed by other calculations in the program before the intermediate result is used later, this intermediate result must be recorded somewhere in the program later. Without saving information, calculated results would be permanently lost. The tool that all programming languages make available to temporarily store information in a program is called variables.
While variables only allow information to be stored, programming languages must provide even more tools - because computer applications should not just store information, but process it. Each programming language therefore provides a whole range of predefined operators. These operators are more or less cryptic characters that are assigned a very specific meaning in the programming language. Variables can now be linked with these operators. Depending on the operator, this link is carried out one way or another and eventually leads to a new result. The information in the two linked variables is calculated by the operator and can then be stored in a third variable, for example.
You can do a lot with variables and operators and develop real computer applications - for example a mathematical program that adds numbers. However, if you want to write software that asks the user to enter a password and, depending on the password, allows access to protected files, variables and operators are not sufficient to write such a program. The problem is, you have a choice to make in your program. Depending on the password entered, access to the files must be permitted or not - that depends entirely on whether the user knows the correct password. Fortunately, programming languages now also offer a tool that checks conditions and executes different code as a function of these. This tool is called control structures. With control structures, conditions can be checked, for example the input of the user to see whether it matches the actual password. With control structures, branches in the code are possible - code can be skipped or even repeated. Programs no longer run stupidly from top to bottom, but branch out depending on the conditions that are checked in control structures.
Variables, operators and control structures - you don't actually need them anymore to develop computer applications. Unfortunately, software development is quite a complicated story. The larger the programs to be developed, the more difficult it becomes to write error-free code. The complexity in programs that consist of thousands of lines of code can hardly be grasped by the human programmer. Programming languages therefore offer another tool to get the complexity under control. The code that the programmer develops can be broken down into small, neat bits. So instead of writing the entire program in one fell swoop, it is broken down into small modules, which can then be easily surveyed and understood. The tool at issue is called a function in programming languages. Functions structure the code and make it clearer.
There are programming languages that are finished at this point. They offer variables, operators, control structures and functions and thus everything you need to develop full-fledged computer applications. Such programming languages are called procedural programming languages. Procedure is another term for function and refers to the fact that the highest and best design element in these programming languages is precisely the functions. Well-known procedural programming languages are C, Pascal and Basic.
Unfortunately, the problem with modern software development today is that it is so immensely complex that functions as structuring agents are just a drop in the ocean. Applications that consist of millions of lines of code require better structuring options so that the programs can still be developed in a meaningful way. In the past few years, object orientation has prevailed and a tool has been added to the procedural programming languages. Code is no longer clearly structured with the help of functions, but with classes and objects. Object orientation is the holy grail today and is the most powerful tool we currently have for developing software. For example, computer applications such as Microsoft Internet Explorer or the programs from Microsoft Office are all programmed in an object-oriented manner. Well-known object-oriented programming languages are C ++, Java and Smalltalk.
However, if you need a variable in C ++ that is to be able to store a word, you have to give the variable the data type.string word pot;
The advantage of the strictly typed programming languages is that programming errors are prevented. It is not possible in C ++ to accidentally save a word in the variable created above - this does not work due to the data type. The disadvantage, however, is that when you create variables you have to be clear about what kind of information you want to save later. It actually depends on which data type you have to specify.
Link and process information
You now know how to create variables. You can now create as many variables as you want at any time and save information in them. Storing information is not enough, however. After all, you want your application to process information, such as performing a calculation and adding two numbers. You can use variables to store numbers, but how do they add up?
Operators can be structured according to their function and assigned to different groups. For example, there is a group of arithmetic operators whose purpose is to perform basic arithmetic with,, and. Just as arithmetic operators can calculate numbers, logical operators such as, and can calculate truth values. Bitwise operators like,, and work very close to the machine. These operators can be used to process the smallest units of information that the computer has in variables - namely bits. Another group of operators - the so-called comparison operators such as,, and - enable values to be compared.
The operator with the highest priority is usually the parenthesis. This means that parentheses are always preferred and carried out first. This also means that the parentheses can be used to change the order in which operators are executed, as specified by the precedence table. As in mathematics, an addition can be carried out first by using suitable brackets, before the sum is then multiplied by another value.
1.4 Control structures
Execute different code depending on conditions
The statement is what is known as a loop. In addition to the loop, programming languages also offer other loops such as the loop or the loop. However, all of these loops work in a similar way: they execute a block of statements repeatedly, as long as a condition to be checked is true.
Using an additional keyword such as, it is also possible to exit loops prematurely. The loop does not end because the condition to be checked is no longer true, but it ends immediately when the code execution hits.
Instruction blocks that can be called at any time
Parameters are input values that can be passed to a function when it is called and that are processed internally in the function. Not every function requires input values. The function in the example above simply displays a message on the screen so that it is not necessary to pass any parameters to this function.
By creating a structure, it is possible to use data types in your program that do not yet exist. Since C ++ does not automatically provide a data type for storing addresses, you can now create this data type yourself thanks to structures. Once created, you can create a tag from this new data type as usual. In the example above is the name of the variable. And this variable can now store information of the type.
1.7 Other ingredients
Of classes and objects
The components of a programming language that have become known in this chapter can be found in almost every language. In addition, programming languages sometimes offer elements such as classes and objects. These programming languages include, for example, Smalltalk, C ++ and Java. These are object-oriented programming languages. In programming languages of this type, objects are used that enable program development that is closer to the description of the problem. With less abstraction from the problem to the solution program, larger applications in particular can be developed more easily, which would become too confusing due to a lack of class and object support.
Object-oriented programming languages are currently the holy grail of programming languages. They are the most powerful tool with which software can be developed today. Most large and successful applications, such as Microsoft's Internet Explorer or all Microsoft Office programs, are programmed in an object-oriented manner. However, the object orientation has also lost some of its luster. Years ago it was considered the ultimate solution to all problems in software development, but one still has to recognize that it is not a panacea, but can also be improved. Of course, programming languages and management methods in software development are also evolving, so that here too it is certainly not all evening.
1.8 Language Development
From proprietary languages and open standards
The vast majority of languages belong to the general public, to put it somewhat casually. They are being further developed by programmers worldwide, which has not been a problem since the Internet at the latest. The standardization of the further developments is taken over by international committees, in which mostly representatives of leading software companies sit. The prominent founding fathers of the programming languages often also have a few important words to say within the further development and standardization committees.
Probably the best-known programming language that belongs to a company and is not further developed by international bodies is Java. Java is a proprietary language and is owned by Sun Microsystems. If you want to use Java, you have to accept the Java license terms. Independent further development of the programming language is prohibited. In January 2001, a court process lasting several years between Sun and Microsoft ended, in which Sun accused Microsoft of not having adhered to the license terms, but of having changed the Java programming language independently. As of January 2001, Microsoft no longer supports Java.
1.9 Compiler and Interpreter
From source code to program execution
When you write small programs as in the examples above, you as a programmer are always working with the source code. The source code is the human readable program flow. While you and I understand this source code quite well, the computer cannot do anything with it. This is important because you want the computer to run your program. The computer only understands machine code. That means someone has to convert the source code of the program into machine code.
Programs called compilers are used to convert source code into machine code. Depending on the programming language and computer system used, you will need a different compiler. If your source code is written in the C ++ programming language and you want to run the program on a computer with the Intel Pentium chip, for example, you need a compiler that can convert C ++ source code into machine code for the Intel chip. If you want your C ++ source code to run on a computer with a PowerPC chip, you need a compiler that converts C ++ into machine code for the PowerPC. Compilers have to master the language of the source code on the one hand, and the machine code of the target system on the other.
Source codes that are converted into machine code with compilers only need to carry out this conversion once. Then there is an executable file that you can start immediately every time, for example by double-clicking as in Windows. One also speaks of native applications. You no longer need the source code, as the complete machine code is already in the file. And that's the only thing the pc needs.
The Java programming language has a special position here. Source code in Java is compiled, but not for a specific target system such as an Intel Pentium chip or a PowerPC chip, but for a virtual machine. This virtual machine is ultimately a computer program that interprets the compiled and virtual machine code. By converting Java source code into virtual machine code and interpreting the virtual machine code, a higher execution speed can be achieved than with purely interpreting languages. The execution speeds of purely compiled programming languages compared to Java are still ten to twenty times faster - roughly as a rule of thumb. However, by compiling the source code for a virtual machine, Java is a language with greater portability. For example, while C ++ programs are compiled either for an Intel Pentium chip or for a PowerPC chip, Java programs run on all computer systems - provided that a program exists for interpreting the virtual machine code. Java programs trade execution speed for portability.
Practice creates masters
You can purchase the solutions to all of the exercises in this book as a ZIP file.
Copyright © 2001-2010 Boris Schäling
- Should people worship
- What is a non-participant observation
- In which vehicle are 15W20 oil used?
- Is the CRED app overrated
- Is there anyone from Pune on Quora
- What are the computer virus inventors called
- How do queen crab legs taste
- What's your favorite antibacterial soap
- How is a computer helpful for programming?
- Bergamot essential oil can help with anxiety
- Do Sensitive Toothpastes Really Work?
- At what age can a pilot retire
- Black men like Argentine women
- What is the central Maven repository
- How do I refuse a birthday present
- Will self-driving cars embarrass people?
- What are the negatives of Elizabeth Warren
- Who are you really
- Why does it always hurt me
- Know foreigners Taobao
- What is He3 in chemistry
- Why did my laptop screen turn red
- How can Excel be used for prediction
- When will Tibet be part of India?