Back-end code is the one that communicates with the front-end sending and receiving messages that have to be interprete and display on the web page. Further to this, there are 2 kinds of websites- static and dynamic. A static web page is the one who’s contents do not change much and a dynamic web application is one whose contents change according to the data present in its database and can be customize. Every website needs a database that manages and stores all the information. The many databases in the market are Oracle SQL, MySQL, PostgresSQL and SQLServer. Some of the back end programming languages used to create dynamic websites are C, C++, Java, Ruby, PHP, .Net and Python.
List of Back-end Programming Languages
Here let us go through some of these languages and get a basic idea on how to use them:
1. Java for Back-end
Java is a general-purpose, object-oriented and concurrent programming language developed by Sun Microsystems in 1995. It uses an engine called JVM (Java Virtual Machine) which provides a runtime environment to run the Java Code and its applications. It translates Java byte code into a language that can be interprete by machines. JVM forms a part of JRE (Java Runtime Environment).
Java has certain key features as follows:
- Object-oriented– This means the code is structure and model as a set of objects which can be manipulate, control, and easily extend.
- Basic– Java language is very basic and simple to master once you have understood the concept of OOP (Object Oriented Programming)
- Platform independent– Java does not depend on any specific platform because, during compilation, it is compile to an independent bytecode format which can be distribute and translate by JVM on any platform.
- Robust– Java has good Memory management and Exception handling which makes it minimize error-prone code.
- Multi-Threading– Java can run multiple tasks concurrently due to this feature which helps save a lot of memory.
Example
Let us get to know how to write a basic program in Java:
public class JavaFirstProgram {
public static void main(String []args) {
System.out.println(“Hello World”); // outputs Hello World to console output
System.out.println(“First program in Java”);
}
}
2. Ruby
Ruby is a programming language coded by Yukihiro Matsumoto during the mid-1990s. It is an open-source, object-oriented, dynamic and reflective language. Like Java, it is platform-independent and hence can run on Windows, Mac, and all Unix versions. Ruby follows a principle called POLA (Principle Of Least Astonishment) which means that the language reduces the confusion for experienced users.
Some of the features of Ruby are:
- Object-oriented– This means everything in Ruby is express in the form of objects. Every object will have a class and each class will be having a superclass. All the rules written for objects applies for entire Ruby.
- Flexibility– In Ruby we can add, remove and customize parts easily. Existing parts can be modify and there are no such restrictions as such.
- Dynamic typing– Programs in Ruby are not compile as such. A variable can hold all types of objects. Ruby looks up a method name when it is call, regardless of the object type.
- Mixin– One of the unique features of Ruby is that it has a single inheritance only. It mainly operates on modules that don’t have many instances. Alternatively, a module can be unite with class.
- Hashing– It is one of the collection types of key-value pairs separate by commas.
- Open– This means Ruby classes and methods can be end with a question and exclamation marks.
- Persistence– In case of missing method, Ruby calls the same with its name with which it could not locate its arguments.
Example
For the following programs, open any editor and save the file in .rb format.
- We can output any sentence with “puts” keyword as follows:
puts “Hello example in Ruby”
- Simple mathematics can be perform in Ruby as below:
# Arithmetic operator examples for: +, -, /, *
puts 4 * 5
# Example for finding the exponent of 4 to the power of 2
puts 4**2
# To find modulus and retrieves the remainder of 4
puts 13 % 4
# Example for the order of the given operations
puts 3 + 5 * 8
# Performing operation on integer and floating-point numbers
puts 10 / 3.0
- The variable types need not be mention here since Ruby identifies it automatically:
distance = 0.4
#We shall use integer and float type both
time = 8.65 / 3600
speed = distance / time
puts “The average speed of the car is #{speed} km/h”
3. Python
Python is an open-source, object-orient, and interactive programming language that was name after a television show call “Monty Python’s Flying Circus” by Guido van Rossum in 1991. It is an interpreted language which means there is no compilation require to run it.
Some of its key features are:
- Dynamic typing– The variable data type need not be declare explicitly as they are allot in run-time.
- Extensive and integrable– Other languages like C and C++ can be unified with Python. It is call to be extensible.
- High-Level– This enables its users to focus on the problem-solution than worrying about the system architecture or memory management.
- Interpreted– Python code execution takes place line by line and since there is no need for compilation, it is easy to debug.
- Extensive Standard Library– There are many built-in modules and functions in its library hence reducing the coding effort. Also, a lot of libraries are present such as regular expressions, web browsers, testing, etc.
- Expressive– Python is easier to understand and read hence helps to focus on the solutions than on syntax.
- GUI Support– Graphical User Interface can be develop using Python.
Examples :
Let us go through some of the basic coding examples in Python.
- The print command is use for printing the output as follows :
print(“Hello World Example for Python”)
- Defining variables can be written as below :
number = 25 # Assigning an integer
decimal = 33.3 # Assigning a floating number
string = “Any Name” # A string
common1 = common2 = 10 # Common Assigning of values
print number, “\n”
print decimal, “\n”
print string, “\n”
print common1, “\n”
print common2, “\n”
- A simple for loop is as follows:
animals = [“cats”, “dogs”, “cows”, “monkeys”] for i in animals:
print(i)
if i == “cows”:
break
Read also about The Beginner’s Guide to Python Back-End Development
4. PHP for Back-end
“PHP: Hypertext Preprocessor” which previously stood for “Personal Home Page” is another open-source scripting language used in the server-side. It is very popular being use in various big giants like WordPress and Facebook. PHP language can only be interprete by the server having PHP install. Its file ends with an extension “.php”. Compared to other languages PHP is consider a stable language.
PHP has some unique features as follows:
- It can be integrate with other databases like Oracle, MySQL, Sybase, PostgreSQL, Microsoft SQL Server, and Informix.
- It has extensive libraries for using various modules and for data representation.
- It is again an interpreted language and also platform-independent
- In PHP all the keywords, methods, classes and user-defined functions are not case-sensitive and are only case-sensitive when a variable is declare.
- PHP generates dynamic content.
- It has a built-in error reporting system thus helps to generate a warning/error notice.
- It creates a summary of the latest accesses for the user by providing real-time access logging.
- There is no need to declare a data type in PHP as the data type will be retrieve during execution based on the value of the variable. Hence called a loosely typed language.
Examples
- Below is the example for declaring and displaying variables in PHP:
<?php
$x = “This is a sentence!”; //Assigning a sentence
echo $x;
echo “<br/>”;
$str=”String Example”;
$x=30;
$y=22.2;
echo “String value is: $str <br/>”;
echo “Integer value is: $x <br/>”;
echo “Float value is: $y <br/>”;
?>
- A basic for loop example can be written as follows:
<?php
for($i=10;$i>=2;$i — ){
echo “$i <br/>”;
}
?>
In this blog, we hope you have got a better picture of some of the most popular and widely used back-end programming languages. Based on the explanation shown for all, it is up to you to decide the language you choose according to your business requirements.
This does not mean that these are the only 4 languages out there. Day by day, lot of new scripting language are emerging which can also be include in your project. Thus, a back-end developer should identify the goals first and integration requirements before choosing a programming language.