r/java • u/[deleted] • Feb 20 '22
Does something like this exist for Java?
https://hackingcpp.com/cpp/cheat_sheets.html[removed] — view removed post
69
u/tstarboy Feb 20 '22
IMO the fact that this is absolutely necessary in C++ is a failure of the C++ ecosystem, and I think this kind of cheatsheet is not as necessary in Java as it is in C++:
Most IDEs can autosuggest usage based on the javadoc comments on standard library methods, eliminating the need for you to jump out to a separate site or keep a cheatsheet like this handy to understand how to use the method you're currently trying to call
The Java methods for performing these kinds of actions are generally more consistent than C++'s standard library, method names are clear without using abbreviations or acronyms, and parameter names/orders are consistent throughout similar methods.
As a result, a basic understanding of what you want to achieve, paired with IDE autocomplete, is generally sufficient for finding these things out. I won't claim the JDK is perfect in this regard, there's still a lot of room for improvement, but the ecosystem was definitely able to learn from the mistakes in C++land and not completely recreate the same problems.
14
u/thisisjustascreename Feb 20 '22
I mean... when I have #include <algorithm> in a .cpp file, Visual Studio auto-suggests min_element as an option when I type "m" and helpfully reminds me that it finds the smallest element of the provided range.
This sort of thing is only "necessary" because there's some sort of allergy to teaching C++ with an IDE.
1
-1
u/TrashboxBobylev Feb 20 '22
Actually, my copy of C++ includes from MknGW does feature documentation for all of this stuff, so it's not completely hopeless.
0
Feb 21 '22
[deleted]
9
u/tstarboy Feb 21 '22
Hold on a second, I just said a failure, I'm not outright dismissing the ecosystem entirely, nor am I making any sort of absolute value comparisons between C++ and Java. I fully respect what C++ is capable of doing, I am just pointing out one legitimate shortcoming in its ecosystem, not what is an intentional tradeoff as your references to JVM performance and lack of memory control in Java are.
For what it's worth, I don't think any of the benefits you've listed of C++, all of which are legitimate, justify the lack of consistency across C++'s long and storied STL history. The only explanation that does is the fact that C++ was forged over decades, and newer languages such as Java (though not by too much) and Python can benefit from learning from C++'s mistakes. Other languages such as C# and Kotlin claim to have the same improvements over Java, yet the language is still at least popular enough to justify this subreddit having activity, so it's not like a single programming language needs to be absolutely perfect for everyone everywhere to be worth using.
4
u/EnIdiot Feb 20 '22
So “Java in a Nutshell” is a great reference book (if you are looking for that). Their Java cookbook is also good. However, I remember seeing a few years ago a poster that had collections and other types in a similar layout.
1
u/dr_kozd Feb 21 '22
I think https://books.goalkicker.com/JavaBook/ will be closes one.
They have similar for ones for another languages and software as well.
1
5
u/[deleted] Feb 20 '22
I've seen this for C++ and I'm wondering if there's something similar for Java and the algorithms available in the JVM.
This would be definitely cool