Are there any higher abstraction libraries for C which helps doing basic stuff very easily without really worrying about memory/ pointers/ etc.
Ex: Python provides very higher abstraction than C. It can be concatenating strings, arrays etc. Simply, we got any lib in C which takes care of that job?
A library is a kind of abstraction: you don't have to know any of the details of how it's coded.
Abstraction means displaying only essential information and hiding the details. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.
Yes. C has the base Data types , and C structs and typedefs allow the full range of data abstraction that other languages allow.
There are only a few purposes for programming in C. The main ones that come to mind are:
You need a language that has a concept of storage duration, whereby you can write bounded-space or in-place algorithms that use memory that's already been obtained, and thereby have absolutely no failure cases.
You want to take advantage of the code-size or performance advantages of C idioms that either aren't idiomatic or aren't expressible in other languages. Again, most of these end up having to do with working with data in-place rather than moving it through intermediate data structures or wrapping it in abstract containers.
If you don't have such needs or don't even know what they mean, you might consider whether you should really be using C. Bringing inefficient idioms like string concatenation, abstract container classes, or lazy memory management with you from other languages to C will negate most/all of the possible benefits of using C while offering you few or none of the benefits of a higher-level language.
Not worrying about pointers is pretty tricky, as someone has to clean up the mess eventually, and C has neither a garbage collector nor destructors when stuff goes out of scope.
char*
, so you can't really avoid the pointers here. You can of course do a typedef char* string
and use that name instead.One important question you might want to ask yourself: why do you want to stick with C, if you intend to use features already provided by other languages like C++? Perhaps your requriements can also be met by some mixed-language programming, where you write part of your application in C++ and either keep existing code in C, or do library calls using the C calling convention. That way, you can write new code at a high level and still use good old C where it is appropriate.
Noone is forcing you to use a specific coding style just because you are using C++. It is perfectly all right to write a program which mostly looks like a C program and still uses the features and data types of C++ where you need them. You don't have to write object oriented stuff yourself, you can stick to simple functions calling one another, in the standard imperative paradigm. But it's still nice to know that you can use objects in those situations where they help make your code easier to write, read and maintain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With