3 ms·
The Coolest Programming Language Features
- rurban 3y agore The Kotlin example fun String.mutate():, extending the builtin String class. This a favorite example, because in Java builtin classes are sealed/closed, and in Kotlin and many other langs they are open, so you can monkeypatch those system classes. https://kotlinlang.org/docs/sealed-classes.html#sealed-classes-and-when-expression https://kotlinlang.org/docs/sealed-classes.html#sealed-class... A cool new feature or a bad mis-feature? Closed classes offer tremendous compile-time safety guarantees and optimization possibilities. with open classes you have to check inheritance on each and every call at run-time, with sealed classes you can easily inline them. A much cooler feature than open classes. Larry Wall was so angry about closed java classes that he wanted them open and slow. On the other hand, Damian Conway, the perl6 designer, wanted them closed by default. You have to look at the current raku design if they are still open or closed. One of the many reasons why raku is so slow.
- lizmat 3y ago> Larry Wall was so angry about closed java classes that he wanted them open and slow. On the other hand, Damian Conway, the perl6 designer, wanted them closed by default. You have to look at the current raku design if they are still open or closed. You don't have to look at the design. You can look at the implementation. And in the implementation, they are closed. However, you can open them, but that invalidates any optimizations done so far. So generally, people don't do that, unless it is at compile time. > One of the many reasons why raku is so slow. Hi Reini, still the same grumpy person, eh? At least Raku is NOT a language that is hooked on needing C extensions whenever it gets too slow. And judging by the amount of modules with C extensions on CPAN, that is quite often. This addiction will prevent it from ever moving forward.