OBJECT ORIENTED PARADIGM IMPLEMENTATION IN C PROGRAMMING LANGUAGE

Authors

DOI:

https://doi.org/10.32782/tnv-tech.2023.5.8

Keywords:

OOP, C, translation, exception, error handling, interface, polymorphism, virtual method table, ABI, API stability.

Abstract

C programming language allows to create application and libraries that could be used on almost any relevant hardware platform. It could be x86-compatible desktop processor, MIPS in PlayStation One, ARM chip in a smartphone or a POWER-10 on some big server. Compiler for this language is often created sooner then the platform itself becomes available as a piece of hardware. Language simplicity with a relatively small amount of key words and included functionality allows to implement a basic C compiler quite easy. This language bring a noticeable simplification to the code. It is often used when the interaction with hardware is required, but in a very specific way. Other contender for this role is assembly for concrete platform, but it lacks such concepts as function, type, struct of cycle. Assembly program is basically a plain list of instructions and some of the have labels that allow jumping to it. And code written in C could be compiled for different architecture, while code in assembly has to be rewritten for other platform. However, while C code is easier then assembler, it is still more difficult then, Python, for example. Code has to be organized in functions, there are no namespaces, memory management is manual, no error handling mechanism, etc. Meanwhile there are various high level languages, that have all these features and allow programmer to concentrate on ideas and concepts of concrete field and not think about low-level stuff. All these feature come with a price. It could be either interpreter, virtual machine, like CLR for C#, or various system components that should be present in order for such application to work. Sometimes infrastructure is tied to concrete hardware of software platform and could not be used in other places. Like microcontrollers, for example. It also makes it more difficult to integrate components from various technologies together. To call Python library from C#, developer has to create a C wrapper that will interact with the Python interpreter and marshall the data between Python Interpreter and CLR. It is also true with C++ and Java, for example. One have to write a wrapper that will interact with a JVM to use Java component from C++ instead of just calling a method or a function. It is possible to have advantages of C code that works quite fast and almost everywhere (with recompilation, of course), but to write much simpler code that looks more familiar to a developer that works with a higher level language. One could use two-level compilation. First stage is to compile the source language to C representation and then, use C compiler to generate native binary. Such languages are already exist (Vala, V, Zig) and each of them have unique way of generating C code and own runtime library, necessary to provide primitives. Some of them could be easily ported to other architectures (like in Zig) and some not (GObject in Vala, which depends on Glib, not to confuse with Glibc). Sometimes it is easier to integrate them in other application and sometimes no. This articles describe OOP library for C language that allows code generation from higher level language and allows to have common way of working with virtual tables for polymorphic objects, type system, error handling, which have no dependencies other then C standard library and allows easy integration into other components that could call a C entry point.

References

Deborah J. Armstrong. The quarks of object-oriented development. Communications of the ACM. 2006. Vol. 49. № 2. p. 123–128.

Brian W. Kernighan, Dennis M. Ritchie. C Programming Language. Second edition. London, 1988. 272 p.

Rabinowitz Henry, Schaap Chaim. Portable C. Hoboken, 1990. 269 p.

Manuel Costanzo and others. Performance vs Programming Effort between Rust and C on Multicore Architectures: Case Study in N-Body. Arxiv. 2021. Vol 2107. Article 11912.

Booch, G. Object Oriented Analysis and Design with Applications. Boston, 1994. 608 p.

Iqbaldeep Kaur and others. Research paper on object oriented software engineering. International journal of computer science and technology. 2016. Vol. 7, Issue 4. p. 36–38.

H. Hourani, H. Wasmi, T. Alrawashdeh. A Code Complexity Model of Object Oriented Programming (OOP). IEEE Jordan International Joint Conference on Electrical Engineering and Information Technology (JEEIT). Amman, Jordan, 2019, p. 560–564.

Репозиторій коду бібліотеки GLib. URL: https://github.com/GNOME/glib/tree/main/glib. (дата звернення: 13.12.2023).

Репозиторій коду ядра Linux. URL: https://github.com/torvalds/linux. (дата звернення 13.12.2023).

Репозиторії із стандартами C++. URL: https://github.com/cplusplus/draft (дата звернення 13.12.2023).

Репозиторій транслятора мови Vala. URL: https://gitlab.gnome.org/GNOME/vala (дата звернення 13.12.2023).

Репозиторій реалізованої бібліотеки. URL: https://github.com/FlaviusHouk/Obj (дата звернення 13.12.2023).

Published

2024-01-11

How to Cite

Стовманенко, В. О. (2024). OBJECT ORIENTED PARADIGM IMPLEMENTATION IN C PROGRAMMING LANGUAGE. Таuridа Scientific Herald. Series: Technical Sciences, (5), 73-84. https://doi.org/10.32782/tnv-tech.2023.5.8

Issue

Section

COMPUTER SCIENCE AND INFORMATION TECHNOLOGY