Earlier quoted context omitted.
Can you do something similar in Kotlin using this function scopes (that let you change the meaning of this in a lambda)? I’ve found those ok at defining EDSLs.
I've only ever done a hello world in Kotlin I'm afraid.
New language features since Java 8 to 17
231–240 of 358 posts
Re: New language features since Java 8 to 17
#232Am I the only one who's seeing "sealed" classes as an unfortunate development? I can't count how many times I had to resolve to using PowerMock and hacking bytecode just to mock something in one of the libraries I use because it's ingenious author "final"-ed the whole API surface of the library (and bits of the implementation usually). Now this gives even greater tool to people who love to lock everything up and thin…
Re: New language features since Java 8 to 17
#233Earlier quoted context omitted.
Hmm yes I guess you might be right given Android. It's a shame in a way that Kotlin was invented as Scala could have filled the niche too imho but that ship has sailed. It's too similar to both Java and Scala and doesn't really bring anything new to the table. Is that fair or does it have a great USP other than massive Google backing?
I don't think Scala ever could have filled that niche, I say this as someone that wanted Scala to be successful. The truth of it is that Kotlin is incredibly easy to learn, even for non-Java devs. It is definitely focused on a very low barrier to entry. I don't think this was an original goal but it's become a significant focus of the language especially after being selected to be the next platform language for Andro…
SBT is inexcusably awful (and so is ScalaTest, which is a lot of people's first exposure to the language), and you might be right about the zeitgeist having moved on, but it's a shame; it's honestly a significantly better language design.
Re: New language features since Java 8 to 17
#234Earlier quoted context omitted.
I don't think this is going to happen with Brian Goetz as language architect. He refuses to add many features that would address everyday pain points such as: * null safe navigation operator * properties * mutable records * a way to ignore checked exceptions (or at least having the stream API take functional interfaces that can throw exceptions) * adding functional methods like .filter()/.map() directly to collection…
Thank god for that, because those feature are either horrible on their own or superseded by better ones. You're getting a car and complaining for not getting faster horses. The features Java has adopted -- specifically, algebraic data types and pattern-matching -- will lead to better development practices, rather than making it easier to work with inferior ones.
Are they though? I agree mutable data classes and property _setters_ are bad, but what about the rest?
I personally like the idea of checked exceptions, but there is no doubt they failed to deliver on Java. Perhaps the good parts of this idea can be salvaged by having an easy way to explicitly wrap a checked exception, like with_context() in the anyhow Rust crate. Kotlin dumped checked exceptions in favor of Results, and I don't see how Java has anything right now that supersedes that.
Explicit nullability is unarguably a good feature. You could make a convincing argument that expressing it with an Option/Maybe is better than the road that Kotlin, Swift, C# and TypeScript took. But Java's Optional is not that solution, since the T within the Optional can still be null. And I'm not even getting into how verbose and unnatural using it feels, or the small issue of having to rewrite all the existing Java APIs to make it work.
The same goes for having eager collection operators. The JIT compiler might be able to inline and optimize simple stream operators, but the ergonomics of doing simple things on a collection is just bad.
But even if Java does all of that, just lack of extension methods and top-level functions make using Java a nightmare for me. If Java had extensions methods (or an equivalent concept like Type classes or the Uniform Function Call Syntax that D has), the previous complaint about lacking collection operators directly defined on Collection and Iterable will be a non-issue. Just let anybody who wants it define their own.
Re: New language features since Java 8 to 17
#235Earlier quoted context omitted.
Is there a reason for that? I'd really love to get into android development, but I'm loathe to give up some of the nicer language features in Java. What version of Java is android supporting? At least 8, right?
Java's supported version on Android is a moot point: all new Android development should be made in Kotlin.
Re: New language features since Java 8 to 17
#236Earlier quoted context omitted.
Most likely to Flutter. When Google will be ready to ditch Android API.
Android is based on the JVM, it will never switch to Flutter (and an aggravating factor is that Dart is an inferior version of Kotlin).
Re: New language features since Java 8 to 17
#237Earlier quoted context omitted.
I must be in the minority of thinking java 7 was the last great version of Java. What I see today is a nearly different language.
I liked Java 1.4. Generics were a mess. And Java before generics was so wonderfully simple. Yes, you had to cast, but that wasn’t a big issue. My favourite language would be Java 1.4 with carefully redesigned standard library (because old standard library was not very nice).
In all seriousness, Java's implementation of generics was less than ideal, but I recently had to deal with a lot of pre-Java 1.5 codebases that haven't seen much upgrade in recent years. It wasn't fun.
Re: New language features since Java 8 to 17
#238Am I the only one who's seeing "sealed" classes as an unfortunate development? I can't count how many times I had to resolve to using PowerMock and hacking bytecode just to mock something in one of the libraries I use because it's ingenious author "final"-ed the whole API surface of the library (and bits of the implementation usually). Now this gives even greater tool to people who love to lock everything up and thin…
Re: New language features since Java 8 to 17
#239I used to really love Java, it was my second "real" programming language after C/C++, and GC, type safety, and object orientation really changed the way I thought. I also learned almost all I knew about high-performance VMs (up to 2013) in the context of JVMs. But these days it seems like Java is engaged in one long apology for the "everything is an object" mindset it started out with. It both took it too far and not…
Re: New language features since Java 8 to 17
#240Earlier quoted context omitted.
public class Main { public static void main(String[] args) { System.out.println("Hello, world!"); } } vs print("Hello, world!") Please comment again if you still cannot see the bloat/unnecessary verbosity.
Global scope is a terrible invention. The less implicitness there is, the better.
Or where is the import to get "System" into scope? It's imported globally everywhere (just like all everything from java.lang).
So the only question is: should "print" be burried under layers or not. I don't think the advantages of burrying are really worth it.