News for hackers. Stuff that matters.
Re:Java 16 by dadoge on Tuesday March 16, 2021 @11:01AM (#26477610)
Very cool to see that Scala continues to have a huge impact on Java’s roadmap.

Records and Sealed Classes are borrowed from Scala.

Could be not the best news for new Scala adoption, but good news for developers having better abstractions in Java

Edit: Kotlin, and other languages should also mentioned since they also include similar features. I still think Scala has had the most influence over the years.

Re:Java 16 by mdm12 on Tuesday March 16, 2021 @11:11AM (#26477779)
We see similar developments with C# borrowing features from F#, with records in v9, pattern matching, etc.

While it's good for C#/Java, it does make it harder to push for adoption for a language such as Scala and F#. Why bother investing in the languages with a much smaller market share when the big boys adopt good bits and pieces from them constantly?

Re:Java 16 by gugagore on Tuesday March 16, 2021 @11:18AM (#26477897)
> Why bother investing in the languages with a much smaller market share when the big boys adopt good bits and pieces from them constantly?

This won't always apply, but sometimes (many times?) there's a software endeavor that permanently feels on the margins of a programming language's capabilities, whatever that means. You may forego market share in order to be 5 or 10 years ahead of current practice. In other words, the mainstream isn't converging to a stable F# / Scala / whatever. It's lagging behind. It's not the last time that a mainstream language adopts a feature that has been available for years in a more fringe ecosystem.

In practice, I'm sure the most important thing is humans and their skill, so mainstreamness matters. But if you can somehow be less sensitive to that, you may reap a lot of benefit from using Foo before it was cool.

Re:Java 16 by geodel on Tuesday March 16, 2021 @11:43AM (#26478319)
Another thing to note that cutting edge languages do not always deliver great features , they also deliver with great frequency half baked features to be discarded or deprecated in few years. Also since most effort spent on language , tooling remain primitive and slow for long time.

So I do not see them a sure win for projects I work on.

Re:Java 16 by mumblemumble on Tuesday March 16, 2021 @12:06PM (#26478651)
FWIW, I feel that way about Scala, but not F#.

The only big F# feature I know of that's fallen out of favor is type providers, and, IMO, that's not because the feature was half-baked so much as because it was one of the many casualties of .NET's transition to being a truly cross-platform toolkit.

Re:Java 16 by riyadparvez on Tuesday March 16, 2021 @12:26PM (#26478982)
Because Scala is a truly innovative and experimental language that came out of a programming language research group. That's why there's a lot of features that didn't play out well in real-world. F# started out as .NET rendition of OCaml. Most languages initiated by large crops don't try to be innovative, rather they take approaches introduced by different niche languages (many of them are only for research purpose) and incorporate to their language. Languages that try cater to a large audience should be adopting features from experimental languages.
Re:Java 16 by mumblemumble on Tuesday March 16, 2021 @12:31PM (#26479033)
F#'s relationship has been vastly overblown. The truth is that they're about as closely related as C# and Objective-C. In the same way that the overlap between C# and ObjC is basically just the C bit, the overlap between F# and and OCaml is basically just the ML bit. (Actually, even less than that.) You could say that it was inspired by OCaml, but it includes almost none of what makes OCaml OCaml, and adds a lot of its own new ideas.
Re:Java 16 by ragnese on Tuesday March 16, 2021 @02:44PM (#26481071)
To someone who has a passing familiarity with OCaml, but none with F#, can you elaborate? Because I do hear the comparison frequently.

Do people just draw the comparison because they don't actually know of any other ML languages besides OCaml?

Re:Java 16 by mumblemumble on Tuesday March 16, 2021 @03:43PM (#26481847)
I haven't touched OCaml in a while, but the things it has and F# doesn't that I can remember include: Functors (in the ML sense), camlp4, polymorphic variant types, multiple inheritance, class interfaces.

Things F# has that OCaml lacks: Extension methods, units of measure, type providers, quotations, computation expressions, active patterns, overloading.

Probably most of the F# things could be (and perhaps have been) added to OCaml with camlp4, which is more powerful than F#'s quotations. Versus, F# may never be able to have all of OCaml's ad-hoc polymorphism features. So there's that. But I'm mainly meaning to compare what's actually built into the language.

Re:Java 16 by gugagore on Tuesday March 16, 2021 @11:48AM (#26478384)
Great point about half-baked features. The investment boils down to risk-reward. Can we say that the features that are introduced into Java at this point are features that have stood the test of time in other languages?
Re:Java 16 by geodel on Tuesday March 16, 2021 @11:56AM (#26478500)
I have already used `records` in some project I work on. To me it does not look too clever / funky. It still looks like very obvious Java code but little more concise.
Re:Java 16 by Barrin92 on Tuesday March 16, 2021 @12:31PM (#26479034)
>Why bother investing in the languages with a much smaller market share when the big boys adopt good bits and pieces from them constantly?

because if you know exactly what you want to do there's no reason to settle for the second best thing. If you want F#, no harm with going exactly with F#.

I talked to a bunch of Jane Street engineers once and the consensus seemed to be that Ocaml, despite its very small footprint, actually helped them attract the kind of people who were super enthusiastic about building really good stuff with a good technology, so it actually made recruiting for them easier.

Re:Java 16 by hota_mazi on Tuesday March 16, 2021 @02:16PM (#26480692)
> actually helped them attract the kind of people who were super enthusiastic about building really good stuff with a good technology, so it actually made recruiting for them easier.

Sounds like a strong case of selection bias.

There is no shortage of people who are super enthusiastic about building really good stuff with good technology, and it's hard to believe that it's easier to hire Ocaml engineers than other languages.

Re:Java 16 by nonameiguess on Tuesday March 16, 2021 @08:21PM (#26485021)
I really don't want to sound elitist, but there is the issue that probably 90% of people who have ever written code for money know enough Java to get by and credibly claim they can do it on a resume. Just the ubiquity in university intro courses and enterprise use means everyone gets exposed to it.

On the other hand, if you see someone took the time to learn OCaml, I think you can be reasonably well assured they legitimately love programming. Signal value jumps from "this person has ever programmed" to "maybe this person has a real passion for it."

Re:Java 16 by jjav on Tuesday March 16, 2021 @06:03PM (#26483761)
Agreed. I worked with a team who was heavily into scala and one of their beliefs was that all the smartest people want to work on scala, thus having the company use scala will filter only the smartest people to want to work for us.
Re:Java 16 by dfgdghdf on Tuesday March 16, 2021 @12:44PM (#26479239)
I can only comment on C# / F#.

The C# versions of F# features tend to be pretty clunky compared to the F# versions. This is because F# was designed for them from the beginning, rather than having them tacked on. Functional programming is getting easier in C#, no question about that, but honestly, it still kind of sucks. And the OOP-minded C# devs on your team still won't be able to make sense of your code that leverages all these fancy new features anyway.

Re:Java 16 by adamdusty on Tuesday March 16, 2021 @06:52PM (#26484270)
What fancy features won't we understand?

I think some things about functional programming make code feel cleaner, but I don't like it enough to use F# or Haskell.

Re:Java 16 by dfgdghdf on Wednesday March 17, 2021 @05:25AM (#26488497)
If you do stuff like this: https://weblogs.asp.net/dixin/category-theory-via-csharp-7-m...

(Note this is horrible because C# does not support this style well, in F# it's idomatic)

Re:Java 16 by xwolfi on Tuesday March 16, 2021 @12:40PM (#26479185)
But it's fine, we don't really care about language adoption if the best most supported most tested most hiring languages swallow their features, right ?

What matters is what we do with the language, more than the name of it no?

Re:Java 16 by mdm12 on Tuesday March 16, 2021 @01:14PM (#26479748)
The problem (as I see it, anyways) is that the 'big boys' that I referred to in my initial comment have been around a long time (2000 for C#, 1995 for Java) and over that long history, have had a slew of language changes. They are starting to suffer from the same problem that C++ suffers from, where every shop defines their own subset of the language with which they use. Meanwhile, the languages that they graft features from (e.g., F#) tend to be smaller and more coherent with respect to the feature set.
Re:Java 16 by kaba0 on Tuesday March 16, 2021 @04:19PM (#26482278)
But that’s the great thing about java, it is still a pretty lean language even with its age.
Re:Java 16 by simiones on Wednesday March 17, 2021 @03:05AM (#26487493)
And even C#, which has grown a lot, tends to have pretty orthogonal features, so that you don't end up too often in C++'s problem that every feature interacts with every other feature and complicates it.
Re:Java 16 by dweekly on Tuesday March 16, 2021 @11:31AM (#26478119)
Really sorry to ask the dumb question here, but what is V9? A cursory Google search didn't show me anything about e.g. a major update to the V8 JavaScript engine?

UPDATE: Ah, C# v9.0 thank you all.

Re:Java 16 by mdm12 on Tuesday March 16, 2021 @11:33AM (#26478159)
I meant 'v' as in 'version' of C#, here's a good reference on it: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csh...
Re:Java 16 by BuckRogers on Tuesday March 16, 2021 @11:56AM (#26478489)
"We see similar developments with C# borrowing features from F#, with records in v9, pattern matching, etc."

Parsing that sentence the subject is C# and F# is referenced, but the subject of the sentence didn't change, it remained C# thus logically v9 applies to it.

Re:Java 16 by url00 on Tuesday March 16, 2021 @11:37AM (#26478235)
Re:Java 16 by T-zex on Tuesday March 16, 2021 @11:35AM (#26478192)
Re:Java 16 by yashap on Tuesday March 16, 2021 @11:34AM (#26478179)
They meant version 9 of C#, the language.
Re:Java 16 by pjmlp on Tuesday March 16, 2021 @02:25PM (#26480802)
No bother, beyond learning new concepts.

In the end platform languages always take the most relevant pieces from the guest languages, which eventually fade away.

Re:Java 16 by agumonkey on Tuesday March 16, 2021 @02:03PM (#26480513)
Semi sad state of the universe
Re:Java 16 by Decabytes on Tuesday March 16, 2021 @11:38AM (#26478239)
This is why it's so important to have different programming languages! Sometimes it's hard to do things differently when you are just looking at your own programming language, and the tools it has available to it. Not everyone programming language needs to be a behemoth to be useful to other people. I say keep making new an interesting programming languages! It will only lead to better programming languages over all
Re:Java 16 by bishop_mandible on Tuesday March 16, 2021 @11:46AM (#26478366)
> Records (...) are borrowed from Scala.

I think records already existed in FORTRAN and other languages like ALGOL-60. C has structs, too.

Re:Java 16 by todd8 on Tuesday March 16, 2021 @01:12PM (#26479734)
Yes you are right, records have been around for a long time.

COBOL was a popular, very early language supporting hierarchical data of different types. This dates back to approximately 1960.

FORTRAN didn’t have records other than I/O “records” (at least for the first 20 years). ALGOL-60 didn’t have records. Algol-68 did have records, however Algol-68 wasn’t in very widespread use. I never had an opportunity to use it; compiler technology at that time wasn’t really ready for such a challenging language. Algol-68 may not have had widespread use, but a number of it’s features made their way into influential languages like C, Pascal, and Simula. These languages did have records.

As I recall, IBM’s PL/1 did have records, I seem to recall using them in the 70’s in a PL/1 program. PL/1 was kind of an amalgamation of FORTRAN and COBOL’s features.

Re:Java 16 by cmrdporcupine on Tuesday March 16, 2021 @06:59PM (#26484322)
In the end... Pascal was/is hugely influential, and, yeah, it called these kinds of things "Records." But the funny thing is it's been so long since I wrote Pascal or Modula-2 that when I first heard the term "Record" in the context of Java I never made the connection.
Re:Java 16 by ragnese on Tuesday March 16, 2021 @02:48PM (#26481126)
I think it's fair, though, to say that it's likely that the implementation and/or semantics may be more based on other JVM languages, who have to work on Java's terms.

In particular, I'm talking about the fact that Java doesn't really have "copy types" or "pass by copy" or whatever. So, sure, C has struct, Swift has struct, etc, but Java can't really model its version off of the way those work.

Re:Java 16 by meddlepal on Tuesday March 16, 2021 @11:08AM (#26477715)
I think the reaction has been more to Kotlin than Scala.
Re:Java 16 by jmarcher on Tuesday March 16, 2021 @11:31AM (#26478126)
Arguably, Kotlin took some of the better ideas from Scala.
Re:Java 16 by virtualwhys on Tuesday March 16, 2021 @11:54AM (#26478467)
Arguably? I'd say it's rather obvious, but overall they're different languages with different goals.
Re:Java 16 by Koshkin on Tuesday March 16, 2021 @03:09PM (#26481421)
To be fair, “arguably” has come to mean “no doubt.”
Re:Java 16 by jmarcher on Wednesday March 17, 2021 @12:26PM (#26493364)
You are thinking about "unarguably". ;)
Re:Java 16 by Koshkin on Wednesday March 17, 2021 @03:28PM (#26495778)
No, I was talking about the now usual in the English-speaking practice amplification of its meaning as "can be supported or shown by persuasive argument", e.g., That is arguably the best book on the subject.

https://www.thefreedictionary.com/arguably

Re:Java 16 by dadoge on Tuesday March 16, 2021 @11:37AM (#26478224)
I’m more a Scala dev than Kotlin

Think it’s safe to say both influenced Java’s Record, shoulda mentioned Kotlin too.

Re:Java 16 by Number157 on Tuesday March 16, 2021 @11:53AM (#26478446)
Kotlins data class is functionally basically the same as a lombok @Data class used in Java. Why Java didn't keep the name "Data class" I don't know.
Re:Java 16 by ragnese on Tuesday March 16, 2021 @02:54PM (#26481223)
"Data" is such an overloaded and vague term, anyway. Almost all classes have "data", so what the heck is a "data class"? Is it one that only has data (not behavior)? Nope- these can have arbitrary methods.

So, I'm kind of glad they didn't use it. (But, to clarify, I really don't care what color the bike shed is)

I'm more wondering why they didn't go with "struct" or "value class", especially because the latter is exactly what we've been calling "class whose equals() is defined by content rather than identity" for many years.

Re:Java 16 by kaba0 on Tuesday March 16, 2021 @04:24PM (#26482362)
Because while in the end project valhalla will not call them value classes, it is a sort of an overloaded term.

Structs/value types can be mutable, records are not. They are basically tuples with names. And as far as I know, while records have a sane default equals defined, they are still identity objects in that they are passed by reference.

Re:Java 16 by ragnese on Tuesday March 16, 2021 @04:48PM (#26482751)
> Structs/value types can be mutable, records are not.

Fair point about record fields not being reassignable (not the same as immutable for others reading this).

> And as far as I know, while records have a sane default equals defined, they are still identity objects in that they are passed by reference.

Well, sure. All non-primitives are passed by reference. That doesn't stop them from being referred to as value types.

But in light of your first point, I agree that choosing a totally new term probably makes sense.

Re:Java 16 by kaba0 on Tuesday March 16, 2021 @07:07PM (#26484395)
I stand corrected, shallowly immutable or as you note fields not being reassignable it is.
Re:Java 16 by JohnKacz on Tuesday March 16, 2021 @11:10AM (#26477747)
I saw someone recently post the idea that Java/Scala/F# almost functioned as LTS/Stable/Dev in reference to how these languages were sharing impact.
Re:Java 16 by ragnese on Tuesday March 16, 2021 @11:34AM (#26478178)
I think the person actually said Java/C#/F#.

But in any case, I'm thinking that the real timeline is more that Java is prioritizing features that are most attractive from Kotlin, which borrowed the ideas from Scala. But Scala never got super popular, so there was not much pressure or "proof" that these were good ideas until everyone fell in love with Kotlin.

Re:Java 16 by eweise on Tuesday March 16, 2021 @12:11PM (#26478724)
I think Kotlin is more at risk than Scala on the server at least. Scala still has a lot of advanced features that sets itself apart. Kotlin is a better Java but Java is catching up fast.
Re:Java 16 by ragnese on Tuesday March 16, 2021 @02:55PM (#26481238)
Agreed. But Kotlin 1.5 will have enough interesting stuff with the new inline class and const methods that I think it'll keep its appeal for quite some time.
Re:Java 16 by jicea on Tuesday March 16, 2021 @04:28PM (#26482430)
Developing now 80% in Kotlin and 20% in Java (on backend), I really think the main advantage of Kotlin over Java is nullability. You can use @Nullable/@NotNull annotations in Java, but nullability being a part of the type system in Kotlin is better. I also love being able to create simple functions and add extension methods to existing classes. But still, nullability is the strongest advantage of Kotlin and I don’t see how Java will address it.
Re:Java 16 by ragnese on Tuesday March 16, 2021 @04:39PM (#26482599)
Agreed about nullability. And Java will never fix it fully or I'll eat my hat.

... but, you have to be pretty damn good to win out over the native language of a platform. And if it were just Kotlin today vs. Java 16, I think Kotlin is a much nicer language, but it doesn't really differentiate itself that much. Sure, it's syntax is much nicer, but you still basically have the same semantics as Java. You have classes; everything is a reference; no const/immutable data; no (good) general way to clone things; you have the same-ish type system with inheritance and interfaces, but no type classes; still have weird shit like sized numeric types with over/underflow; exceptions for error handling; etc.

At least Scala has monads and type classes, so you can say it actually has some expressability that Java truly doesn't. I'm not sure that Kotlin has that. Clojure is a totally different beast that really doesn't directly compete over Java devs, IMO. It just happens to use the JVM as a platform.

Re:Java 16 by roguas on Thursday March 18, 2021 @08:39AM (#26502029)
Yup, clojure people have no love for jvm. It's a source of libraries, period.
Re:Java 16 by kaba0 on Tuesday March 16, 2021 @04:27PM (#26482404)
But I fear kotlin will fall in-between all the platforms they try to support, and will end up comparatively bad on all. Like, you can’t really target both your coroutines on each platform as well as project loom properly, same with project Valhalla and the like.
Re:Java 16 by ragnese on Tuesday March 16, 2021 @04:43PM (#26482667)
Why can't coroutines take full advantage of Loom's green threads on JVM and do other stuff on Native/JS/whatever?

I generally agree that being multiplatform is a lofty goal. And as much as I like Kotlin, it clearly inherits some of Java's (IMO) deficiencies. I'm not sure why I'd want those deficiencies exported to my native code when I could use lots of other nice languages.

Re:Java 16 by BoyRobot777 on Tuesday March 16, 2021 @05:22PM (#26483162)
I think Loom can be abstracted away by Kotlin quite easily. Valhalla on the other hand won't work at all. You won't be able to have inline classes in android/older Java versions. Even more - specialized generics.
Re:Java 16 by wpietri on Tuesday March 16, 2021 @11:08AM (#26477717)
I hope they're subsidizing the Scala project, and Kotlin too. Nothing better for a dominant player than having other people scout the territory for you.
Re:Java 16 by geodel on Tuesday March 16, 2021 @11:16AM (#26477857)
I think millions of man hours went in JVM development will count for lot of subsidy.
Re:Java 16 by u678u on Tuesday March 16, 2021 @01:31PM (#26480000)
I spent a few years moving to Scala but have come back as Java really does everything I want now. Just Akka is a bit clunky.
Re:Java 16 by sireat on Tuesday March 16, 2021 @04:30PM (#26482464)
Besides Scala, I feel both Kotlin and Rust have been heavily influenced by Scala.
Re:Java 16 by BoyRobot777 on Tuesday March 16, 2021 @11:31AM (#26478123)
Why not Kotlin, C#, F#, ML and so many other languages?