You are on page 1of 12

CHAPTER 10

Recent Trends in Programming


TABLE OF CONTENTS

10 Recent Trends in Programming 1


10.1 Introduction to Object Oriented Programming (OOP) . . . . . . . . . 1
10.2 Definitions of Class, Method and Object in OOP . . . . . . . . . . . 4
10.3 Difference between Procedure Oriented and OOP . . . . . . . . . . . 5
10.4 Overview of other High Level Programming Languages . . . . . . . . 5

i
Chapter 10

Recent Trends in Programming

10.1 Introduction to Object Oriented Programming


(OOP)

Object-Oriented Programming (OOP) is a programming paradigm that uses objects


– which are instances of classes – to design and organize code. It is based on several
fundamental principles that promote code organization, reusability, and maintainabil-
ity. OOP is widely used in software development due to its ability to model real-world
entities and relationships in a more intuitive and structured manner.

Key Concepts of OOP:

1. Classes and Objects:

• Class: A blueprint or template that defines the properties (attributes) and


behaviors (methods) common to all objects of a certain type.

• Object: An instance of a class. Objects have specific values for their


attributes and can perform actions through their methods.

2. Encapsulation:

• Encapsulation involves bundling the data (attributes) and methods that


operate on the data into a single unit called a class. This unit restricts
access to some of the object’s components, protecting the integrity of the
data.
2

3. Abstraction:

• Abstraction is the process of simplifying complex systems by modeling


classes based on the essential properties and behaviors relevant to the
problem at hand. It hides the complex reality while exposing only the
necessary details.

4. Inheritance:

• Inheritance allows a class (subclass or derived class) to inherit properties


and behaviors from another class (superclass or base class). It promotes
code reuse and establishes a hierarchy of classes.

5. Polymorphism:

• Polymorphism allows objects of different classes to be treated as objects


of a common base class. It enables the same method name to be used for
different types of objects, enhancing flexibility and extensibility.

Basic OOP Concepts Explained:


Example of a class and an object in OOP:
#include< iostream >
using namespace std;
// Class declaration
class Car {
public:
// Attributes
string brand;
string model;
// Method to display information about the car
void displayInfo() {
cout << ”Car: ” << brand << ” ” << model << endl;
}
};

int main() {
// Object instantiation

© iamsspoudel
3

Car myCar;
// Assign values to the object’s attributes
myCar.brand = ”Toyota”;
myCar.model = ”Camry”;
// Call the method to display information about the car
myCar.displayInfo();
return 0;
}
In this example:

• The ‘Car‘ class has two attributes (‘brand‘ and ‘model‘) and a method (‘dis-
playInfo‘) that displays information about the car.

• In the ‘main‘ function, an object of the ‘Car‘ class is instantiated as ‘myCar‘.

• Values are assigned to the ‘brand‘ and ‘model‘ attributes of the ‘myCar‘ object.

• The ‘displayInfo‘ method is called to print information about the car.

Output
Car: Toyota Camry

Benefits of OOP:

1. Modularity: OOP promotes modular code, making it easier to understand,


maintain, and update.

2. Reusability: Code reuse is facilitated through the creation of classes and inher-
itance, reducing redundancy.

3. Flexibility and Extensibility: Polymorphism allows for flexibility in code design,


and new functionality can be added without modifying existing code.

4. Improved Code Organization: OOP mirrors real-world entities, making the code
more intuitive and closely aligned with problem domains.

OOP is employed in languages like Python, Java, C++, and many others. It provides
a powerful and flexible approach to software development, enabling developers to
create scalable and maintainable applications.

© iamsspoudel
4

10.2 Definitions of Class, Method and Object in


OOP
1. Class

• Definition: A class is a blueprint or template for creating objects. It defines


a data type, including attributes (data members) and methods (functions),
which represent the properties and behaviors common to all objects of that
type.

• Purpose: Classes provide a way to structure and model the properties and
behaviors of real-world entities or abstract concepts in a software system.

2. Method

• Definition: A method, also known as a member function, is a set of in-


structions or operations associated with a class. It represents the behavior
of objects created from that class. Methods can operate on the class’s
attributes and perform various actions.

• Purpose: Methods encapsulate functionality within a class, promoting


modularity and code organization. They define what an object of the
class can do.

3. Object

• Definition: An object is an instance of a class. It is a runtime entity with


a unique identity, state (attributes), and behavior (methods). Objects are
created based on the blueprint provided by the class.

• Purpose: Objects represent tangible or abstract entities in a software sys-


tem. They encapsulate data and functionality, allowing the modeling of
real-world scenarios and interactions.

In summary, a class serves as a blueprint for creating objects, defining their attributes
and behaviors. Methods are the functions associated with a class, specifying the
operations that objects of that class can perform. Objects are instances of classes,
embodying the properties and behaviors defined by the class. Together, these concepts
enable the principles of encapsulation, abstraction, inheritance, and polymorphism in
Object-Oriented Programming.

© iamsspoudel
5

10.3 Difference between Procedure Oriented and


OOP

Feature Procedure Oriented Pro- Object-Oriented Program-


gramming (POP) ming (OOP)
Focus Emphasis on procedures (func- Emphasis on objects
tions)
Program Structure Linear structure Structure revolves around objects
and classes
Data Handling Functions operate on data Objects encapsulate data and be-
havior
Code Organization Code is organized around func- Code is organized around objects
tions and classes
Reusability Limited code reuse Encourages code reuse through
classes and inheritance
Encapsulation Limited or no encapsulation Encapsulation bundles data and
methods within a class
Abstraction Limited abstraction Promotes abstraction for model-
ing real-world entities
Inheritance No concept of inheritance Supports inheritance for code
reuse and hierarchy
Polymorphism Limited or no polymorphism Supports polymorphism for flexi-
bility and extensibility
Maintenance Code maintenance can be chal- Easier maintenance due to encap-
lenging sulation and abstraction
Examples C, Pascal, Fortran Java, C++, Python, Ruby, etc.

10.4 Overview of other High Level Programming


Languages

1. Python: Continues to be a popular language due to its readability, versatility,


and extensive libraries.

© iamsspoudel
6

2. JavaScript: Essential for web development, and its popularity extends to server-
side development.

3. Java: Remains relevant in enterprise-level applications and Android develop-


ment.

4. C#: Used in game development (Unity), Windows applications, and backend


services.

5. TypeScript: Growing popularity due to its static typing for JavaScript.

6. Rust: Gaining traction for systems programming, known for memory safety and
performance.

7. Go (Golang): Notable for its simplicity, efficiency, and concurrency support.

Trends:
1. Machine Learning and AI: Python is widely used for machine learning, and
languages like Julia and R are gaining popularity.

2. WebAssembly (Wasm): Allows running code written in high-level languages on


web browsers with near-native performance.

3. Serverless Computing: Languages like Python, Node.js, and Go are popular


choices for serverless architectures.

4. Blockchain Development: Smart contract languages like Solidity for Ethereum,


and languages like Rust for blockchain development.

An overview of some high-level programming languages, highlighting their


key characteristics and use cases:

1. Python:
Key Features:

• Easy-to-read syntax and readability.

• Extensive standard library.

• Dynamic typing and automatic memory management.

© iamsspoudel
7

• Versatile, used in web development, data science, artificial intelligence,


automation, and more.

Use Cases:

• Web development (Django, Flask).

• Data science and machine learning.

• Automation and scripting.

• Network programming.

2. JavaScript:
Key Features:

• Primarily used for front-end web development.

• Asynchronous and event-driven.

• Supports both object-oriented and functional programming.

Use Cases:

• Front-end web development.

• Server-side development (Node.js).

• Cross-platform mobile app development (React Native).

3. Java:
Key Features:

• Platform independence (Write Once, Run Anywhere).

• Object-oriented, class-based language.

• Strongly typed and statically compiled.

Use Cases:

• Enterprise-level applications.

• Android app development.

• Web development (Java Spring).

4. C#:
Key Features:

© iamsspoudel
8

• Developed by Microsoft.

• Object-oriented and component-oriented.

• Common Language Infrastructure (CLI) support.

Use Cases:

• Windows desktop applications.

• Web development (ASP.NET).

• Game development (Unity).

5. C++:
Key Features:

• Extension of C with object-oriented features.

• Low-level and high-level programming capabilities.

• Efficient and widely used in systems programming.

Use Cases:

• Systems programming.

• Game development.

• Embedded systems.

6. Ruby:
Key Features:

• Dynamic, object-oriented scripting language.

• Focus on simplicity and productivity.

• Elegant syntax.

Use Cases:

• Web development (Ruby on Rails).

• Scripting and automation.

7. TypeScript:
Key Features:

© iamsspoudel
9

• Superset of JavaScript with static typing.

• Improved tooling for large-scale applications.

• Compiles to plain JavaScript.

Use Cases:

• Large-scale web applications.

• Front-end development.

8. Go (Golang):
Key Features:

• Developed by Google.

• Concurrency support.

• Compiled language with fast execution.

Use Cases:

• Cloud-based services.

• Network programming.

• Containerization (Docker).

9. Rust:
Key Features:

• Focus on safety, performance, and concurrency.

• Memory safety without garbage collection.

• Ownership system prevents data races.

Use Cases:

• Systems programming.

• Game development.

• WebAssembly.

10. Swift:
Key Features:

© iamsspoudel
10

• Developed by Apple.

• Designed for iOS, macOS, watchOS, and tvOS development.

• Safety-oriented with modern syntax.

Use Cases:

• iOS and macOS app development.

• Server-side development (Vapor).

© iamsspoudel

You might also like