3 ms·
There is a large overlap between what you call the default constructor and scala case classes—there is a primary "value" parameter list, and other constructors
by duaneb 11y ago
There is a large overlap between what you call the default constructor and scala case classes—there is a primary "value" parameter list, and other constructors must be defined in those terms.
My comment was not meant to be an argument, just a note that there are similarities between this and the other major contender for "java/javascript replacement" and you don't bother to mention them. If they are different, you don't bother to say that either. So it's not a very useful without the comparison, it's just tweaking of the language's constructor patterns and calling it novel.
- justthistime_ 11y agoNot sure what scares me more: A language designer which doesn't want to give credit where credit is due, or a language who really didn't do his research. Too bad that Ceylon/Dart still haven't caught up with the state of the art in terms of "named/default constructors".
- gavinking 11y agoOK, 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.
- gavinking 11y agoWait, Scala's "case classes" are an implementation of what are called "sum types" in PL theory. Ceylon also has sum types, but they don't have anything much at all to do with _constructors_. If you want to know about how Ceylon supports sum types, you can look here: http://ceylon-lang.org/documentation/1.1/tour/types/ http://ceylon-lang.org/documentation/1.1/tour/types/ FYI, Scala didn't invent sum types, and they can be found in languages much older than Scala, going back to the 1970s, if I'm not mistaken. Finally, I don't understand why you're repeating the claim that we're "just tweaking of the language's constructor patterns and calling it novel" when I've already responded and explained that the approach to constructors in Ceylon is quite different to Scala and wasn't influenced by Scala. Is it just a lame attempt to try and provoke me or do you have an actual point to make?