Comparative Programming: 1082335

Introduction

The problem at hand was to create a text-based program for storing data of a Hotel Room Bookings.

The program was to be able to allow the user to add guests, add rooms, add bookings and to allow the user to view both the guests’ bookings and the rooms bookings respectively. The program was to be implemented in Python, Java, and Lisp.

After implementing the application in each language notes were to be kept on the following (but not limited to that):

  • The characteristics of the languages employed,
    • Peculiarities discovered valuable, and
    • Any concerns or dilemmas which arose due to the complexity or reduction of any language characteristics.

Discussions on each language used 

1. Python

Python is a high level objected oriented programming language. The language emphasizes on clean code through strict indentation rules, (Downey, Wentworth,  Elkner & Meyers, 2016 ). All code needed to be indented for the code to run.

In python, the data type of variables need not be specified at declaration time. A single variable can store string, integers, floats, arrays, dictionaries and even objects without being explicitly declared to be of the type, (Salvatier, Wiecki, & Fonnesbeck , 2016). This implies the fact that Python is an untyped language. It is also interpreted language.

Python supports data types such as lists, integers, strings, dictionaries, and objects. It supports both functional and object-oriented programming paradigms. The language also possesses many builtin functions and packages for performing common tasks.

In this project, Python lists and list operations were used extensively. The lists objects were used for storing the data for the program and also temporary data to be used by operations. The dictionaries were used for storing details about a single object such as a room and then the whole details stored in a list. Python functions (both in-built and custom declared) were also extensively used to implement the program. Decision and control structures of the python language such as while and for loops, and if statements were also implemented in the program.

The language features which proved useful include :

  • lists and dictionaries for data storage
  • builtin functions for data manipulation such as range,len
  • user-defined functions
  • control structures

2. LISP

LISP(List Processing) programming language is an untyped language in which everything in a program is represented as a list, (Knott, 2017). You don’t have to declare the type of data a variable will hold at declaration time. Data can be expressed as numbers (integers, floating-point figures, and proportions), lists, conses, functions, characters, strings, symbols, packages, hash tables, and single-dimensional arrays.

Lisp is both an object-oriented language and a functional programming language. It is object-oriented in the discernment that: variables possess objects as their values, and two variables can be connected to the corresponding object; composite objects possess objects as their constituents; objects, slightly than locutions, have values and types, (Sauter,2017). It is also interpreted language (though it can be compiled).Lisp has many inbuilt functions for lists operations. However, unlike other programming languages, everything in Lisp is represented as a list. This includes variables, functions, decision structures, control structures, and even objects. This is referred to as symbolic expression or S-expression.

Lisp does not distinguish between program and data. They are syntactically equivalent. This means you can treat code as data, modifying it automatically perhaps. The features of Lisp used extensively include lists, variables, and functions. Decision structures and control structures of the language such as loop, loop for, if, when, do times, etc were implemented in the program.

The features of the language that proved useful in the implementation of the program are:

  • Lists for data storage
  • Builtin functions for list manipulation e.g list, car,
  • Decision structures especially cond and if
  • Looping structures such as loop
  • User-defined functions

Issues or complications which arose include having to put braces around every symbolic operation, using pre-fix notation in carrying out arithmetic and logical operations, and debugging issues.

Appending data to the end of a list is not as simple in Lisp. You have to carry out many operations compared to a language such as a python which you just use the append method of the list object.

3. Java

Java is a strongly typed language. This means you have to declare the type of data to be stored in a variable at declaration time. It is a general-purpose programming language, (Savitch,2017). The language is purely object-oriented.

Java functions are implemented as methods of objects. Data stored in variables can be integers, floating-point values, double, arrays, Boolean values, etc, (Balagurusamy,2019). The different data type cannot be assigned to a variable other than that declared.

The language features implemented in this program includes variable declaration and assignment, class declaration and implementation, objects declaration and implementation and control and decision structures such as while, for, if and case.

The language features which proved useful includes:

  • Arrays and objects for data storage
  • Control structures such as if, while, for, and case statements
  • Built-in functions such as those for getting input and output

Issues or complications which arose include searching items in objects and arrays, having to remember to assign the right data type to variables, and a large codebase. Adding objects to arrays is also not as easier as appending to lists in Python.

Comparative Analysis

FEATURESJAVAPYTHONLISP
data-typesKnown at variable declarationNeed not be specifiedNeed not be specified
functionsSpecify return type,and parameters typeType declaration not  neededDeclared as a list
Easy of using decision and control structuresmoderateeasyhard
Objected orientedPure object-orientedBoth object-oriented and functionalBoth object-oriented and functional
Code basemoderateleastmore
Ease of usemoderateeasierhard
Ease of debuggingmoderateeasierhard
Ease of implementationmoderateeasierhard
Code readabilitybetterbestgood
Ease of manipulating data structuresgoodbestbetter
Syntax simplicitybetterbestgood
Mode of handling arithmetic and logical operationsInfinix notationInfinix notationPre-fix notation
Exception handlingbetterbestworse
    

Conclusion

A comparative overview of the languages has highlighted that they are suitable or not suitable for creating different kinds of applications. The languages have different capabilities which can be utilized in different use cases.

References

Balagurusamy, E. (2019). Programming with JAVA (Vol. 6). McGraw-Hill Education.

Downey, A., Wentworth, P., Elkner, J., & Meyers, C. (2016). How To Think Like A Computer Scientist: Learning with Python 3.

Knott, G. D. (2017). LISP. In Interpreting LISP (pp. 1-1). Apress, Berkeley, CA.

Salvatier, J., Wiecki, T. V., & Fonnesbeck, C. (2016). Probabilistic programming in Python using PyMC3. PeerJ Computer Science, 2, e55.

Sauter, J. (2017). A Brief Study of Prolog for Writing Context Free Grammars and a Comparison of the Language with Lisp.

Savitch, W. (2017). Java: An Introduction to Problem Solving and Programming, Student Value Edition Plus MyProgrammingLab with Pearson eText-Access Card Package. Pearson.