3 ms·
Right, so at that point, as I say, there's really not much daylight between "class" and "record". The difference being that a class protects its initialization
by gavinking 11y ago
Right, so at that point, as I say, there's really not much daylight between "class" and "record". The difference being that a class protects its initialization logic (favoring modularity), whereas a record opens it up (favoring flexibility).
Ultimately I see them as much more similar than they are different.
- jules 11y agoThe difference is that a class combines several things into one construct (initialization, type definition, naming) that are separate with records. This is also what causes you to need such an elaborate design for constructors.
- gavinking 11y agoWhat I'm trying to say is that I don't think that the total complexity or total expressiveness is ultimately much different. You trade class types + interface types for record types + named structural types. You trade class inheritance for record extension. You gain a tiny little bit of flexibility via structural typing - but in my opinion much less than is often claimed, since in all these languages so-called structural types are only partially structural - and you lose some power at the tooling level (refactorings are no longer guaranteed to work). You gain a bit of flexibility by decoupling initialization into a function, but you also gain a bit of verbosity and lose a little bit of modularity. Ultimately it's a bit of a wash and honestly I would probably be almost as happy with OCaml or Rust or something like that as I am with Ceylon. I think both systems work well and are intellectually consistent. I don't think either is clearly superior to the other.
- jules 11y agoIt's highly dependent on coding style. If you program in a mostly ML-like style then I think that design has its advantages because only only need record of functions + open recursion + named + always constructed via some constructor in 1% of cases. In such a style you view that combination as just one combination in a whole spectrum of data types that you can express. However if you want to make a language for object oriented programming it makes sense to build that combination into the language rather than supplying each part as a separate building block that you compose in exactly the same way all the time.
- gavinking 11y agoYeah, I think that's probably right.