18

C is an old language lacking many, many, many modern features. One of the features it does not lack is encapsulation and isolation.

top 8 comments
sorted by: hot top controversial new old
[-] Penguincoder@beehaw.org 6 points 1 year ago

C is an old language lacking many, many, many modern features. One of the features it does not lack is encapsulation and isolation.

[-] bl_r@beehaw.org 6 points 1 year ago

I have a love hate relationship with C. I love the simplicity of the language. Although it is simpler, it is certainly possible to emulate many features found in other languages like the encapsulation, though rarely perfectly, and not every feature.

I also like C because I am dealing with code at a lower level leads me to having a much better understanding of what is happening under the hood. However, this lower level access allows you to accidentally write bad code that could introduce a vulnerability

[-] Penguincoder@beehaw.org 2 points 1 year ago

Same. It's not a perfect language, far from such. It is simple but not easy. I too believe it helps with understanding exactly what the code is doing via being lower level.

[-] livendie@beehaw.org 2 points 1 year ago

Using C is a great way to learn some discipline, your given so much control.

[-] bl_r@beehaw.org 1 points 1 year ago

Shooting yourself in the foot is a great way to learn discipline. It is how I learned to be careful of what I am writing. However, I think in most cases a memory safe language could be better.

[-] Hexorg@beehaw.org 1 points 1 year ago

JavaScript is much much higher level than C, but there are vulnerability announcements in npm all the time. C does, however, let you implement more kinds of vulnerabilities associated with memory handling.

[-] kalanggam@beehaw.org 3 points 1 year ago

I'm surprised to hear that anyone would complain about this with C. Even the Wikipedia page about encapsulation cites C as a non-OOP language example.

[-] Kajo@beehaw.org 2 points 1 year ago

Thank you for the article. Opaque struct is an interesting subject for people who want to go deeper into their understanding of C.

If I could add/emphasis two points to the article:

  • FILE is a famous example of struct using this trick. So, even if yon don't often need to develop an opaque struct in C, you certainly use such struct daily without knowing.

  • you can't declare a variable with an opaque type (because the compiler would need to know its size). Everything must be handled through pointers, and the library has to provide functions to allocate/destroy the struct, like fopen() and fclose() for FILE.

this post was submitted on 18 Jul 2023
18 points (100.0% liked)

Programming

13250 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS