Introduction To Programming Language


 

Introduction to Programming Language

Ø  A program is a set of instructions given to a computer to perform a specific operation.

Ø  A programming language is a formal language that specifies a set of instructions for a computer to perform specific tasks.

Ø  It’s used to write software programs and applications, and to control and manipulate computer systems.

Ø  There are many different programming languages, each with its own syntax, structure, and set of commands.

Ø  Some of the most commonly used programming languages include Java, Python, C++, JavaScript, and C#.

Ø  The programmer communicates with a machine using programming languages.

Basic Terminologies  in Programming Languages

Ø  Algorithm: A step-by-step procedure for solving a problem or performing a task.

Ø  Variable: A named storage location in memory that holds a value or data.

Ø  Data Type: A classification that specifies what type of data a variable can hold, such as integer, string, or boolean.

Ø  Function: A self-contained block of code that performs a specific task and can be called from other parts of the program.

Ø  Control Flow: The order in which statements are executed in a program, including loops and conditional statements.

Ø  Syntax: The set of rules that govern the structure and format of a programming language.

Ø  Comment: A piece of text in a program that is ignored by the compiler or interpreter, used to add notes or explanations to the code.

Ø  Debugging: The process of finding and fixing errors or bugs in a program.

Ø  IDE: Integrated Development Environment, a software application that provides a comprehensive development environment for coding, debugging, and testing.

            Operator: A symbol or keyword that represents an action or operation to be performed on one or more values or variables, such as + (addition), – (subtraction), * (multiplication), and / (division).

            Statement: A single line or instruction in a program that performs a specific action or operation.

Types of Programming Languages

Ø  Machine Language

Ø  Machine language is a collection of binary digits or bits that the computer reads and interprets.

Ø  Machine language is the only language a computer is capable of understanding.

Ø  Machine level language is a language that supports the machine side of the programming or does not provide human side of the programming.

Ø  It consists of (binary) zeros and ones.

Ø  Each instruction in a program is represented by a numeric code, and numerical addresses are used throughout the program to refer to memory locations in the computer’s memory.

Ø  Microcode allows for the expression of some of the more powerful machine level instructions in terms of a set of basic machine instructions.

Ø  Assembly language

Ø  An assembly language is a type of low-level programming language that is intended to communicate directly with a computer’s hardware.

Ø  Unlike machine language, which consists of binary and hexadecimal characters, assembly languages are designed to be readable by humans.

Ø  Low-level programming languages such as assembly language are a necessary bridge between the underlying hardware of a computer and the higher-level programming languages

Ø  Assembly language is easier to use than machine language.

Ø  An assembler is useful for detecting programming errors.

Ø  Programmers do not have the absolute address of data items.

Ø  High level language

Ø  High level language is a language that supports the human and the application sides of the programming.

Ø  A language is a machine independent way to specify the sequence of operations necessary to accomplish a task.

Ø  A line in a high level language can execute powerful operations, and correspond to tens, or hundreds, of instructions at the machine level.

Ø  Consequently more programming is now done in high level languages.

Ø  Examples of high level languages are BASIC, FORTRAN, C, C++,Java etc

Ø  Fourth Generation Language

Ø  a grouping of programming languages that attempt to get closer than 3GLs to human language, a form of thinking, and conceptualization and are easier to use than 3GLs.

Ø  It is a non-procedural language which means that the programmer defines what has to be done instead of how the task is to be completed.

Ø  4GL is more familiar and similar to human language.

Ø  These languages are usually designed for specific purposes and are commonly used in database programming and scripts such as PHP, Python, SQL, and many more.

Ø  4GLs make programming easier, more efficient, and more effective for users with less programming skills.

Ø  Fifth Generation Language

Ø  A fifth-generation programming language is based on solving using constraints given to the program rather than using an algorithm written by a programmer.

Ø  It very closely resembles human speech. Examples are PROLOG, Mercury, OPS5, AI, etc.

Ø  These programming languages are designed to make the computer smarter and more intelligent.

Ø  It is mainly used in artificial intelligence research.

Ø  PROLOG (Programming Logic) is an example of fifth-generation language.

Ø  It is based on mathematical logic to solve the problems given by the programmer.

Language Processor

Ø  A language processor, or translator, is a computer program that translates source code from one programming language to another.

Ø  They also identify errors during translation.

Ø  Computer programs are usually written in high-level programming languages (like C++, Python, and Java).

Ø  Further, to make them understandable by the computer, a language processor needs to translate the source code into machine code (also known as object code, which is made up of ones and zeroes).

Ø  There are three types of language processors:

Ø  Assembler

Ø  compiler

Ø  interpreter

Ø  Assembler

Ø  Assembler is a program for converting instructions written in low-level assembly code into relocatable machine code and generating along information for the loader.

Ø  It generates instructions by evaluating the mnemonics (symbols) in operation field and find the value of symbol and literals to produce machine code.

Ø  Now, if assembler do all this work in one scan then it is called single pass assembler,

Ø  otherwise if it does in multiple scans then called multiple pass assembler.


Ø  Compiler

Ø  A compiler is a software program that is responsible for changing initial programmed code into a more basic machine language closer to the “bare metal” of the hardware, and more readable by the computer itself.

Ø  A high-level source code that is written by a developer in a high-level programming language gets translated into a lower-level object code by the compiler, to make the result “digestible” to the processor.

Ø  The object code is machine code that the processor can perform one instruction at a time.

Ø  Compilers are needed because of the way that a traditional processor executes object code.

Ø  Interpreter

Ø  An interpreter is a program that directly executes the instructions in a high-level language, without converting it into machine code.

Ø  Translate the source code in some intermediate code and then execute this code.

Ø  Using an internal compiler to produce a precompiled code. Then, execute this precompiled code.

Interpreter vs Compiler




 Program Error

Ø  Errors are the problems or the faults that occur in the program, which makes the behavior of the program abnormal, and experienced developers can also make these faults.

Ø  Programming errors are also known as the bugs or faults, and the process of removing these bugs is known as debugging.

Ø  These errors are detected either during the time of compilation or execution.

Ø  Thus, the errors must be removed from the program for the successful execution of the program.

Ø  There are mainly five types of errors exist in C programming:

Ø  syntax error

Ø  semantics error

Ø  runtime error

Ø  Linker error

Ø  Logical Error

Syntax Error

Ø  Syntax errors are also known as the compilation errors as they occurred at the compilation time, or we can say that the syntax errors are thrown by the compilers.

Ø  These errors are mainly occurred due to the mistakes while typing or do not follow the syntax of the specified programming language.

Ø  These mistakes are generally made by beginners only because they are new to the language.

Ø  These errors can be easily debugged or corrected.

Ø  Commonly occurred syntax errors are:

Ø  If we miss the parenthesis (}) while writing the code.

Ø  Displaying the value of a variable without its declaration.

Ø  If we miss the semicolon (;) at the end of the statement.

Ø  For example: If we want to declare the variable of type integer,  

Ø  int a; // this is the correct form  

Ø  Int a; // this is an incorrect form.  

Semantics error

Ø  Semantic errors are the errors that occurred when the statements are not understandable by the compiler.

Ø  The following can be the cases for the semantic error:

Ø  Use of a un-initialized variable.

Ø  int i;

Ø  i=i+2;

Ø  Type compatibility

Ø  int b = "javatpoint";

Ø  Errors in expressions

Ø  int a, b, c;

Ø  a+b = c;

Run Time Error

Ø  Sometimes the errors exist during the execution-time even after the successful compilation known as run-time errors.

Ø  When the program is running, and it is not able to perform the operation is the main cause of the run-time error.

Ø  The division by zero is the common example of the run-time error.

Ø  These errors are very difficult to find, as the compiler does not point to these errors.

Ø  For Example: Number divide by zero.

Ø  int a=2;  

Ø  int b=2/0;  

Linker error

Ø  Linker errors are mainly generated when the executable file of the program is not created.

Ø  This can be happened either due to the wrong function prototyping or usage of the wrong header file.

Ø  For example, the main.c file contains the sub() function whose declaration and definition is done in some other file such as func.c. During the compilation, the compiler finds the sub() function in func.c file, so it generates two object files, i.e., main.o and func.o.

Ø  At the execution time, if the definition of sub() function is not found in the func.o file, then the linker error will be thrown.

Ø  The most common linker error that occurs is that we use Main() instead of main().

Logical Error

Ø  The logical error is an error that leads to an undesired output.

Ø  These errors produce the incorrect output, but they are error-free, known as logical errors.

Ø  These types of mistakes are mainly done by beginners.

Ø  The occurrence of these errors mainly depends upon the logical thinking of the developer.

Ø  If the programmers sound logically good, then there will be fewer chances of these errors.

Features of good program

Ø  Potability: The computer program should be platform independent.

Ø  Maintainability: It is related to finding and removing  programming errors.

Ø  Efficient: It is related to space & time complexity.

Ø  Reliable: Computer programs should maintain time and space complexity even if the user needs are changed.

Ø  Machine Independence: Computer programs should possess the  run-time equilibrium on different systems.

Ø  Flexible: Computer programs should provide the flexibility of extension. If required computer programs should extend features easily.

Programming Paradigm

Ø  an approach to solving a problem.

   Imperative

Ø  Imperative programming consists of sets of detailed instructions that are given to the computer to execute in a given order.

Ø  It's called "imperative" because as programmers we dictate exactly what the computer has to do, in a very specific way.

Ø  Imperative programming focuses on describing how a program operates, step by step.

Ø   Example: baking a cake.

        Declarative

Ø  Declarative programming is all about hiding away complexity and bringing programming languages closer to human language and thinking.

Ø  It's the direct opposite of imperative programming in the sense that the programmer doesn't give instructions about how the computer should execute the task, but rather on what result is needed.

Ø  What declarative programming does is to hide away that complexity from the direct view of the programmer.

Procedural

Ø  Procedural programming is a programming paradigm built around the idea that programs are sequences of instructions to be executed.

Ø  They focus heavily on splitting up programs into named sets of instructions called procedures, analogous to functions.

Ø  A procedure can store local data that is not accessible from outside the procedure's scope and can also access and modify global data variables.

     Functional

Ø  Functional programming encourages programs written mostly with functions.

Ø  It also defends the idea that code modularity and the absence of side effects makes it easier to identify and separate responsibilities within the codebase.

Ø  This therefore improves the code maintainability.

      Object oriented

Ø  The core concept of OOP is to separate concerns into entities which are coded as objects.

Ø  Each entity will group a given set of information (properties) and actions (methods) that can be performed by the entity.

Ø  OOP makes heavy usage of classes (which are a way of creating new objects starting out from a blueprint or boilerplate that the programmer sets).

Ø  Objects that are created from a class are called instances.

       Multi-paradigm

Ø  any programming language which offers multiple programming paradigms is referred to as a multi-paradigm programming language

Ø  The programming world used to be split into functional languages, object-oriented languages, and everything else (mostly procedural languages).

Ø  JavaScript and Python are good examples of multi-paradigm.

Software development Model

Ø  various processes or methodologies that are being selected for the development of the project depending on the project’s aims and goals.

Ø  There are many development life cycle models that have been developed in order to achieve different required objectives.

Ø  The models specify the various stages of the process and the order in which they are carried out.

Ø  various Software development models or methodologies are as follows:

Ø  Waterfall

Ø  Rapid Application Development (RAD)

Ø  Prototype

Ø  Spiral

Ø  Increment

WaterFall Model



Ø  The Waterfall Model was the first Process Model to be introduced. It is also referred to as a linear-sequential life cycle model.

Ø  It is very simple to understand and use. In a waterfall model, each phase must be completed before the next phase can begin and there is no overlapping in the phases.

Ø  The Waterfall model is the earliest SDLC approach that was used for software development.

Ø  The waterfall Model illustrates the software development process in a linear sequential flow.

Ø  This means that any phase in the development process begins only if the previous phase is complete.

Ø  In this waterfall model, the phases do not overlap.

Ø  Requirements are very well documented, clear and fixed.

WaterFall Model-Advantages

Ø  Simple and easy to understand and use

Ø  Phases are processed and completed one at a time.

Ø  Works well for smaller projects where requirements are very well understood.

Ø  Clearly defined stages.

Ø  Well understood milestones.

Ø  Easy to arrange tasks.

Ø  Process and results are well documented.

WaterFall Model-Disadvantages

Ø  No working software is produced until late during the life cycle.

Ø  High amounts of risk and uncertainty.

Ø  Not a good model for complex and object-oriented projects.

Ø  Poor model for long and ongoing projects.

Ø  Not suitable for the projects where requirements are at a moderate to high risk of changing. So, risk and uncertainty is high with this process model.

Ø  It is difficult to measure progress within stages.

Ø  Cannot accommodate changing requirements.

Rapid Application Development



Ø  RAD is a linear sequential software development process model that emphasizes a concise development cycle using an element based construction approach.

Ø  software development methodology that uses minimal planning in favor of rapid prototyping.

Ø  A prototype is a working model that is functionally equivalent to a component of the product.

Ø  the functional modules are developed in parallel as prototypes and are integrated to make the complete product for faster product delivery.

Ø  Since there is no detailed preplanning, it makes it easier to incorporate the changes within the development process.

Rapid Application Development-Phases

Ø  Business Modelling: The information flow among business functions is defined by answering questions like what data drives the business process, what data is generated, who generates it, where does the information go, who process it and so on.

Ø  Data Modelling: The data collected from business modeling is refined into a set of data objects (entities) that are needed to support the business. The attributes (character of each entity) are identified, and the relation between these data objects (entities) is defined.

Ø  Process Modelling: The information object defined in the data modeling phase are transformed to achieve the data flow necessary to implement a business function. Processing descriptions are created for adding, modifying, deleting, or retrieving a data object.

Ø  Application Generation: Automated tools are used to facilitate construction of the software; even they use the 4th GL techniques.

Ø  Testing & Turnover: This reduces the overall testing time. But the new part must be tested, and all interfaces must be fully exercised.

Rapid Application Development-Advantages

Ø  Good to use when the technical risk is limited.

Ø  In this model, changes are adoptable.

Ø  Each phase in RAD brings highest priority functionality to the customer.

Ø  It reduced development time.

Ø  It increases the reusability of features.

Rapid Application Development-Disadvantages

Ø  It required highly skilled designers.

Ø  All application is not compatible with RAD.

Ø  For smaller projects, we cannot use the RAD model.

Ø  On the high technical risk, it's not suitable.

Ø  Required user involvement.

Prototype



Ø  The prototype model requires that before carrying out the development of actual software, a working prototype of the system should be built.

Ø  A prototype is a toy implementation of the system.

Ø  A prototype usually turns out to be a very crude version of the actual system, possible exhibiting limited functional capabilities, low reliability, and inefficient performance as compared to actual software.

Ø  In many instances, the client only has a general view of what is expected from the software product.

Ø  In such a scenario where there is an absence of detailed information regarding the input to the system, the processing needs, and the output requirement, the prototyping model may be employed.

Prototype-Advantages

Ø  Reduce the risk of incorrect user requirement

Ø  Good where requirement are changing/uncommitted

Ø  Regular visible process management

Ø  Support early product marketing

Ø  Reduce Maintenance cost.

Ø  Errors can be detected much earlier as the system is made side by side.

Prototype-Disadvantages

Ø  An unstable/badly implemented prototype often becomes the final product.

Ø  Difficult to know how long the project will last.

Ø  Easy to fall back into the code and fix without proper requirement analysis, design, customer evaluation, and feedback.

Ø  Special tools & techniques are required to build a prototype.

Ø  Needs committed customer

Ø  May be too customer specific, no broad market

Spiral



Ø  Spiral model is one of the most important Software Development Life Cycle models, which provides support for Risk Handling.

Ø  In its diagrammatic representation, it looks like a spiral with many loops.

Ø  The exact number of loops of the spiral is unknown and can vary from project to project.

Ø  Each loop of the spiral is called a Phase of the software development process. 

Ø  The exact number of phases needed to develop the product can be varied by the project manager depending upon the project risks.

Ø  As the project manager dynamically determines the number of phases, so the project manager has an important role to develop a product using the spiral model. 

Spiral-Phases

Ø  Objectives determination and identify alternative solutions: Requirements are gathered from the customers and the objectives are identified, elaborated, and analyzed at the start of every phase. Then alternative solutions possible for the phase are proposed in this quadrant.

Ø  Identify and resolve Risks: During the second quadrant, all the possible solutions are evaluated to select the best possible solution. Then the risks associated with that solution are identified and the risks are resolved using the best possible strategy. At the end of this quadrant, the Prototype is built for the best possible solution.

Ø  Develop next version of the Product: During the third quadrant, the identified features are developed and verified through testing. At the end of the third quadrant, the next version of the software is available.

Ø  Review and plan for the next Phase: In the fourth quadrant, the Customers evaluate the so far developed version of the software. In the end, planning for the next phase is started.

Spiral-Advantage

Ø  Risk Handling: Spiral Model is the best development model to follow due to the risk analysis and risk handling at every phase.

Ø  Good for large projects: It is recommended to use the Spiral Model in large and complex projects.

Ø  Flexibility in Requirements: Change requests in the Requirements at later phase can be incorporated accurately by using this model.

Ø  Customer Satisfaction: Customer can see the development of the product at the early phase of the software development

Spiral-Disadvantage

Ø  Complex: The Spiral Model is much more complex than other SDLC models.

Ø  Expensive: Spiral Model is not suitable for small projects as it is expensive.

Ø  Too much dependability on Risk Analysis: The successful completion of the project is very much dependent on Risk Analysis.

Ø  Difficulty in time management: As the number of phases is unknown at the start of the project, so time estimation is very difficult.

Increment



Ø  Incremental Model is a process of software development where requirements are broken down into multiple standalone modules of software development cycle.

Ø  Incremental development is done in steps from analysis design, implementation, testing/verification, maintenance.

Ø  Each iteration passes through the requirements, design, coding and testing phases.

Ø  And each subsequent release of the system adds function to the previous release until all designed functionality has been implemented.

Incremental-Advantages

Ø  The software will be generated quickly during the software life cycle

Ø  It is flexible and less expensive to change requirements and scope

Ø  Throughout the development stages changes can be done

Ø  This model is less costly compared to others

Ø  A customer can respond to each building

Ø  Errors are easy to be identified

Incremental-Disadvantages

Ø  It requires a good planning designing

Ø  Problems might cause due to system architecture as such not all requirements collected up front for the entire software lifecycle

Ø  Each iteration phase is rigid and does not overlap each other

Ø  Rectifying a problem in one unit requires correction in all the units and consumes a lot of time

System Design Tool

Ø  System design tools play an important role in system development.

Ø  It is similar to designing the blueprint of a house before actual constructing beings. 

Ø  Some of them are:

Ø  Data Flow Diagram (DFD)

Ø  Flowchart

Ø  Algorithms

Ø  Decision Table and decision tree

Ø  ERD

Ø  Pseudocode

Data Flow Diagram

Ø  A Data Flow Diagram (DFD) is a traditional visual representation of the information flows within a system.

Ø  A neat and clear DFD can depict the right amount of the system requirement graphically.

Ø  It shows how data enters and leaves the system, what changes the information, and where data is stored.

Ø  The objective of a DFD is to show the scope and boundaries of a system as a whole.

Ø  It may be used as a communication tool between a system analyst and any person who plays a part in the order that acts as a starting point for redesigning a system. 

Flowchart

Ø  A flowchart is a picture of the separate steps of a process in sequential order.

Ø  It is a generic tool that can be adapted for a wide variety of purposes, and can be used to describe various processes, such as a manufacturing process, an administrative or service process, or a project plan.

Commonly used symbols in flowcharts



Flowchart-Examples




Algorithms

Ø  An algorithm is a sequence of instructions that are carried out in a predetermined sequence in order to solve a problem or complete a work. OR

Ø  An algorithm is a set of instructions for solving a problem or accomplishing a task.

Ø  One common example of an algorithm is a recipe, which consists of specific instructions for preparing a dish or meal.

Ø  Every computerized device uses algorithms to perform its functions in the form of hardware- or software-based routines.

Basics part of an algorithm

Ø  Describe the problem in mathematical terms

Ø  Create the formulas and processes that create results

Ø  Input the outcome parameters

Ø  Execute the program repeatedly to test its accuracy

Ø  The conclusion of the algorithm is the result given after the parameters go through the set of instructions in the program.

Algorithm-Example

Ø  Step 1 - Get started

Ø  Step 2 - Declare three integers a, b, c

Ø  Step 3 - Define the values of a and b

Ø  Step 4 - Add the values of a and b

Ø  Step 5 - Save the output of step 4 in c

Ø  Step 6 - Print c

Ø  Step 7 - Stop

Decision Table

Ø  Decision Table is just a tabular representation of all conditions and actions.

Ø  Decision Table are always used whenever the processing logic is very complicated and involves multiple conditions.

Figure: Sample decision table for the chemical tracking system.

Ø  A decision tree is a visual way to represent the same information that appears in a decision table.

Ø  Decision Trees show a better representation of decision outcomes.



  Decison Table vs Decision Tree


Entity Relationship Diagram (ERD)

Ø  A diagram that displays the relationship of entity sets stored in a database.

Ø  In other words, ER diagrams help to explain the logical structure of databases.

Ø  ER diagrams are created based on three basic concepts: entities, attributes and relationships.

Ø  ER Diagrams contain different symbols that use rectangles to represent entities, ovals to define attributes and diamond shapes to represent relationships.

 ERD Symbols & Notation

ERD-Example

Pseudocode

Ø  Pseudo code is a term which is often used in programming and algorithm based fields.

Ø  Pseudocode literally means ‘fake code’.

Ø  It is an informal and contrived way of writing programs in which you represent the sequence of actions and instructions (aka algorithms) in a form that humans can easily understand.

Ø  It is a methodology that allows the programmer to represent the implementation of an algorithm. 

Ø  It doesn’t matter what language you use to write your pseudocode. 

Ø  In pseudocode, you don't have to think about semi-colons, curly braces, the syntax for arrow functions, etc.

Pseudocode-Example

Read the value of A and B

IF (A > B) THEN

Print A + “is bigger”;

ELSE

Print B + “is bigger”;

ENDIF;

 



 

 



 

 

 

 

No comments:

Post a Comment

Research in Social Science

   C  Concept of Research in Social Science -         Understanding the concept of Research Methods, Techniques and Tools: Interview, Fo...