|
|
|
|
|
by Drup
3042 days ago
|
|
I don't know all that much about C++'s object system, so I can't give you a concrete example on how it breaks down. However, you say that it is "not something people do" ... well maybe not in C++ (I highly doubt that), but it's very common in many languages.
In C, it's common to look inside structs directly and change things.
Javascript libraries do it all the time: They inspect their arguments, look at the types and change their behavior depending on it. It's a common programming practice to poke deep into the data-structures and do things.
In Java, they made it an art with reflection and monstrosity such as Spring. Abstraction is a bit like immutability: Sure, you can try to fake it in languages that don't have it, but then you are just praying that everyone plays by your rules. :) |
|
I admit that I kinda pushed you into it, but you are moving the goal post. People indeed use public fields in languages like C and Javascript.
In C it's often done for the sake of performance. Hiding data behind a pointer has a cost.
In Javascript I would say it's lazyness above all. Front end programs often aren't that big nor pinacles of code quality.
But it is possible to define abstract data types in both languages. ML makes it a bit easier and some times even more performant, but it doesn't "own" the idea.
Abstractions are quite like immutability. You can enforce both in many languages, some just give you better tools for it.