Thursday, 22 September 2016

Assignment 1


Know the Features of Programming Languages
Unit 6: Assignment 1
Declan O'Driscoll
10-12-2016



Table of Contents



Know the Features of Programming Languages

Procedural Programming Paradigm

Procedural programming is derived from structured programming; it is based on the concept of a procedure call. Procedures are also known as subroutines or functions contain a series of steps to be carried out in the given procedure. Any procedure can be called from any point within the general program this includes other procedures or even itself.

Advantages

Procedural programming is written in a step by step function this makes smaller programs easier to follow. Also, Procedural programming is easy to maintain as each procedure or function is able to be debugged in isolation from the rest. This allows for easy isolation of any problems or issues.

Disadvantages

The main disadvantage to procedural programming is that it is not fast to run compared with lower level language. For applications that require more processing power, this can limit the effectiveness. Also, procedural programming struggles to handle situations in which a number of possible actions may lead to the desired result.

Object Oriented Programming Paradigm

Object Oriented Programming (OOP) is designed to model and organize around objects rather than actions and data rather than logic. OOP views programs as a collection of objects such as a database record instead of a link of tasks, each object can be viewed as an independent ‘machine’ which a distinct role or responsibility which is capable of receiving messages, processing data and sending other messages to other objects

Advantages

A key advantage of OOP is that objects that are created can be easily reused in other programs. Also, large programs can be very difficult to write. OOP forces designers to go through an extensive planning phase, this makes for better designs with fewer flaws or issues.

Disadvantages

OOP programs are much larger than other programs. This means that they take more hard drive space to be able to perform. Also, OOP requires a lot of work to create. A lot of planning goes into an OOP well before a single piece of code is ever written. Also, OOP programs are slower due to their large size.

Event Driven Programming Paradigm

Event Driven Programming is a paradigm in which the flow of the program has been determined by the events such as different user actions, this can include what to do with mouse clicks or key presses. Event driven programming is a dominant paradigm used in graphical user interfaces (GUI) and other applications such as JavaScript and web applications.

Advantages

An advantage to Event Driven Programming is that it is flexible, programs that use event driven can be altered easily if the programmer wants to change something. Also, it is easier to program. A programmer can put different things on top of the form which can make it simpler for the programmer.

Disadvantages

Event Driven programming is often more complex for smaller simpler programs. Also, the flow of the program is usually less logical and obvious than other programming paradigms.

High-Level Programming

Programs that are written in a high-level language are a much closer representation of how we would write normally. This allows for a programmer to write programs that are more or less independent of a particular type of computer.

Advantages

Generally, high-level programming languages tend to execute faster than other languages, also you can specifically target and utilize specific computer features.

Disadvantages

A disadvantage to High-level programming languages is that in some cases you have an interpreter between which can consume resources. Also, you need to a compiler to get the Higher Level Language to Lower Level Language that can be understood by the machine.

Imperative Programming

Imperative programming is a paradigm that uses statements to change a programs state in the same way that imperative mood in natural languages expresses commands. An imperative program consists of commands that are to be executed by the machine.

Advantages

An advantage of imperative programming is that it is efficient by working closer to the physical machine to be able to execute faster.

Disadvantages

Imperative programming can be complex to understand and due to this, it makes it harder to debug the code to find it's issued. Also, the order of the code is critical to success as if the order is incorrect the program will fail.

Visual Basic

Advantages
Disadvantages
It is free to download and use
Programs created within VB only work on Windows
Easy to learn and easy to understand
Requires a lot of memory to install due to being a GUI
Has an integrated IDE
Slower than lots of other languages

C++

Advantages
Disadvantages
Free to Download and use
Complicated language to learn
Uses a similar syntax to other languages such as Java
Used mostly for platform specific applications
Multi-paradigm friendly so can be used for procedural, OOP, generic and functional programming etc
Overly complex and difficult to debug when used for many applications

Dark BASIC

Advantages
Disadvantages
Free to download and use (with advertisements)
Dark BASIC languages' syntax is unique
Doesn't require as much code as other languages
Mainly focussed on creating games so isn't flexible with it's functionality
Easy to learn
Not very Fast

JavaScript

Advantages
Disadvantages
Free to download and Use
Difficult to use and learn with limited experience
Javascript is cross platform compatible
Slower to develop and execute
Multithreaded to allow for the program to perform different tasks simultaneously
Difficult to create frame based applications

HTML

Advantages
Disadvantages
Free to use
All pages must be edited separately
Easy to edit and understand as it is written in plain text
Limited security features
HTML is supported by all browsers
Structuring can be difficult to learn

Describe the factors influencing the choice of Programming Language

Time Constraints

Depending on how much time a programmer has depends on what language they will use for a project. This is because some languages take longer to code than other languages. This is because each language uses different functions to get to the same end goal.

Organisational Policies

Organisations will all have different policies for the different things within their company. This can be something as simple as their PC operating systems ranging from Windows to Linux or they may have a policy on what programming language that they want to be used in their program. If a company does not have a policy on the set language they want it is up to the programmer to decide on the language that will suit the systems needs and operate efficiently. Using the set information that the programmer receives from the company they will be able to work out the language that will work best for example Visual Basic is a language that is exclusive to windows so will not work on Linux.

Suitability

A programmer must find out what the organization actually wants out of their program. This means that they must found out the systems needs to find what specifics they want in toe program. The Programmer needs to figure out what language will be best for the specific system.

Availability of Trained Staff

If a programmer is making a system for an organization they need to be aware of the staff members and take into consideration what training they will need to use the new program that they create. This means that the Programmer has to take into account the ease of use of the system before choosing the correct language to use.

Reliability

The Programmer has to take into consideration the reliability of the program that they will be creating as organizations do not like down time in their business. If the program was to crash it can cause serious repercussions for the company. This means that the Programmer has to choose a programming language that is reliable and efficient for the organization's needs. The Reliability of a program can also depend on the Time Constraints that the Programmer has to code the program. This is because if they use a reliable language it may take longer to program.

Environment

The environment in which the program is used is a large influencing factor on what programming language to use. For example if a program was being created for a supermarket they will need to ensure that it is a reliable system and also that the programming language that is chosen can meet the environment of its use, this means that choosing a programming language that is unable to handle things such as a barcode scanner inputting information is not a good choice for a supermarket.

Development and Maintenance Costs

Although the Programming Languages and their programs used to code them are freely available there are costs that are needed for development. The Programmer will have to look at what the specs on the computers are so that they can tell the company if any hardware is needed to be updated to efficiently run the program. There are costs for the continuous maintenance of the program. This is if the program has issues after release that users have found the Programmer will have to find and fix the bugs and release patches and updates to the program to ensure that the bugs can be fixed. There are also costs included in the upgrades of the program.

Expandability

Expandability is important as an organization is constantly looking for ways to grow. If a company is happy with the program that has been created they can request new features and updates to the program. This can mean that the Programmer will then need to add more functions to the software. This is important as certain programming languages are not the best for expandability and adding more features later on. Also if a company grows they need their program to be able to adapt and grow with the company and be able to support the new expansions.

Python

Sequencing

Sequences allow a user to store multiple values in an organized and efficient way. There are three different types of sequences. Strings, Lists and Tuples. These are the most used types however there are more.

Strings

A String is where all content within it is allocated a specific number which allows the user to echo a specific character from the string. For example, in the image below you can see that the string “Hello World” is called but only the character label 1 is echoed back.
Even though “H” is the first character Python (and most other programming languages) start counting at the number zero. So it views the string “Hello World” as shown below.
A user is also able to call upon a negative number and Python will count backwords through the string to find the correct value. So for example, if I asked for the -2 character I would be given the “d”.

Lists and Arrays

A list is just another word for an Array is a list of values that are organized into a specific order. Lists are created by python using square brackets and then listing with comas the individual values. Again values of a list can be displayed by calling upon the list name and containing the numeric value of the item in the list you want to view.
A user is also able to return the total number of items that are in a list or array by using the “len()” function.

Tuples

Tuples operate similar to lists however, once a tuple is set there is no way of changing it. A user isn’t able to add, remove or edit any element of a tuple Otherwise they would be identical to lists. You can create a tuple you declare it by first naming it then listing the items of the tuple. Like a list but without the square brackets. An item in a Tuple can be called upon like a list. Tuples also are able to have their total values listed like a list with the use of the “len” function.

Selection

Selection statements allow for a program to choose when to execute specific instructions. For example, a program might choose how to proceed to the basis of the users input. The most common selection statement is the “IF” statement. This is where the code reaches an option where one of 2 things can happen. An “IF” statement has a condition and if that condition is met then the program will execute the if code. However, if the condition is not met by the program then it will execute the else code.
Python if...else statement
Most “IF” statements follow the principals of the diagram shown above. However, some “IF” statements have extra variables that have to be met along the way. This is the “ELSE IF” statement. Where the IF statement would normally execute the else code if the first condition is not met you can use else if so that if the else statement conditions are not met it will execute additional code. The Typical else if statement looks like the flow chart below. The example is a grading example where if the student has scored more than or equal to 80 then they get given a grade a, else if they scored more than or equal to 65 they are given a grade B and so on.
None

Iteration

Iteration is the repetition of a specific procedure in a program. This is very important in programming as it is used to create loops. A loop is a series of code that is executed within a program and repeated a set number of times. Iteration is also used to create infinite loops which are constantly executed. Infinite loops are common in video games as it’s used to constantly update and render the world surrounding a player.
Iteration is also used when a specific sequence of code needs to be executed multiple times until it’s condition has been met or completed. For example, a timer would continue to print the current time that is left until it reaches zero which is its condition. In this example the program will subtract one from the variable until it reaches the desired value of zero.

Data Types

There are many different data types which can be used in different scenarios that can arise within a program. Each variable that is created when programing has a data type. There are six different data types. These are Strings, Integers, floats, characters, datetimes and Boolean. Each data type has an appropriate situation where it should be used and all have different features.

String

Strings are a data type that contains plain text. They are used to be printed out onto a screen and they can be stored into variables as well. Strings cannot perform mathematical operations as they are sentences of words.

Integers

An Integer is any whole number. This also includes negative whole numbers. Programmers can use mathematical operations with integers. This means that they can be added, subtracted, multiplied, divided or any other mathematical operation. For example, you can add together 2 numbers such as 1 + 2.

Floats

A Float is any number that contains a decimal point. This also includes negative numbers. Just like integers floats can be used with mathematical operations such as addition, subtraction and multiplication. They are used when a specific and precise value is needed rather than a whole number. For example, if someone wanted to do a calculation with Pi then they need a float number to be precise so that they can do the operation with the value “3.14159” rather than “3”.

Characters

A character is a specific letter within a string which can be accessed and printed on it’s own. This can be used by first creating a string with a value then echoing it calling upon a specific character number from within the string. Characters in a string are counted starting at zero so in the example below character 1 is “e” and Character zero is “D”.

Datetimes

The datetime datatype is used to store a specific point in time which can show the day, month and year. It can also be used to show the time of day in hours, minutes and seconds. The value of this can be manipulated so that it can adapt to different time zones.

Boolean

A Boolean is a data type that has only 2 possible values. True or False, this datatype is sued to validate weather a condition has been met or not and they are useful for many situations. Booleans are used in selection to allow programs to execute a specific series of code when it is needed and when the conditions are met.