maintains the memory for each programme. • Allows basic system operations to take place such as input/output. • Receives input from peripheral devices (i.e. speakers, keyboard, mouse). • Acts as a ‘buffer’ between the user and a programme. The user doesn’t need to tell a programme to do something, they just need to tell the OS which then controls the programme to do that thing. • Provides a user-interface. The windows and buttons that we see and interact with are a part of this interface.
type when writing in a programming language such as Java. While it has to follow the correct syntax, the important thing to note about source code is that it is understandable to a user. For example, the code: System.out.println(“Hello World”); is a piece of source code. We can see it and, without needing to execute it, we can make an educated guess to its function: it prints a line of text saying “Hello world”.
a computer. It is a programming language that the computer’s hardware can interpret. Although a user could learn it (and indeed this was necessary at one point) it is difficult, unintuitive, and time-consuming. - Machine code is known as a low-level programming language. - Java is one of many high-level programming languages. A high-level programming language abstracts away from the complexity of a low-level language
this needs to be converted to machine code (a low-level language) so that the instructions we’ve written can be executed. This translation is done by software called a compiler. So the user writes some source code, the compiler converts this to machine code, and then this is executed. Seems okay, right?
is that different computers have different machine code instruction sets. That is, they read machine code differently. So source code that is translated directly into machine code would not be understood if sent to a different computer. This limits the portability of code.
a piece of software called the virtual machine. A virtual machine mimics hardware, and has its own instruction sets just like hardware, but is in fact software. The Java Virtual Machine (JVM) converts source code into bytecode. We can think of bytecode as the machine code of the JVM.
can think of this process as consisting of three stages: 1] The user writes the source code. 2] The JVM compiles the source code into bytecode. 3] The bytecode is compiled into machine code which then executes.
can be shared between different computer systems. As long as each computer system has the same JVM installed, the bytecode can be translated into machine code separately on different computers, and will work the same.