A comparison of functional and object-orientedprogramming paradigms in JavaScript

University essay from Blekinge Tekniska Högskola/Institutionen för programvaruteknik

Abstract: There are multiple programming paradigms that have their own set rules forhow code should be written. Programming languages utilize one or multiple ofthese paradigms. In this thesis, we will compare object-oriented programming,that is the most used today with languages such as C++ and Java, and functionalprogramming. Functional programming was introduced in the 1950's butsuered from performance issues, and has not been used much except for in theacademic world. However, for its ability to handle concurrency and big data,functional programming is of interest in the industry again with languages suchas Scala. In functional programming side effects, any interaction outside of thefunction, are avoided as well as changing and saving state. To compare these paradigms we have chosen four dierent algorithms, whichboth of us have implemented twice, once according to object-oriented programmingand once according to functional programming. All algorithms were implementedJavaScript. JavaScript is a multiparadigm language that supportsboth functional and object-oriented programming. For all implementations,we have measured development time, lines of code, execution time and memoryusage. Our results show that object-oriented programming gave us betterperformance, but functional programming resulted in less code and a shorterdevelopment time.

  AT THIS PAGE YOU CAN DOWNLOAD THE WHOLE ESSAY. (follow the link to the next page)