11 ms·
Rating 26 years of Java changes
- JanisErdmanis 1y ago> if you wanted to store an integer in a collection, you had to manually convert to and from the primitive int type and the Integer “boxed” class I have never worked with Java. What is this? Why would one want to have a class for an Integer?
- morcus 1y agoIt's because the collection types (and generics) don't support primitives, only objects. So you been to stuff the primitives into objects to use them with a lot of the standard library.
- JanisErdmanis 1y agoThat doesn't sound very pleasant.
- dcminter 1y agoWell, it was annoying until autoboxing came in. // Before autoboxing list.add(new Integer(42)); // After autoboxing list.add(42); Mostly it's a non-issue now. If you're desperately cycle/memory constrained you're likely not using Java anyway.
- marginalia_nu 1y agoYou can get pretty good performance out of Java these days, so long as you know to avoid stuff like boxed primitives and the streams api, as they generally have god-awful memory locality, and generally don't vectorize well.
- dcminter 1y agoYeah, I know there are even oddballs using it for HFT and the like - I like Java a lot, but even I find that a bit peculiar. Edit: actually, if someone here is using it for something like that I'd love to hear the rationale...?
- ivan_gammel 1y agoNot „oddballs“ for sure. Java established itself as the primary enterprise language for fintech in 2000s and since then there was and there is no reason to switch. It offers everything business needs including vast supply of workforce.
- marginalia_nu 1y agoI've worked adjacent to that space (high performance fin-tech java), enough that I feel qualified to answer. It's mostly a trade-off. Java's tooling, reliability and ecosystem is some of the best around. Even though building high performance software in Java is a bit of a pain, looking at the bigger picture, it's often still worth it.
- commandersaki 1y agoIf you're desperately cycle/memory constrained you're likely not using Java anyway. Java Cards would like to have a word with you. But yeah I know what you mean.
- Arwill 1y agoThere are libraries, like fastutil, that provide collections for primitive types.
- coldtea 1y agoEither the same of this feature or always hiding the boxing (e.g. a Python int is actually a wrapper object as well, with some optimizations for some cases like interning) is the case in almost all languages.
- JanisErdmanis 1y agoI personally use Julia, which does not have such boxing issues. Rust, C, C++, and Fortran also avoid boxing like this. Perhaps Go is also free from such boxing? Python does it, that's true.
- dcminter 1y agoOne of the more amusing bugs I had to figure out resulted from the fact that some of the autoboxed values get cached, resulting in peculiar behaviour when someone managed to reflectively change the boxed primitive value... i.e. something like: Integer x = 42 highlyQuestionableCode(x); println(x); // "24" WAT? I'm a fan of JEP-500... https://openjdk.org/jeps/500 https://openjdk.org/jeps/500
- raspasov 1y agoI think your intuition is correct: you probably don’t. That’s also very likely changing. Lookup “project Valhalla”. It’s still a work in progress but the high level goal is to have immutable values that “code like a class, work like an int”. PS When I say “changing”: it’s being added. Java tries hard to maintain backward compatibility for most things (which is great).
- iceboundrock 1y agoPrimitive variables in Java, such as `int`, `boolean`, and `double`, store their actual values directly in memory. When they are local variables inside a method, this memory is typically allocated on the thread's stack. These primitives do not have the structure or overhead of an object, including the object header used by the Garbage Collector (GC) to manage heap-allocated objects. If a primitive value must be treated as an object (e.g., when stored in a Java Collection like ArrayList or when passed to a method that requires an object), Java uses a process called `boxing` to wrap the primitive value into an instance of its corresponding Wrapper class (e.g., Integer, Boolean, Double). These Wrapper objects are allocated on the heap and do possess the necessary object header, making them subject to the GC's management.
- wpollock 1y agoAside from this, having such a class provides a convenient place to hold all the int utility functions, and the same for the other primitive types.
- 1718627440 1y agoCan you have a collection of primitives?
- krior 1y agoNo, but yes. There is nothing in the standard library, that implements the Collection-interface and works with primitives. However you can write your own and there are several implementations of collections for primitives. The problem is that you have to implement them seperately for each type of primitive (e.g. an IntList, DoubleList, BooleanList...).
- 1718627440 1y agoCan't you use templates for that, or do these also only work with objects?
- 1y ago
- iceboundrock 1y agoIt appears that most of the good changes are imported from C#.
- sjrd 1y agoOr Scala. Or Kotlin. Or any of the other languages that had most of these features years if not decades before Java. ;)
- marginalia_nu 1y agoYeah that's very much an explicit design philosophy of Java, dating way back. Let other languages experiment, and adapt what proves useful. It hasn't worked out in terms of delivering perfect language design, but it has worked out in the sense that Java has an almost absurd degree of backward compatibility. There are libraries that have had more breaking changes this year than the Java programming language has had in the last 17 releases.
- agos 1y agoWhat other language made them think checked exceptions were a good idea?
- vips7L 1y agoThey are a good idea. Checked errors are so important for correctness. HN’s darling Rust exclusively uses checked errors.
- ahoka 1y agoRust has panic, although intended for “unrecoverable” errors only.
- ivan_gammel 1y agoSome inspiration came from C++, Modula-3, CLU etc. (note, inspiration, not validation of the idea) They exist since v1, which had very different philosophy than Java of 2010s-2020s. 1990s were an interesting time in language design and software engineering. People started reflecting on the previous experiences of building software and trying to figure out how to build better, faster, with higher quality. At that time checked exceptions were untested idea: it felt wrong not to have them based on previous experience with exceptions in C++ codebases, but there were no serious arguments against them.
- dkarl 1y agoDefinitely underrates the impact of annotations. I'm personally not a fan of the way annotations are used to implicitly wire together applications, but I have to admit the impact. Maybe 5/10 is fair in light of the wide range of positive and extremely negative ways annotations can be used. So many of these features were adopted after they were proven in other languages. You would expect that since Java took such a slow and conservative approach, it would end up with extremely polished and elegant designs, but things like streams ended up inferior to previous developments instead of being the culmination. Really disappointing. Java is now a Frankenstein's monster with exactly as much beauty and charm.
- dhosek 1y agoI used to joke that the direction spring was heading was that you’d have an application be a boilerplate main method with a dozen lines of annotations. Then I actually encountered this in the wild: we had an app that sent updates from db2 to rabbitmq, and the application literally was just configuration via annotations and no actual Java code other than the usual spring main method.
- bdangubic 1y agothis is exactly why spring succeeded. I need to run a scheduled job, @EnableScheduling then @Scheduled(cron = “xxxxxx”) - done. I need XYZ, @EnableXYZ the @XYZ… sh*t just works…
- vbezhenar 1y agoYeah, it works until it isn't. And they good luck debugging it. I'd prefer simple obvious linear code calling some functions over this declarative magic any day. cronService.schedule("xxx", this::refresh); This isn't any harder than annotation. But you can ctrl+click on schedule implementation and below easily. You can put breakpoint and whatnot.
- bdangubic 1y agonever had any issues debugging as I am never debugging the scheduler (that works :) ) but my own code. and what exactly is “cronService”? you write in each service or copy/paste each time you need it?
- Supermancho 1y agoCan someone explain why developers like var?
- pgwhalen 1y agoIt reduces (often repetitive) visual noise in code, which can make it more readable. I wouldn’t recommend using it in all cases, but it’s a good tool to have.
- Traubenfuchs 1y agoIt‘s a harmful code smell: It often obfuscates the type, forcing you to actively check for the type and should not be used.
- Supermancho 1y agoThis is what it looks like to me. If you wanted to do this, why not use a scripting language where you can use this kind of practice everywhere? In Java, I don't expect to have to look up the return type of something to discover a variable type. Graciously, I can see how you can save rewriting the Type declaration when it's a function return you want to mutate. Generally, you save some keystrokes to let other people (or future you) figure it out when reading. It seems like bad practice altogether for non trivial projects.
- guax 1y agoModern IDEs will show you the type of anything at all times. I do not understand your point unless you're doing raw text editing of Java source. Those keystrokes are not just saved on writing, they make the whole code more legible and easier to mentally parse. When reading I don't care if the variable is a specific type, you're mostly looking whats being done to it, knowing the type becomes important later and, again, the IDE solves that for you.
- Supermancho 1y ago> Modern IDEs will show you the type of anything at all times. I do not understand your point unless you're doing raw text editing of Java source. The word "String" "Integer" et al. + "var" is too much real estate for being explicit. Sometimes, I'm looking at the decompiled source from some library that doesn't have a source package available. > Those keystrokes are not just saved on writing, they make the whole code more legible and easier to mentally parse. This is incorrect. Repeating it doesn't make it true. For trivial code (<10 lines) probably seems fine at the time. Lots of bad practices start with laziness. Changing practice because an author thinks a function is small enough when it was written, is a recipe for unclean code with no clear guidelines on what to use or expect. Maybe they rather put the onus on a future reader; this is also bad practice.
- haunter 1y agoI'm sorry, please don't hate me (I'm tired and don't have anything better to do) https://files.catbox.moe/ge4el3.png https://files.catbox.moe/ge4el3.png
- rvitorper 1y agoDude, this is awesome
- alex_smart 1y agoWhy so much hate for modules? They seem to be almost universally disliked by everyone on this thread and I don't understand why.
- ivan_gammel 1y agoModules are weird. In Java world there exists consensus on dependency management via Maven-style repositories (Maven Central is the primary distribution channel) and all tools support it. You handle your dependency tree outside of your code and just import packages from libraries available on classpath. It’s possible to continue doing that that without using modules, so the case for using them is still unclear to many people. Where the actual hate may have come from is an old story with migration from Java 8 to Java 9, where modules hidden the access to certain internal APIs, breaking some libraries which relied on them, making that migration painful. Today their value is probably 0/10, but there’s no reason to hate.
- alex_smart 1y agoThe use case for modules is to have a unit of organizing code (deciding what is visible and accessible to who) at a higher level of abstraction than a package. It allows library authors to be much more explicit about what is the public API of their library. Ever wrote "List" in Intellij and instead of importing "java.util.List" Intellij prompts you to choose between like twenty different options from all the libraries you have included in your classpath that have implemented a public class named "List"? Most likely 90% of the libraries did not even want to expose their internal "List" class to the world like that but they got leaked into your classpath just because java didn't have a way to limit visibility of classes beyond packages.
- harladsinsteden 1y agoI don't know what to make of this list... Very strange reasoning and even stranger results: Streams 1/10?! Lambdas (maybe the biggest enhancement ever) a mere 4/10?! Sorry, but this is just bogus.
- tofflos 1y agoI will make any excuse to use Streams but understand the negativity. They are difficult to debug and I feel the support for parallelism complicated, and in some cases even crippled, the API for many common use cases.
- wetpaws 1y ago[dead]
- nunobrito 1y agoI'm that author. It has been more than a decade and still won't use streams nor lambdas. Makes the code too difficult to write and debug for me. Really prefer to have more lines of code and understanding very clearly what each one is doing, than convoluting too many instructions on a single line.
- samus 1y agoI bet you don't like how it looks when you put huge code blocks inside a lambda. Me neither. But that's an issue with coding style; it forces you to extract processing code into a method. I'd argue the opposite way - imperative syntax constructs make spaghetti code too easy to work with.
- harladsinsteden 1y agoFor me it's the opposite: If I had to write the code that I usually use lambdas for in any other way then _that_ would be very difficult to write and to debug. Especially when writing JavaFX code which is full of callbacks and event handlers I really don't see any other (useful) option. Can lambdas be misused? Of course they can - but so can every other code construct.
- 1y ago
- Arwill 1y ago-10 for modules is fair, only 4 for lambdas is not. My programming style changed after using lambdas in Java, even when using a different programming language later that doesn't have lambdas as such.
- MBCook 1y agoLambdas + streams is fantastic. I think if you didn’t have them streams would just be a total mess to use.
- marginalia_nu 1y agoI think the author is sleeping on Java assertions. I really like the feature, and it's really one of the features I feel Java got right. The syntax is very expressive, and they can easily be made to generate meaningful exceptions when they fail. It's also neat that it gives the language a canonical way of adding invariant checks that can be removed in production but run in tests or during testing or debugging (with -da vs -ea). You could achieve similar things with if statements, and likely get similar performance characteristics eventually out of C2, but this way it would be harder to distinguish business logic from invariant checking. You'd also likely end up with different authors implementing their own toggles for these pseudo-assertions.
- rwmj 1y agoI'm quite surprised that he said asserts are not found in production code. Is that really so? I rarely write Java, but in C code we use asserts (in production code) all the time. It's not uncommon for functions to contain 2 or 3 asserts.
- dcminter 1y agoI very rarely see assertions in "real" Java code; I think the author is right - in fact the place I see them the most often is in unit tests where they've been used by mistake in place of an assertion library's methods! I don't know why they're not more popular.
- nunobrito 1y agoGood conversation, I had no idea what assertions are beyond JUnit.
- marginalia_nu 1y agoIf you're only doing like CRUD endpoints, they may be less useful, but that's hardly the extent of Java production code. I certainly use asserts in production code quite a lot in Java, though the use biases toward more low level functions, rarely in high level application logic.
- zylepe 1y agoI haven’t used markdown in javadoc yet but this seems like at least 3/10? I often want to put paragraphs or bulleted lists in javadoc and find myself wanting to use markdown syntax for readability in the code but need to switch to less readable html tags for tooling to render it properly.
- ronyeh 1y agoI hate using html in comments. Markdown in javadoc is at least 7/10 for me. Improves comment readability for humans while allowing formatted javadocs.
- metaltyphoon 1y agoI wish C# would add this too. I despise having to write docs in XML style
- MBCook 1y agoPersonally it’s fine, I haven’t used it though. I really wish Javadoc was just plain text that honored line breaks. I really don’t care about the fact I can put HTML in there, that just seems dumb to me. I get you can’t remove it but I would be happy if you could. I do like markdown. But I don’t see myself ever using it in a Javadoc.
- rsynnott 1y agoI feel this is overly harsh on Collections. You have to take into account just how awful that which it replaced was. > Java Time: Much better than what came before, but I have barely had to use much of this API at all, so I’m not in a position to really judge how good this is. Again, it is hard to overstate just _how_ bad the previous version is. Though honestly I still just use joda time.
- wpollock 1y ago>Again, it is hard to overstate just _how_ bad the previous version [of Java time] is. The original Java Time classes were likely a last-minute addition to Java. They were obviously a direct copy of C language time.h. It feels as if the Java team had a conversation like this: "Darn, we ship Java 1.0 in a month but we forgot to include any time functions!" "Oh no! We must do something!" "I know, let's just port C time.h!"
- MBCook 1y agoIn my mind Java really got usable in 1.5 with collections and generics. When you didn’t have collections everything was a complete pain. But after they were added you still had to cast everything back to whatever type it was supposed to be when you got stuff out of collections. Which was also a huge pain. I know all the arguments about how genetics weren’t done “correctly“ in Java. I’ve run into the problems.But I’m so glad we have them.
- zkmon 1y agoApplets (Java 1.1 - that's where I started), Servlets (Together with MS ASP, JSP/Servlets have fuelled the e-commerce websites) I think Java dominated the scene mostly because of its enterprise features (Java EE) and the supporting frameworks (Spring etc) and applications (Tomcat, Websphere, Weblogic etc) and support from Open source (Apache, IBM)
- foolfoolz 1y agothe biggest things to change java have been type inference, lambdas, records, streams (functional ops on collections), and pattern matching. these are all must-have features for any modern programming language. at this point any language without these features will feel old and legacy. it’s impressive java was able to add them all on decades after release, but you do feel it sometimes
- newAccount2025 1y agoFor my part, returning to Java a couple years back after 15+ years away, streams + var/val were my favorite discoveries.
- sedro 1y agoAutoboxing's evil twin, auto-unboxing should knock the score down a few points. Integer a = null; int b = 42; if (a == b) {} // throws NullPointerException
- deleted 1y ago[deleted]
- dcminter 1y agoOr my favourite... Short w = 42; Short x = 42; out.println(w == x); // true Short y = 1042; Short z = 1042; out.println(y == z); // false
- prein 1y agoOnce, after we had an application go live, we started getting reports after a few hours that new users were unable to log in. It turns out, somewhere in the auth path, a dev had used `==` to verify a user's ID, which worked for Longs under (I believe) 128, so any users with an ID bigger than that were unable to log in due to the comparison failing.
- sedro 1y agoThat's another gotcha-- interning of strings and boxed primitives. Are there linters for this sort of thing? I don't write Java much any more.
- dcminter 1y ago> Are there linters for this sort of thing? Yes and they're pretty good so it's rarely an issue in practice. Using == on object references will indeed usually get you yelled at by the linter.
- MBCook 1y agoI’ll say from experience that even if your IDE highlights that by default people won’t pay any attention to it and the bug will get in. I’ll be happy when it’s fixed.
- tombert 1y agoInteresting; I actually have grown pretty fond of NIO. I will acknowledge that the interface is a bit weird, but I feel like despite that it has consistently been a "Just Works" tool for me. I get decent performance, the API is well documented, and since so many of my coworkers have historically been bad at it and used regular Java IO, it has felt like a superpower for me since it makes it comparatively easy to write performant code. Granted, I think a part of me is always comparing it to writing raw epoll stuff in C, so maybe it's just better in comparison :)
- cesarb 1y agoThere's one thing I deeply dislike with Java NIO: ClosedByInterruptException. If a thread is interrupted (for instance, due to a future.cancel(true) or similar), and it happens to be in the middle of a NIO operation, the channel will be closed, even if it's not owned by that thread. That single thing makes using NIO far more brittle than the older Java IO.
- simonklee 1y agojava.util.Date and java.util.Calendar are the two packages I remember struggling with as a new programmer. Which I guess is solved with java.time after Java 8.
- b_e_n_t_o_n 1y agoI haven't written much Java but I am learning Kotlin and I really appreciate the language and the whole JVM ecosystem. Yeah yeah, Gradle is complicated but it's waaaaay easier to figure out than my adventures with Cmake, and when I read Java code there is a certain comfort I feel that I don't get with other languages, even ones I'm experienced with like Go. Java feels a bit like a stranger I've known my whole life, same with Kotlin. Perhaps despite all its flaws, there is a certain intrinsic quality to Java that has helped make it so popular.
- dcminter 1y agoMaven was peak Java build tool. I detest Gradle. Some people just hate XML enough to doom us all.
- MBCook 1y agoI wouldn’t say I’m a fan of maven, but it is absolutely one of the best build/dependency tools I’ve ever used despite its warts. So many things, even if they came much later, are somehow much worse.
- Defletter 1y agoCan't speak for everyone, but I think a substantial part of the shift from Maven to Gradle was the ability to write build scripts: you didn't need to write a plugin. I'm hoping that Maven (and Gradle) can take advantage of JEPs 458 and 512 to allow people to write build scripts for that Java projects in Java. - https://openjdk.org/jeps/458 https://openjdk.org/jeps/458 - https://openjdk.org/jeps/512 https://openjdk.org/jeps/512
- dcminter 1y agoAnt had the ability to write build scripts. It's part of what made Ant such a terrible build tool and IMO it's what makes Gradle such a terrible build tool. Maven's requirement that you write plugins meant that you had to have a decent understanding of the conventions that Maven brought to the table before you could inflict some monster on the world. In Gradle you can do something quick to get your idea working how ever terrible it is and however much it defies convention or breaks the expectations of anyone coming to the project later on.
- MarkMarine 1y agoI’m sure there are better ways to do streams on the JVM, scala being a great example, but however imperfect the implementation is streams are such a net positive I can’t imagine the language without them. I pine for the streams API when I write go.
- MBCook 1y agoI totally agree with the criticism about exceptions. If you need exceptions inside a stream it turns into a mess. Overall I agree with you. They are significantly better, even if a little verbose, than not having them. Love cleaning up old loops with a tiny stream that expresses the same thing more compactly and readably. He’s also right on the parallel benefits not really being a thing I’ve ever seen used.
- peterashford 1y agoI'm in agreement, too. The intersection of streams and exceptions was not pretty. Streams are still good, but the feature is a little ugly
- AbuAssar 1y agoso java 22, 23, 24 are all released in 2024?
- dcminter 1y agoNo, it's a 6 month release cadence. You might be confusing the initial release with a point release which are less regular. Edit: oh, my bad, I see the article author had the wrong year for 24. 22 was March 2024 23 was September 2024 24 was March 2025 25 was September 2025 This is much better than the old "release train" system where e.g Java 5 and Java 6 were released in Sept 2004 and Nov 2006 respectively!
- linuxhansl 1y agoDidn't Java 1.3 (Sun's JDK) introduce the JIT? I remember talking to colleagues about what a joke Java performance was (we were working in C++ then). And then with Java 1.3 that started to change. (Today, even though I still C++, C, along with Java, I'll challenge anyone who claims that Java is slower then C++.)
- hashmash 1y agoThe first official JIT became available in JDK 1.1, in 1997. The Symantec JIT was available as an add-on sometime in mid 1996, just a few months after JDK 1.0 was released. Even better performance was possible with GCJ, available in 1998. The release of HotSpot was in 1999, and became default with JDK 1.3 in 2000. It took JIT compilation to the next level, making tools like GCJ mostly obsolete.
- winternewt 1y agoMaybe not slower once it has warmed up, though for memory-bandwidth bound use cases I would still say the lack of mutable records has you fighting the language to get reasonable cache locality (and everybody will hate your code for not being good Java). The fact that everything is a pointer kills the CPU execution pipeline and cache. But even for I/O bound applications it still feels slow because excessive memory usage means more swap thrashing (slowing down your entire OS), and startup time suffers greatly from having to fire up VM + loading classes and waiting for the JIT to warm up. I can start a C/C++/Rust based web server in under a second. The corresponding server in Java takes 10 seconds, or minutes once I have added more features.
- brap 1y agoWow I can’t believe try with resources is so old! I’ve been working with Java for years and only learned this exists recently, I thought it must be relatively new. 14 years!
- dcminter 1y agoIt was such a lifesaver for doing raw database stuff. The boilerplate for making sure Connection, PreparedStatement, ResultSet and so on were all released properly was a huge pain before that.
- MBCook 1y agoDespite it being available at the time I too didn’t learn it until much later. I really wish I had known.
- travisgriggs 1y agoAh Java. The language I never got to love. I came of coding age during the “camps” era of object oriented stuff: Eiffel, Smalltalk, CLOS, C++, etc. Java, from 95ish to oh 98ish, was like a giant backdraft. Completely sucked the air out of the room for everything else. Does anyone remember the full page ads in WSJ for programming language, that no on quite yet knew what it really was? So my formative impressions of Java on were emotional/irrational, enforced by comments like: “Of Course Java will Work, there’s not a damn new thing in it” — James gosling, but I’ve always suspected this might be urban legend “Java, all the elegance of C++ syntax with all the speed of Smalltalk” - Kent Beck or Jan Steinman “20 years from now, we will still be talking about Java. Not because of its contributions to computer programming, but rather as a demonstration of how to market a language” — ?? I can code some in Java today (because, hey, GPT and friends!! :) ), but have elected to use Kotlin and have been moderately happy with that. One thing that would be interesting about this list, is to break down the changes that changed/evolved the actual computation model that a programmer uses with it, vs syntactic sugar and library refinements. “Languages” with heavy footprints like this, are often just as much about their run time libraries and frameworks, as they are the actual methodology of how you compute results.
- hoolajoop2 1y ago> I can code some in Java today (because, hey, GPT and friends!! :) ), I love GPT. Such a marvellous tool. Before ChatGPT came along, I had no medical experience. Thanks to GPT and friends, I am now a doctor. I've opened a clinic of my own.
- KyleBerezin 1y agoFor whatever reason, gpt-5 writes java code like it is 1995. I think it was trained on decompiled code.
- laughing_man 1y agoIn the early days javascript wasn't far enough along that you could make a web app without a lot of compromises, and the cross-platform nature of java was a big, big plus. I worked on an internal java client application that was developed on Linux for end users on PC. Ten years after we released the first version, and while it was still under development, a group of powerful managers at our company demanded they be issued Macs instead of the PC corporate standard. When IT asked us if our application worked on Mac, we shrugged and said "We don't have a Mac to test it. We've never run it on a Mac. We won't support it officially, so if there are Mac specific bugs you're on your own. But... it should work. Try it." And it did work. All the Mac users had to do was click on our Webstart link just like the PC users. It installed itself properly and ran properly. Never had a single issue related to the OS. Before Java was introduced that was an unobtainable dream in a full-featured windowed application.
- rr808 1y agoJava is great, Spring ruined the platform.
- __float 1y agoAs someone who has used Java pretty extensively for a few years (but in an environment where Spring was forbidden), why is that?
- MBCook 1y agoYou’ll find differing opinions. As someone who has worked on code bases that did not have spring that really should have and had to do everything manually: when used well it’s fantastic. Now people can certainly go majorly overboard and do the super enterprise-y AbstractBoxedSomethingFactoryFacadeManagerImpl junk. And that is horrible. But simple dependency injection is a godsend. Ease of coding my just adding an annotation to get a new component you can reference anywhere easily is great. Spring for controllers when making HHTP endpoints? And validation of the data? Love it! Some of the other modules like Spring Security can be extremely confusing. You can use the Aspect Oriented Programming to go overboard and make it nearly impossible to figure out what the hell is happening in the program. Spring is huge, and it gets criticized for tons of the more esoteric or poorly designed things it has. But the more basic stuff that you’re likely to get 90+ percent of the value out of really makes things a lot better. The relatively common stuff that you’ll see in any Spring Boot tutorial these days.
- rr808 1y agoActually I really dont like DI and its a core of my dislike. I can easily create objects directly and pass in dependencies, its a lot easier to debug and see what is going on as opposed to Spring magic.
- noisy_boy 1y agoI mean if you just follow the common usage patterns of Spring Boot, it is not really magic - just stick to the core annotations and not more. It does require one to have basic familiarity with Spring Boot but I don't think that is an unreasonable ask. And like many things, people can go totally overboard and make it an impenetrable mess but I think that is on the programmer, not the framework.
- taspeotis 1y agoWhich release did they add the URL class that checks for equality by connecting to the internet? 10/10
- pixelmonkey 1y agoA cool thing about Doug Lea's java.util.concurrent (received a 10/10 rating here) is that its design also inspired Python's concurrent.futures package. This is explicitly acknowledged in PEP 3148[1] (under "Rationale"), a PEP that dates back to 2009. [1]: https://peps.python.org/pep-3148/ https://peps.python.org/pep-3148/
- swuecho 1y agoThat is why I think of java when using python's concurrent.future package.
- nunobrito 1y agoFully agree with most votings but 3/10 text blocks?! That has got to be one of the most useful recent features. :-) The pleasure of just copying and paste text in plain ASCII that looks as intended rather than a huge encoded mess of "\r\n"+ concatenations. But ok, I'm just an ASCII art fan. ^_^
- MBCook 1y agoString sql = “Not having “ + “to break up “ + “SQL statements” + “like this for readability “ + “thus making them hard to edit “ + “was incredibly useful at my job.”; (Note: I put a subtle bug in there because it always happened) SQL injection is horrible, but people were managing to do that all these years after prepared statements anyway without text blocks. I really don’t think they made things worse. Same thing with embedding HTML in the code. They were gonna do it anyway.
- 1718627440 1y ago> Note: I put a subtle bug in there because it always happened No space between "statements" and "like"?
- w10-1 1y agoIt's nice to review the features, but the history of Java isn't really about features or even programmer popularity. (1) It was the first disruptive enterprise business model. They aimed to make everyone a Java programmer with free access (to reduce the cost of labor), but then charge for enterprise (and embedded and browser) VM's and containers. They did this to undercut the well-entrenched Microsoft and IBM. (IBM followed suit immediately by dumping their high-end IDE and supporting the free Eclipse. This destroyed competition from Borland and other IDE makers tying their own libraries and programming models.) (2) As an interpreted language, Java became viable only with good JIT's. Borland's was the first (in JDK 1.1.7), but soon Urs Holzle, a UCSB professor, created the HotSpot compiler that has seeded generations of performance gains. The VM and JIT made it possible to navigate the many generations of hardware delivering and orders-of-magnitude improvements and putting software in every product. Decoupling hardware and software reduced the vertical integration that was killing customers (which also adversely affected Sun Microsystems). btw, Urs Holzle went on to become Google employee #8 and was responsible for Google using massively parallel off-the-shelf hardware in its data centers. He made Google dreams possible.
- oofbey 1y agoThe business plan originally was to sell CPUs that ran Java natively. And these would be fast. That idea failed miserably.
- fleventynine 1y agoStill no unsigned integer types in the standard library after 26 years?
- MBCook 1y agoIt’s rare I have to do bit math but it’s so INCREDIBLY frustrating because you have to do everything while the values are signed. It is amazing they haven’t made a special type for that. I get they don’t want to make unsigned primitives, though I disagree, but at least makes something that makes this stuff possible without causing headaches.
- hashmash 1y agoSometimes I'd like to have unsigned types too, but supporting it would actually make things more complicated overall. The main problem is the interaction between signed and unsigned types. If you call a method which returns an unsigned int, how do you safely pass it to a method which accepts a signed int? Or vice versa? Having more type conversion headaches is a worse problem than having to use `& 0xff` masks when doing less-common, low-level operations.
- fleventynine 1y ago> If you call a method which returns an unsigned int, how do you safely pass it to a method which accepts a signed int? The same way you pass a 64-bit integer to a function that expects a 32-bit integer: a conversion function that raises an error if it's out of range.
- hashmash 1y agoThis adds an extra level of friction that doesn't happen when the set of primitive types is small and simple. When everyone agrees what an int is, it can be freely passed around without having to perform special conversions and deal with errors. When trying to adapt a long to an int, the usual pattern is to overload the necessary methods to work with longs. Following the same pattern for uint/int conversions, the safe option is to work with longs, since it eliminates the possibility of having any conversion errors. Now if we're taking about signed and unsigned 64-bit values, there's no 128-bit value to upgrade to. Personally, I've never had this issue considering that 63 bits of integer precision is massive. Unsigned longs don't seem that critical.
- zeroq 1y agoJoshua Bloch's work on Collections for Java2 was absolutely formative for me. I was just starting real programming, I knew naming was hard so I was using thesaurus almost as extensively - if not more - than the reference manual. But his work defined designing API for me for life. Stuff we take for granted, and we often overlook as seemingly trivial. Let's say you have a collection type that has a method ``put``. It takes two arguments - an object you want to insert, and an index you want to put it at. Which argument should go first? Could index be optional? What value should it default to? Does the function returns anything? A boolean to indicate whether insertion was successful? Or the index at which the object was put? If latter how you indicate an error? All of these seems seemingly trivial but he and his team worked on that library for over a year and he throughly documented their work in series of presentations. And we can't forget about his java puzzlers, absolute gem.
- parallax_error 1y agoI can’t believe lambdas got a 4/10! I’m a student so maybe my opinion will change when I work on “real” code but I really like their conciseness
- peterashford 1y agoI've been a developer for over three decades now and I agree with you - Lambdas are really good.
- 1a527dd5 1y agoI owe Java a lot. Programming clicked for me when I was taught OOP in Java, my other programming module with event-driven design in C# which I hated. Fast forward a few years later, and I'm actually at a C# shop. Fast forward a decade, I'm at the same shop. I adore C# and I fondly remember my foray into Java. I left Java around the time Streams were becoming a thing. I thought it looked like a mess, and then I ran into LINQ in C# land. Swings (pun intended) and roundabouts.
- yousfzaxoy88 1y agoZaxo
- SerCe 1y agoMy read is that it's easy to be quite negative on Java features when you're not the person they were designed for. For example, the main "customer" of the module system is the JDK itself. The main customer of NIO/2 is the low-level libraries like Netty. I highly recommend the Growing the Java Language talk by Brian Goetz to anyone who's interested in the philosophy behind evolving the modern Java language [1]. And Don’t be misled by the title, it’s not just about Java, it’s about software design. [1]: https://www.youtube.com/watch?v=Gz7Or9C0TpM https://www.youtube.com/watch?v=Gz7Or9C0TpM
- paulddraper 1y agoYeah modules isn’t for end users, at least not for the most part
- adgjlsfhk1 1y agomodules get a -10 because they were massively breaking
- executesorder66 1y ago>For example, the main "customer" of the module system is the JDK itself As mentioned in TFA, "The general advice seems to be that modules are (should be) an internal detail of the JRE and best ignored in application code" So yeah, why expose it to those who are not the "main customer"?
- vips7L 1y agoIt’s just too complex. They should have went with the internal modifier.
- SerCe 1y ago> So yeah, why expose it to those who are not the "main customer"? How did modules affect you as a user? I'd guess that you had to add `--add-opens`/`--add-exports` during one of the JDK migrations at some point. And the reason you had to do it was that various libraries on your classpath used JDK internal APIs. So modules provided encapsulation and gave you an escape hatch for when you still have to use those libraries. How else would you do it while still achieving the desired goal?
- anotherevan 1y agoDon't know what version it was, but default functions in interfaces I think is an underrated feature that comes in extremely useful on occasion.
- lenkite 1y agoSorry, but several of these ratings are just plain wrong. I am not even a Java developer these days, but it is extremely clear that author did not work in a domain that rightfully leveraged the Java features he rates as of little use. He would have been better served by opening a poll - that would have opened his eyes to the use of these features. Its like giving operator overload a rating of 1 in C++/Python. Sure, if you don't find any need for it in your domain, it would look stupid to you.
- hdpe 1y agoGreat list, even if I disagree with many of the ratings! But astonished that Optional isn't mentioned either there or in the comments. A second way to represent no-value, with unclear and holy-war-ushering guidance on when to use, and the not exactly terse syntax I see everywhere: Optional<Ick> ickOpt = Optional.ofNullable(ickGiver.newIck()); ickOpt.flatMap(IckWtfer::wtf).ifPresentOrElse((Wtf wtf) -> unreadable(wtf)), () -> { log.warn("in what universe is this clearer than a simple if == null statement?!"); });
- skribanto 1y agoWell, it can make some chained function composition easier. Ick1 result1 = potentiallyNull1(); Ick2 result2 = (result1 == null) ? null : potentiallyNull2(result1); Ick3 result3 = (result2 == null) ? null : potentiallyNull3(result2); vs Ick3 result3 = potentiallyNone1() .flatMap(potentiallyNone2) .flatMap(potentiallyNone3); You could maybe move the null check inside the method in the former and it cleans it up a bit, but in the latter you can have methods that are explicitly marked as taking NonNull in their type signature which is nice.
- munksbeer 1y agoI don't grumble about Java much, I make my living with it and enjoy it. But Optional is a bane. We use NullAway and I just never use Optional unless it really, really makes sense.
- adben 1y agoA little bit bias and opinionated... Tho limited, lambdas and streams were a paradigm shift so big that revamped the love for java into functional programming... Not just a set of features introduced in Java 8.
- pachouli-please 1y ago>little bit bias and opinionated Well, we are reading an individual's blog after all.
- uliqquel 1y agoI use Java time a lot and yes it has to be that complex. One of my favourite examples is Duration vs Period. They are just not the same once you factor in timezones. And I like that they make it difficult for you to mess that up, although I'm sure there is a way.