3 ms·
> No programmer is going to be confused about what "var" means, so making everyone type "variable" gains you nothing "variable" is easily distinguished from "v
by vorg 9y ago
> No programmer is going to be confused about what "var" means, so making everyone type "variable" gains you nothing
"variable" is easily distinguished from "value" in Ceylon, whereas "var" and "val" are easily confused in Kotlin, being only different by a single letter "r" and "l" -- which even sound the same in some East Asian languages.
- ptx 9y agoTrue, and "let" would have been better. Scala uses var and val though, so I suppose they chose it for familiarity. When it comes to Ceylon, they weren't going for easily distinguished, they were going for unabbreviated (see earlier link) - the rest of the language follows the same pattern. Anyway, I'd rather take this minor risk of confusion than a language I can barely write without auto-completion. It hasn't been a big problem for me in practice. And if you do use an IDE, it will use syntax highlighting to distinguish var and val.
- stickfigure 9y agoCeylon was designed with functional programming in mind. The idea is that variable is something you will rarely type because mutability is something to avoid; with this mindset, the pain of typing it could be considered a feature. value is used for type inference and isn't much different from typing val. It's also optional; you might just declare an actual type instead, ala Java. I personally think this tends to read better, but that's probably because I spend most of my time in Java.
- lucono 9y ago> The idea is that variable is something you will rarely type This, precisely. I feel Ceylon uses more sensible defaults all around, like also having non-public methods/properties by default unless explicitly declared public. I use Kotlin in some projects, but don't really like its default of public properties and methods unless explicitly declared private, nor their decision on final classes by default. It's also so many other little things in Ceylon that really add up to make it a pleasure to use, like its simplification of numeric types to just the minimal meaningful set of Integer and Float[1] (no Double, Long, etc), its integer literals which use the metric suffix system, like 5k for 5000, 5M for 5 million, and even hex integer literals like #ffffff, etc.[2][3], its comparison operations which return one of the enumerated Comparison type of smaller, equal, or larger (and not -1, 0, 1) ...etc [1] https://ceylon-lang.org/documentation/current/tour/language-module/#numeric_types https://ceylon-lang.org/documentation/current/tour/language-... [2] https://ceylon-lang.org/documentation/current/reference/literal/integer/#decimal_suffixes https://ceylon-lang.org/documentation/current/reference/lite... [3] https://ceylon-lang.org/documentation/current/tour/language-module/#numeric_literals https://ceylon-lang.org/documentation/current/tour/language-...