Tuesday 15 December 2015

Procedural languages

Procedural languages are the most conventional 2nd and 3rd generation programming languages.
They tell the computer how to do something using a sequence of commands called imperatives- do this, do that
Characteristics:
> The code runs one line after another, it supports selection,iteration and assignment.
>Uses variables
>Programs are built in modules, which contain instructions to define exactly how the program should   run

Global variables are declared at the start of the program and are accessible throughout the program.
Local variables are defined inside procedures and are only visible to them.

Python Snowflakes:


Advantages and disadvantages of procedural language:

Advantages:- Excellent for general purpose programming- Many books and references available on well-tried and tested coding algorithms- Good level of control without having to know precise target CPU details- Portable source code - use a different compiler to target a different CPUDisadvantages:- As there are so many procedural languages, a programmer tends to have to specialise in a particular language in order to get work- Need to be very precise and knowledgeable about programming instructions, and so a fully de-bugged working program takes more time to put together- Not as efficient as hand-crafted source code written in a low level language




Thursday 10 December 2015

Device drivers


Device Drivers:

Every piece of hardware that connects to a computer will have a device driver that allows the computer system to communicate with it. Some drivers will be preinstalled with the OS, the right ones are loaded on boot up. The exact details of the driver will be kept in a file, called the registry in Windows. Makers of hardware will provide the device drivers for the piece of hardware and the specific OS.


When an application asks the OS to save a file or access any connected device, the OS needs to make use of a hardware driver. Hardware drivers are simply software that understands how to talk directly to a given piece of hardware. Drivers are normally produced by the manufacturer of the hardware, but can also be produced by OS manufacturers and even the open-source community. As all devices are different, the OS needs to have a generic way of talking to devices of the same type. This generic communication is not understood by the hardware itself and requires translation into the correct binary control signals. Hardware drivers perform this translation from the generic instructions sent by the OS to the specific instructions understood by the hardware. Drivers are only loaded by the OS, if specific hardware has been connected to the PC and requires installation. They are modular in nature and can be loaded on demand. Most OS installations will detect what hardware the user has and try to install the required drivers when the OS is installed. This functionality works by each device having two codes, a vendor ID (VID) and a product ID (PID). When a device is connected, the OS queries the device for these two codes. It then checks its database of known vendors and products to see if a suitable device driver can be found. If not, the user will have to install one before that device can be used.
Sometimes the OS will install generic drivers that will not be able to use the full range of features of the device. When setting up a new OS, you will have to install drivers for every piece of hardware on your PC. To see what drivers your system is currently using, you will need to load Device Manager for Windows or System Profiler on a Mac. On Linux the easiest way to see what devices are installed is to run ‘lspci’ or ‘lsusb’ from the command line.

What a device driver does:

A device driver understands how to talk to a particular piece of hardware, it translates the generic way an OS communicates to hardware into the correct binary signals for the hardware. When a new piece of hardware is installed the device driver will be installed using the Vendor and Product ID from the device so that it can automatically download the correct driver.



Friday 4 December 2015

Iteration

Iteration
Simply iteration just means repetition.
It is a sequence of instructions that are repeated multiple times.

There are 3 different types of iteration. These are:

  • WHILE
    • This loop is a condition controlled loop. the condition is tested upon entry to the loop, the instruction in this loop would not be executed if not all of the conditions are met. The loop will repeat itself until all the conditions are met, when this happens the loop will be exited.
  • REPEAT
    • The statements in this loop are executed before the condition is evaluated. A repeat loop is also a condition controlled loop, and it must be run through once at least.
  • FOR
    •  This is a count controlled loop, this is because you tell it the amount of times to complete this loop. For this there will always be a counter variable which will automatically increment each time that the loop is run through.
A procedure is a sub routine which execute their statements and does not return a value.

Thursday 3 December 2015

Open Source

Source Code:
Source code is the raw code produced by developers and defines what they want their software to do. It is written by developers using a programming language such as Java.

Open source:
Open-source software is opposite to closed source. For software to be open source, you must be able to download the source code and make changes to it  freely. There is a big difference between free software and open source. Free software does not make the source code available. Open-source code tends to have a lot of developers working on it for free, or being sponsored by a larger company. Anyone can join the community of developers to make changes to the code and upload their changes for the rest of the world to see. If the changes are good, they will be merged into the main source code and all users can benefit. Some famous examples of open-source software are Mozilla Firefox and the Linux kernel.

One of the most common licences is the GNU General Public License (GNU GPL or GPL) (GNU is a recursive acronym that stands for ‘GNU’s not UNIX’). Linux is under this type of license.

A program is free software, for certain users if:
  • You have the freedom to run the program as you wish, for any purpose. 
  • You have the freedom to modify the program to suit your needs. (To make this freedom effective in practice, you must have access to the source code, since making changes in a program without having the source code is exceedingly difficult.) 

Positives:
  • Free to use for everyone 
  • Allows creatation new programs and ideas that can be implemented on a larger scale
  • Continually evolving over time
  • Modify software to business practices, not possible with proprietary software

Negatives:
  • High number of bugs
  • Bugs can take time to be fixed developers with less support
  • Generally harder to use for individuals
  • Can have some high costs
  • Source code open to certain users.

Questions:
1, Open source software has the source code available in the public domain for viewing and editing.

2. Off the shelf software can be bought online as a download or in a shop on an optical disk. It is ready to use straight away for general tasks for a wide range of users. It cannot be used for specific tasks. Bespoke software is custom designed for a specific purpose by a company for a client that has a specific request, for example software for business. This generally has less support but features can be added on request.

3. GNOME, Apache, OpenOffice.

4. It is better value for money for the government without being locked into proprietary software. It allows flexibility without extra costs.

5. Benefits: lower costs, easier to add new features, it will evolve continually over time. Issues: lower security issues, source code available to malicious users, little to no support, bugs take a while to be fixed.

6. Licenses are needed to stop people using open source software for commercial reasons and making money off a free to use program. However it also stops malicious users from taking software and not sharing their edits with other users, for example GNU license.