-3
\$\begingroup\$

Roblox has many types of instances. But services and other NonCreatable Instances (ReplicatedStorage, Workspace, etc.) still have methods for creating or destroying. Why? Why do they have :Destroy() and :Clone() methods if they cannot be destroyed or created? What's the point of inheriting these from the Instance class?

What's the point of inheriting a property that can't be used?

\$\endgroup\$
  • 2
    \$\begingroup\$ Very likely it is a workaround to some technical limitation. I don't really know what, I don't know enough of roblox internals to tell. And very likely most people on the site don't know either. \$\endgroup\$ – Theraot Jun 14 at 5:53
  • 2
    \$\begingroup\$ By the way, let us assume some user in this site knows, and that person logs in every day… In that scenario, just by time zone and scheduling differences, it might take 24h to get an answer (it has only been 5 hours so far), perhaps it can take a few days if that person skips holidays and weekends… Worse if that person only has time to log in a day per week… All that assuming that person exist, and is willing to answer. By doing useless edits as you said you will get attention, alright, but not necessarily the attention you expect. \$\endgroup\$ – Theraot Jun 14 at 5:55
  • 1
    \$\begingroup\$ I’m voting to close this question because questions about "why" a game does X is not a good fit for this site since only the developers of the game themselves can answer it correctly and accurately. \$\endgroup\$ – Charanor Jul 17 at 1:19
1
\$\begingroup\$

I can't speak to whether this applies to Roblox specifically (hopefully someone with in-depth knowledge of that tool can share a more detailed answer), but most programming languages don't give you a choice of which parts of a parent type to inherit or which ones to skip.

Once you inherit from a particular type, you get everything that type defines, even if you don't plan to use half of it.

So you often end up leaving the items you don't need with their default implementation, or overriding them with an implementation that throws an error in case someone uses these unsupported methods by mistake.

Even if this inheritance restriction does not apply to Lua scripting directly, it may apply to the underlying back-end code that the script interfaces with.

The actual inherited methods cost practically nothing (just one extra entry in a VTable somewhere, not even an entry per instance), so it's often not worth the grief of refactoring the inheritance hierarchy into a more complex form to avoid this unnecessary inheritances.

That said, this kind of inheritance complication is one reason why game developers often favour composition over inheritance, as a way to glue-together only the functionality a particular entity needs, without hauling in a pile of unnecessary inheritance, or locking the types into a rigid contract with one another that's difficult to modify later.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ But that's dumb, inheriting values you don't use. Inheritance is dumb. Why even inherit properties at all? Why don't they just define every class individually? \$\endgroup\$ – user140507 Jun 15 at 18:36
0
\$\begingroup\$

Every Roblox instance has these methods, they could "remove" them for these particular instances but there's no need as you are not expected to use them anyways.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy