The Birth of Modern Programming Language
Programming Languages
- Programming languages were of two types:
- Non-structured
- Structured
Non-Structured Programming Languages
Generally oriented towards particular tasks.
Examples:
- FORTRAN (Formula Translation):
- Used mainly for space research programs.
- Still in use with some modifications.
- COBOL (Common Business-Oriented Language):
- Developed mainly for Mainframe computers.
- Used in microcomputers as well.
- FORTRAN (Formula Translation):
Structured Programming Languages
- Languages like SIMULA and C addressed the need for structured programs.
- C:
- Changed the way programming was approached and thought about.
- Its creation was a direct result of the need for a structured, efficient, high-level language that could replace assembly code when creating system programs.
- Prior to C, languages like Fortran were not suitable for system code.
- Languages like BASIC and COBOL were not designed around structured principles.
Object-Oriented Programming (OOP)
- Emergence: Late 70s and early 80s.
- Motivation: As projects grow in size, their complexity exceeds what a programmer can manage using structured programming alone.
- OOP is a programming methodology that helps organize complex programs using:
- Inheritance
- Encapsulation
- Abstraction
- Polymorphism
- Adoption: By the end of the 80s and early 90s, OOP using C++ took hold.
Java
- Conceived by James Gosling and others; initially called "Oak."
- Renamed to Java in January 1996.
BlueJ
- Introduction: BlueJ is distributed in three different formats:
- Windows systems
- Mac OS
- Other systems
- Purpose: BlueJ offers an easy way to run Java programs and view program documentation.
- Type: BlueJ is an Integrated Development Environment (IDE).
- Features: It includes tools like a debugger and an editor.
- Starting BlueJ: Start → All Programs → BlueJ.
- Interface: The first screen of BlueJ appears briefly, followed by the BlueJ Working Environment screen.
High-Level Programming Languages (HLL)
- Translation: An HLL requires a compiler or interpreter to translate the program into machine language.
- Advantages: Easy to read, write, and maintain.
- Classification: HLLs are further divided into different paradigms, including OOP and POP (Procedural Oriented Programming).
Procedural Oriented Programming (POP) Language
- Definition: A language in which instructions are organized into groups called procedures (functions).
- Examples: BCPL, C, COBOL, etc.
- Implementation: POP and OOP can be accomplished using an editor like IDE (Integrated Development Environment) with a top-to-bottom approach.
Integrated Development Environment (IDE)
- Definition: A software suite that consolidates basic tools required to write and test software.
Object-Oriented Programming (OOP) Language
- Structure: A programming language structure where data and their associated processing methods are defined as self-contained entities called objects.
- Implementation: Programs are divided into small parts called objects.
- Usage: Used to implement real-world entities like inheritance, polymorphism, abstraction, etc., to make the program reusable, efficient, and easy to use.
Concept of Object-Oriented Programs
- Elements: All computer programs consist of two elements: code and data.
- Organization: Object-oriented programming organizes a program around its data (i.e., objects) and a set of well-defined interfaces to that data.
Principles of Object-Oriented Programming
- Four main principles:
- Data Abstraction
- Encapsulation
- Inheritance
- Polymorphism
Data Abstraction
- Definition: Representing essential features without including background details or explanations.
- Analogy: Switchboard
- When you press a certain button, you only need to know what happens without understanding the internal circuitry and wiring.
Encapsulation
- Definition: The wrapping up of data and functions (that operate on the data) into a single unit.
- Requirement: An object that encapsulates data must provide an interface to obtain the result.
- Implementation: The internal coding used for calculations need not be available to the requesting object.
Inheritance
- Definition: The capability of one class to inherit properties from another class.
- Example: A Car inherits properties from Automobiles.
- Base Class & Sub Class:
- A super class (or base class) is a class from which another class inherits properties.
- The inheriting class is called a subclass (or derived class).
Polymorphism
- Definition: The ability for a message to be processed in more than one form.
- Example: The symbol can perform summation or concatenation depending on the data types it is working on.
- Achieving Polymorphism in Java:
- Overloading
- Overriding
- Overriding:
- Occurs when a base class and derived class have the same method names.
- If the subclass provides a specific definition of a parent class method, this action is called method overriding.
Features of Java
- General Purpose:
- Java is used for a variety of applications.
- Object-Oriented:
- Java is a true object-oriented programming language as everything is represented as a class and object.
- Simple:
- Java was designed to be easy for professional programmers with C++ syntax.
- Many programmers have little trouble learning Java.
- Object Oriented:
- Java supports Abstraction, Polymorphism, Encapsulation, Inheritance, and user-defined types which are all concepts of objects.
- Robust:
- Java is a robust and reliable programming language.
- It has strict compile-time and run-time checking for data types, which makes Java programs fault-tolerant.
- It prevents errors and handles exceptions.
- Platform Independent:
- The concept of “write once, run anywhere” (WORA) is an important feature of Java.
- Secure:
- Java provides protection by restricting applets' access to the execution environment and preventing access to other parts of the computer.
- This helps to eliminate damage due to malicious software or viruses.
- Case Sensitive:
- In Java, uppercase and lowercase letters are treated differently, making it a case-sensitive language.
- Both Compiled and Interpreted:
- Java uses both a compiler and an interpreter.
- The Java compiler converts Java source code into byte code.
- The Java interpreter converts this byte code into object code.
- Source Code:
- The file created in a high-level language is saved with the extension ".java".
- Byte Code; An intermediate code generated by the Java compiler after compilation. Byte codes are not executable
- Java Applets:
- Definition: A special kind of Java program (small programs) that is designed to be transmitted over the internet and automatically executed by a Java-compatible web browser.
- Execution: An applet is downloaded on demand by software without further interaction with the user.
- The applet is automatically downloaded and run when the user clicks a link containing it.
Java Virtual Machine (JVM)
- Role: The JVM is the interpreter that runs Java programs.
- Platform Independence: It can be installed on several different types of operating systems (e.g., Windows).
- Functionality: JVM processes instructions in the same way a physical processor does; therefore, it is called a virtual machine.
Java Development Kit (JDK)
- Definition: An abbreviation for Java Development Kit.
- Contents: A bundle of software development tools and supporting libraries combined with the Java Runtime Environment (JRE) and Java Virtual Machine (JVM).