3 ms·
> One doesn't define _classes_ per se, but rather just plain old boring structs. in which language are there differences between classes and structs ?
by jcelerier 8y ago
> One doesn't define _classes_ per se, but rather just plain old boring structs.
in which language are there differences between classes and structs ?
- stevelosh 8y agoCommon Lisp http://www.lispworks.com/documentation/lw70/CLHS/Body/m_defstr.htm http://www.lispworks.com/documentation/lw70/CLHS/Body/m_defs... http://clhs.lisp.se/Body/m_defcla.htm http://clhs.lisp.se/Body/m_defcla.htm
- ygra 8y agoOf the languages i know, C++ and C# come to mind. Granted, in C++ the differences are fairly minor and inconsequential at runtime.
- wffurr 8y ago"struct" here is meant in the same sense that the author of the post refers to "PoD objects". Just data in public fields. Whereas a "class" is usually thought of as private data exposed only through methods. There is no language that enforces this distinction; it's purely by convention. C++ makes it a little simpler by having a different default access level. In any case, you are being needlessly pedantic and missing the point.
- deleted 8y ago[deleted]
- leiroigh 8y agoAbove example is from julia. Julia structs have C layout and have no member functions. The analog of "classes" in julia are "abstract types"; e.g. `AbstractArray{T}` is anything that implements the AbstractArray interface and holds objects of type T. Abstract types have no instances (all objects have a concrete type, that may be a subtype of an abstract type). Binary compatibility between class and superclass is a cool feature in many OOP languages. This allows fast dynamic dispatch via vtable and lots of shared binary code for non-virtual methods (you can always memory pun from class to superclass). Julia does not support that feature: your different methods can share source code, but they get compiled separately. This is good for performance (more aggressive inlining) and bad for compiling small shared libraries (it is very painful to create julia apps/libs that work without invoking the JIT-compiler at runtime; can be done via custom sysimg). In some sense, julia is not very well suited to closed source business models.