Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.


LPI Linux Essentials Exam 010-160 - Topic 1.2 - Development/Programming Languages

Programming languages offer a way for humans to communicate with computers. They serve as a bridge between human input and the binary code that computers operate on. These languages enable developers to write instructions, or code, that computers can execute to perform a wide range of tasks. Programming languages vary in their structure, syntax, purpose, and type, which this guide will explain in more detail.

Programming Types

Procedural Programming Languages

Procedural programming languages follow a linear or sequential approach to solving problems. They emphasize breaking down a problem into smaller, reusable procedures or functions. Key examples include C and Pascal. In procedural languages, code is organized into procedures or functions that manipulate data step by step.

Object-Oriented Programming (OOP) Languages

Object-oriented programming languages are designed around the concept of objects, which are instances of classes. These objects encapsulate both data (attributes) and the methods (functions) that operate on that data. OOP promotes concepts such as encapsulation, inheritance, and polymorphism. Notable OOP languages include Java, C++, and Python.

Compiled Languages

Compiled languages require a compiler to translate the entire source code into machine code or an intermediate code before execution. Compilation typically results in faster execution because the code is optimized for a specific platform. Common compiled languages include C, C++, java and Rust.

Interpreted Languages

Interpreted languages, on the other hand, are executed line by line by an interpreter at runtime. They are platform-independent and often easier to work with during development. Popular interpreted languages include Python, Perl, PHP, JavaScript, Shell and Ruby. Interpreted languages are generally slower than compiled ones due to the interpretation process.

Scripting Languages

Scripting languages are a subset of interpreted languages that are often used for automating tasks, writing scripts, and web development. They are lightweight and flexible, making them ideal for rapid development.

Each type of programming language has its own strengths and weaknesses, making them suitable for different types of projects and problem-solving approaches. The choice of language depends on factors such as the project's requirements, performance considerations, developer preferences, and the specific domain of application.

Common Programming Languages

C

C is a high-level, general-purpose programming language created in the early 1970s by Dennis Ritchie at Bell Labs. It is known for its efficiency and close-to-the-hardware capabilities, making it popular for system programming, embedded systems, and low-level operations. C is a procedural language, which means it follows a step-by-step approach to problem-solving. It has influenced the development of many other programming languages and remains widely used in operating systems and software development where performance is critical.

Follow the exercise below to print Hello, World! using C:

Print Hello, World! using C:

gcc package must be installed.

Create a file called hello_world_c.c with the following contents:

#include <stdio.h>

int main() {
   printf("Hello, World!\n");
 return 0;
}

Compile the program:

gcc hello_world_c.c -o hello_world_c

Run the program which will print Hello, World! to screen:

./hello_world_c

Java

Java is a versatile, object-oriented programming language developed by Sun Microsystems (now owned by Oracle Corporation) in the mid-1990s. Java is known for its platform independence, which means Java code can run on different operating systems without modification. It's commonly used for web and mobile application development, enterprise software, and large-scale systems. Java emphasizes strong typing, automatic memory management (garbage collection), and a rich set of libraries and frameworks.

Follow the exercise below to print Hello, World! using java:

Print Hello, World! using java:

jdk package must be installed.

Create a file called hello_world_java.java with the following contents:

public class hello_world_java {
    public static void main(String[] args) {
       System.out.println("Hello, World!");
   }
}

Compile the program:

javac hello_world_java.java

Run the program which will print Hello, World! to screen:

java hello_world_java

JavaScript

JavaScript, often abbreviated as JS, is a dynamic, high-level, and interpreted scripting language primarily used for web development. It allows developers to create interactive and dynamic web pages by manipulating the Document Object Model (DOM) of web browsers. JavaScript is essential for front-end web development and can also be used on the server-side (Node.js) to build scalable, real-time applications.

Follow the exercise below to print Hello, World! using javascript:

Print Hello, World! using javascript:

nodejs package must be installed.

Create a file called hello_world.js with the following contents:

console.log("Hello, World!");

Run the program which will print Hello, World! to screen:

node hello_world.js

Perl

Perl is a versatile and highly expressive scripting language created by Larry Wall in the late 1980s. It is renowned for its text-processing capabilities, making it popular for tasks such as data extraction, report generation, and text manipulation. Perl is known for its "TIMTOWTDI" philosophy, which stands for "There's more than one way to do it," reflecting its flexibility and adaptability. It has been used extensively in system administration and web programming.

Follow the exercise below to print Hello, World! using perl:

Print Hello, World! using perl:

perl package must be installed.

Create a file called hello_world.pl with the following contents:

#!/usr/bin/perl

print "Hello, World!\n";

Give the script execute permissions:

chmod +x hello_world.pl

Run the script which will print Hello, World! to screen:

./hello_world.pl

Shell Scripting

Shell scripting refers to the use of shell (command-line) languages like bash, ksh, or sh to automate tasks and interact with an operating system. Shell scripts are essential for system administrators to perform tasks efficiently, manage files, and execute commands in a scripted manner. They are also crucial for writing deployment scripts and managing server environments.

Follow the exercise below to print Hello, World! using bash:

Print Hello, World! using bash:

Create a file called hello_world.sh with the following contents:

#!/usr/bin/bash

echo 'Hello, World!'

Give the script execute permissions:

chmod +x hello_world.sh

Run the script which will print Hello, World! to screen:

./hello_world.sh

Python

Python is a high-level, dynamically typed, and interpreted programming language known for its simplicity and readability. Created by Guido van Rossum in the late 1980s, Python has gained immense popularity in various domains, including web development, data analysis, scientific computing, artificial intelligence, and automation. Python's extensive standard library and third-party packages make it a versatile choice for a wide range of applications.

Follow the exercise below to print Hello, World! using python:

Print Hello, World! using python:

python3 package must be installed.

Create a file called hello_world.py with the following contents:

#!/usr/bin/python3

print("Hello, World!")

Give the script execute permissions:

chmod +x hello_world.py

Run the script which will print Hello, World! to screen:

./hello_world.py

PHP

PHP (Hypertext Preprocessor) is a server-side scripting language designed for web development. It is embedded within HTML code to create dynamic web pages. PHP is commonly used for building websites, web applications, and content management systems (CMS), such as WordPress. It offers features like database integration, session management, and support for various web protocols. PHP is easy to learn and deploy, making it a popular choice for web developers.

Follow the exercise below to print Hello, World! using PHP:

Print Hello, World! using PHP:

php package must be installed.

Create a file called hello_world.php with the following contents:

<?php
echo "Hello, World!\n";
?>

Run the script which will print Hello, World! to screen:

php hello_world.php

Each of these languages has its strengths and is suitable for specific use cases, making them valuable tools in the software development world. The choice of language depends on the project's requirements, the developer's expertise, and the desired functionality of the application.


Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.