3 ms·
OK, well it seems quite likley you're just trolling me here, but I'll respond anyway: do you have some technical feedback on how the design I've outlined here i
by gavinking 11y ago
OK, well it seems quite likley you're just trolling me here, but I'll respond anyway: do you have some technical feedback on how the design I've outlined here is flawed or inferior to some other "state of the art" design, or a link to some research that you think I didn't do?
Because if not, it doesn't seem that scary, does it?
- justthistime_ 11y agoThe whole idea of "let's encourage people to litter their classes with convenience constructors" is bad. Constructors are the odd things which act like static methods, but have access to the fields of the instance-to-be-created. Because constructors are weird and special in a lot of other ways too, it makes sense to use them only for initialization, and try to encourage people to define exactly one constructor. Named constructors are poorly designed factory methods with the disadvantage that they are married to the class and add additional baggage to class declarations. Why does Ceylon have objects, if they aren't used for one of their prime use-cases? "Static methods go into objects, except static factory methods, let's keep dumping them into the class declaration" ... looks quite questionable to me. Ok ... I'm really starting to believe you when you said you didn't look into that other language, because there is practically no benefit in doing it the way Ceylon does.
- gavinking 11y agoWell in fact constructors aren't that much like static methods at all. Now static methods really are a weird thing, because they break the block structure of the language: they look like they have access to members of the class, but they don't. That's why Ceylon doesn't have static methods. Constructors, OTOH, actually fit in with the block structure of the language. They do have access to the members of the class, and the responsibility to initialize those members. Now, the interesting thing is that I spend 4 years of my life hoping that we would not need constructors, and that the ability to initialize a class via the parameter list of the class would be sufficient for all usecases. Sadly, it turns out that I was wrong about this, and that, in practice, there are some really good usecases for constructors in a language which emphasizes immutability as Ceylon does. That's just what we ran into in practice. > you said you didn't look into that other language I never said that. Please don't put words into my mouth. FYI, I've looked closely at lots of other languages, including languages like OCaml and F# and Rust which do things quite differently to Ceylon. I like those approaches, and they have advantages/disadvantages compared to constructors. I would not say they are clearly better, nor clearly worse. But I'm confident that what we have done is very clean and elegant and powerful in the context of Ceylon.