13 ms·
modern java is a huge improvement over old java. switch pattern matching will be huge, this has been in preview for a long time
by foolfoolz 4y ago
modern java is a huge improvement over old java. switch pattern matching will be huge, this has been in preview for a long time
- papito 4y agoLook, I haven't done Java in more than 10 years, but I have done Scala. Honest question - isn't Java just trying to "steal" Scala's concepts and catch up to the "cool" languages?
- mayank 4y agoAll modern languages heavily borrow from each other’s latest iterations. In the case of Java though, playing catch up is by design since it’s intended to be a conservative/stable language.
- sfritz 4y agoTheir philosophy is to "adopt" language features once they're well worn by other languages so they can learn from their mistakes / successes.
- NwpierratorR 4y agoWhile philosophy is good, Java makes a very questionable syntactic choices when adopts that said features. Pure slowness in how java develop feels like you have to wait 5 years to get something that other languages have, only to get it in the most aesthetically unpleasant way. It seems like devs add unnecessary verbosity whenever they can. Java adopted lambdas after many other languages, yet still decided that allowing to move last parameter closure {} outside of () is too radical, even though it is much more visually pleasant choice and quite common in other languages. default methods in interfaces instead of static extensions. This one is controversial as static extension methods were not really common when java came up with this, but end result does not look impressive. Same with their new sealed classes. They just chose the most verbose version they came up with. Some inconsistency of choices also kinda baffles me. First they added support for skipping necessity of mentioning generic type inside <> during instantiation, only to introduce local vars later that require you to mention generic types within the same <>. Now you either mention generics by their full type always, or embrace the inconsistency and have it skipped when type mentioned in prefix and type it when using local vars. Or do not use local vars and have consistent codestyle with increased verbosity. Java is still a good language, but it feels dated in syntax. TBH I have no idea why would anyone chose java in 2023 when there's kotlin, which not only fully covers the same functionality(okay, no pattern matching and no loom/valhalla until java merges it), but does it while being much more concise and readable.
- marginalia_nu 4y agoI'd choose Java over Kotlin in 2023, in fact I'd do so most years. I'll pretty much take conservative language design over developer comfort every day of the week.
- Alupis 4y agoBut you do not have to choose Java over Kotlin - you can use them both in the same project without any side effects. This was by design for Kotlin, and is probably their smartest/best feature. All existing Java code/libs just work in Kotlin. Conversely, most Kotlin code/libs just work in Java, although some care needs to be made there. Kotlin is amazing to use and read. For most things, the Kotlin version is easier to read and comprehend than the Java version in my experience. As Java adds language features, Kotlin either gets them for free or already had them (and now can use native features instead of their own custom features).
- krzyk 4y agoIn my case Kotlin was harder to read than Java, so it really depends on the person. (Same thing with Groovy, but that one is even worse than Kotlin) On the other hand Scala looks nice.
- pjmlp 4y agoKotlin adds Jetbrains only as IDE, additional build plugins, an ecosystem of Kotlin libraries for more idiomatic code, stack traces completly unrelated to Kotlin as JVM only understands Java, and it needs plenty of boilerplate to emulate co-routines and functions in JVM bytecodes. Other than Android, there are no reasons for additional complexity in development tooling.
- Alupis 4y agoMost of your points are not really valid if you understand Kotlin. It's not different than understanding Java really... > Kotlin adds Jetbrains only as IDE Not true, you can use any IDE you want. Of course IntelliJ is the "blessed" IDE, but really, Kotlin is just a bunch of libs, any IDE will work. > additional build plugins I don't see why this would matter. Any non-trivial build is going to use a bunch of plugins. > an ecosystem of Kotlin libraries for more idiomatic code Which are optional. > stack traces completly unrelated to Kotlin as JVM only understands Java I don't know what you mean. The stack traces are from bytecode, which Kotlin compiles to just like Java. The stacks are identical... > needs plenty of boilerplate to emulate co-routines and functions in JVM bytecodes You do not write the boilerplate though. That's the difference. Of course all higher level languages with High Order functions are going to suffer this same issue. It's abstractions all the way down.. You probably already use Kotlin and don't even know it. The popular okHttp library from Square is Kotlin - but you'd never know that if you just used it in your Java project.
- deleted 4y ago[deleted]
- zokier 4y ago> Honest question - isn't Java just trying to "steal" Scala's concepts and catch up to the "cool" languages? Is that somehow bad thing?
- cbm-vic-20 4y agoThe Java team is very conservative in building out new language features- they find the things that have been battle tested in the wider language space, and take their lessons and adapt them into Java features. IMO this is a good thing. If it's "stealing" then every other language is "stealing" from each other, too.
- margorczynski 4y agoJava, the Debian of programming languages. I guess that would make Scala like Arch and Haskell - Gentoo?
- cutler 4y agoIt's a pity they never stole quotemata() from Perl instead of having to escape regex metacharacters.
- deleted 4y ago[deleted]
- bcrosby95 4y agoMany of these changes are made with an eye towards having better support for data oriented programming in Java: https://www.infoq.com/articles/data-oriented-programming-java/ https://www.infoq.com/articles/data-oriented-programming-jav...
- deleted 4y ago[deleted]
- aardvark179 4y agoWe are all taking stuff that ML had 40 years ago, or maybe Lisp 50 years ago. I wish the debates around language features could just get past the idea that language X is stealing from my favourite language Y.
- nradov 4y agoAs an industry we have amnesia. Many developers, including programming language designers, are simply unaware of what was done decades ago and thus end up reinventing the wheel. Before jumping into writing new code we should develop the discipline to start by researching what has been done before in similar domains. Even if the old code isn't reusable we can often apply the same design patterns or at least avoid making the same mistakes.
- robertlagrant 4y agoSure, but I think you forget: we aren't the first industry to have amnesia.
- lenkite 4y agoIt is just simply too hard to read several hundred papers and do bin-surfing to find out what was done in the historical past of computing and grab the timeless ideas. We need government/grant supported researchers and tech writers who can do this work and create a curated, focused bunch of books describing the best methods and designs. I found the Architecture of Open Source Apps to be amazing, but we need something regularly maintained for all software domains.
- javier2 4y agoIn that case you need to look at the people designing java/C# in the 90s.
- mindcrime 4y agoMeh. Take pattern matching for example... that dates back at least to the SNOBOL[1] days. So you could say that every language that has first class patterns and pattern matching is "stealing" from SNOBOL. Or probably SNOBOL "stole" the idea from some predecessor. My point is, "imitation is the sincerest form of flattery." Languages have been "borrowing" ideas from each other dating back to the beginning of programming languages. There's nothing particularly notable about Java continuing that tradition. [1]: https://en.wikipedia.org/wiki/SNOBOL https://en.wikipedia.org/wiki/SNOBOL
- marginalia_nu 4y agoJava's stated goal has always to be conservative with adding new features, to implement what the "cool" languages are doing after it's been battle tested. It's been this way since the start.
- andylynch 4y agoI was just reading the final chapter of The Well-Grounded Java Developer, and it quotes thus on the borrowing of ideas, which is apt to mention here: One of the surest of tests is the way in which a poet borrows. Immature poets imitate; mature poets steal; bad poets deface what they take, and good poets make it into something better, or at least something different. —T. S. Eliot
- Kwpolska 4y agoScala is not cool in any way, shape or form. It’s an unsuccessful, niche language, that has implemented probably every possible feature ever done in a programming language, including some really backwards ones (like putting XML in the middle of your code). Having all those features makes Scala harder to learn and understand. Programming language features aren’t “stolen”, since they aren’t really “owned” by any given language.
- nradov 4y agoYou're getting down voted but your comment is basically correct. Scala contains some good ideas but due to high complexity and weak tooling support it has failed to gain mainstream adoption. And it's widely recognized now that embedding XML literals in the code was a bad idea; if we want to do something like that then it should be a more generalized mechanism that could support other hierarchical data formats such as YAML or JSON instead of being locked in to XML. Despite its flaws, Scala isn't a bad language necessarily. It will still continue to see niche use. But it no longer seems like the obvious path forward for general purpose application coding.
- Kwpolska 4y agoI don’t think a generalized mechanism that would simultaneously suport XML and JSON would work, because they have different structures, uses, and generation/parsing mechanisms (XML/HTML is often generated using textual templates, but JSON is generated and parsing by going by plain old objects. While Scala is perhaps not a “bad language”, it contains many flaws and I don’t see much of a bright future for it. (Also, Scala 3 brings new single-use features, and an entire alternate Python-style syntax, because learning one syntax is apparently not enough.)
- nradov 4y agoMy point was that XML and JSON (and YAML and S-expressions) are fundamentally similar in that they can be modeled as tree structures. So, in principle it might be possible for a programming language to have generalized support for tree structured data literals which could then be encoded into multiple different external formats. As to how that could work syntactically without turning into a huge mess, I'm not sure.
- ackfoobar 4y agoAnd Scala is stealing OCaml's named pattern matching for records, while Java is replicating Scala's deficiency (positional destructuring only) from a decade ago. https://github.com/scala/improvement-proposals/pull/44/files https://github.com/scala/improvement-proposals/pull/44/files
- tpoacher 4y agoMy honest reply to that would be, do some more java and see for yourself. Your last experience with java was Java 5, which is ... ancient. Java has gone through a lot of changes, and is actually a very nice, streamlined language now. You'll probably be very surprised to hear it even comes with a jshell and jwebserver these days!
- SillyUsername 4y agoI would not call Java streamlined by any measure, API size, library size, or LOCs. If you want to see a streamlined API, see Typescript + Webpack which will trump in all of those metrics. Source: Me, Java coding professionally since Java 1.0 when it was "streamlined" in 1997, and Typescript for the last 5 years.
- vips7L 4y agoThat doesn’t seem like much of a source. Do you have specific examples?
- fidgewidge 4y agoTry compiling a program that prints Hello World to the console and see how many bytes it takes in both source and shipped form. JS/TS will indeed win every time in those metrics.
- vips7L 4y agoWhy is that a metric that matters?
- fidgewidge 4y agoDownload latency is important in many contexts.
- vips7L 4y ago
- davnicwil 4y agoYes, and that's a fantastic strategy. Steal the bits that work, don't steal the bits that don't work, get cooler but slowly without adding a bunch of useless rough bits along the way.
- pjmlp 4y agoIt is called Java Virtual Machine, not Scala Virtual Machine. The guest languages are just that, guests that eventually leave the party.
- nativecoinc 4y agoComparing ten-years-ago Java with todays: Yeah, it’s come a long way but it’s nowhere close to what Scala is (for better or worse; I truly don’t know).
- foolfoolz 4y agoi wrote scala almost exclusively for 10 years and last year started doing more java. are there things i miss from scala? yes. self types. for comprehension. better list and collection syntax. scalas collection processing is probably the best there is. are there things i don’t miss? yes. implicit. execution context on every future method. slow compiles. sbt i couldn’t do java without records and “var”. i don’t think scala has a real future. the binary incompatibility crushed scala for so long. sure scala 3 fixes it but not much has moved to 3. java is iterating at a faster pace than scala. they aren’t the same. scala was designed to be more terse and flexible and always will be. but i don’t think that has made my programs worse in java. in some ways the lack of flexibility makes the code more predictable and easier to maintain
- bombolo 4y agoCall me around the year 3004 when they add unix datagram sockets, fork(), and native support for syslog… so that one can implement sane server software.
- adra 4y agoUnix sockets were released in java 16 officially though it was always supported before that in third party software. C style fork() seems insane for any gc-type languages, so ?? Threading in Java post virtual threads has been so pleasant that I'm like why would one bother? The vast majority of applications use third party logging and many have the ability to call out to syslogd. I'm not entirely interested that every language fits perfectly into the UNIX classical "everything's a process / pipe" style model.
- bombolo 4y ago> Unix sockets were released in java 16 officially though it was always supported before that in third party software. I said datagram, not stream. > C style fork() seems insane for any gc-type languages, so ?? java daemons have no way to signal systemd their readiness. The unix way is to fork and exit. The systemd specific way is to use dbus to tell systemd that the process is ready. java supports none of that natively. So if you have a service that depends on a java daemon, you can't sort them properly. The normal way is to hack the java daemon to be launched from a bash script, that will test if it's ready using curl or netcat, and will in turn tell systemd about it. As it is, doing a sane daemon in java is impossible without having some JNI fun. > I'm not entirely interested that every language fits perfectly into the UNIX classical "everything's a process / pipe" style model. Ok, how do you propose to tell systemd that your daemon is ready to accept connections?
- kaba0 4y ago> As it is, doing a sane daemon in java is impossible without having some JNI fun And there is a brand new Foreign Memory, Function API in Java (from project panama), which makes it quite possible and ergonomic.
- 4y ago