THE JAVASCRIPT FUNCTIONAL FEATURES AND RELATED ISSUES - Наукові конференції

Вас вітає Інтернет конференція!

Вітаємо на нашому сайті

Рік заснування видання - 2011

THE JAVASCRIPT FUNCTIONAL FEATURES AND RELATED ISSUES

19.09.2023 18:35

[1. Інформаційні системи і технології]

Автор: Oleksii Hlazok, c.t.s, associate prof., National aviation university, Kyiv, Ukraine; Natalia Khalimon, c.t.s, associate prof., National aviation university, Kyiv, Ukraine


ORCID: 0000-0002-1888-8779 Olexiy Glazok

ORCID: 0000-0002-7159-6740 Natalia Khalimon


The popularity of the Javascript programming language for server-side programming has increased tremendously over the past decade. With the spread and growing popularity of various Javascript-based frameworks, such as Node.js, JavaScript has become the most popular languages for web-programming, with its focus shifted from client-side web development towards server-side and general-purpose applications, such as databases, desktop, mobile or IoT applications. During its evolution, Javascript absorbed some essential concepts of the functional programming paradigm. Here is a short list of functional features in Javascript:

1. Functions in JavaScript are first-class objects. They may be treated in the same way as any other objects. Functions in JavaScript can be values of variables, passed as arguments to other functions, and behave like any other objects in the language.

2. In JavaScript, objects can be used to create data structures similar to lists or arrays. They provide the ability to store data and access data using keys. However, using traditional-style arrays formed using square brackets is a more common and convenient way to work with sequences of elements in JavaScript.

3. Currying is a functional programming technique that allows you to convert a function with several arguments into a sequence of functions with one argument. Currying allows you to partially (sequentially) apply arguments and create new functions based on the original function. This can be useful in many situations, including function composition and creating reusable functions.

4. Anonymous functions in JavaScript can be created without declaration and assignment to a variable. Anonymous functions are often used as arguments to other functions or to create functions on the fly. Anonymous functions are widely used in JavaScript for event handling, callbacks, asynchronous operations, and other programming scenarios.

5. Closures allow functions to retain access to external scope variables, even after the execution of that scope has finished. Closures occur when a function is defined within another function and has access to the variables of that outer function. Closures allow you to create private variables, create functions with fixed contexts, and save function state between calls. They are often used in functional programming, event handling, asynchronous code, and other scenarios where you need to store state and access variables.

6. Objects introspection. In JavaScript, there is an opportunity to inspect the internal structure of objects in runtime, obtaining information about their types, properties and methods. Various methods and properties can be used for this, such as typeof, instanceof, Object.keys(), Object.getOwnPropertyNames(), Object.getPrototypeOf(), Object.hasOwnProperty() etc.

7. Mechanism of prototypes and dynamic type change. In JavaScript, every object has a prototype that defines the set of properties and methods available to that object. When a property or a method is not found directly on an object, JavaScript automatically looks for it in that object's prototype, as well as in the prototype's prototype, forming a prototype chain. This mechanism allows you to dynamically change the type of objects, add or change the properties and methods of an object or one of its generating prototypes. This mechanism also allows you to use the concept of classes and inheritance by creating objects with a specific prototype using the "new" keyword and a constructor function. With these capabilities, JavaScript provides flexibility and the ability to dynamically change objects, and provides powerful mechanisms for prototyping, inheritance, and polymorphism.

Additional features that must be considered in connection with the functional aspects of Javascript programming are: exception handling, including the ability to access the exception object whose properties contain information about the error that occurred; automatic type coercion, which occurs when performing operations between values of different types: arrow functions, which is a syntactic abbreviation for defining functions.

Important issues in any kind of programming are code verification, code testing and ensuring its performance. Javascript developers use in practice static and runtime verification, as well as conformance testing (e.g. Test262 – the official ECMAScript Conformance Test Suite). Modern testing frameworks allow, for example, to generate monitors that allow to observe all runtime values and events that are required in order to verify the correctness of the application behaviour [1].

Functionally aware Javascript code requires adaptation of the test frameworks and testing methods, since the approach to code execution in the functional paradigm is significantly different from the imperative one. An expedient approach may be the so-called Concolic testing, or dynamic symbolic execution [2, 3], which is a hybrid software verification technique that performs symbolic execution, treating program variables as symbolic variables, along with a "concrete" testing performed on particular inputs. This would allow to trace possible problems with allocation and memory leaks. The use of functional paradigm in Javascript can also affect the performance of the application, which can significantly depend on the way functions are interpreted and processed, as well as data types [4].

Література

1. NodeMOP: Runtime Verification for Node.js Applications /Schiavio F., Sun H., Bonetta D., Rosa A., Binder W. // The 34th ACM/SIGAPP Symposium on Applied Computing (SAC 19), April 2019: Proceedings. – Pages 1794-1801. DOI 10.1145/3297280.3297456. 

2. Li Zhe, Xie Fei. Concolic Testing of Front-end JavaScript. //Fundamental Approaches to Software Engineering (FASE 2023) 26th Int. Conf., Paris, France, April 22–27, 2023: Proceedings. –  Pages 67-87. DOI 10.1007/978-3-031-30826-0_4. 

3. Li Zhe, Xie Fei. In-Situ Concolic Testing of JavaScript. // 2023 IEEE Int. Conf. on Software Analysis, Evolution and Reengineering (SANER), March 2023: Proceedings.– Pages 236-247. DOI  10.1109/SANER56733.2023.00031. 

4. Improving JavaScript performance by deconstructing the type system /W. Ahn, J. Choi, T. Shull, M. J. Garzarán, J. Torrellas. // The 35th ACM SIGPLAN Conf. on Programming Language Design and Implementation (PLDI '14): Proceedings. – June 2014. – Pages 496–507. DOI 10.1145/2594291.2594332. 

Creative Commons Attribution Ця робота ліцензується відповідно до Creative Commons Attribution 4.0 International License
допомога Знайшли помилку? Виділіть помилковий текст мишкою і натисніть Ctrl + Enter
Конференції

Конференції 2024

Конференції 2023

Конференції 2022

Конференції 2021



Міжнародна інтернет-конференція з економіки, інформаційних систем і технологій, психології та педагогіки

Наукова спільнота - інтернет конференції

:: LEX-LINE :: Юридична лінія

Інформаційне суспільство: технологічні, економічні та технічні аспекти становлення