News for hackers. Stuff that matters.
Re:Why I Like Java (2014) by smoyer on Monday February 21, 2022 @08:39AM (#30415727)
You can write a pretty trivial Java program to copy stdin to stdout but Java is still one of the enterprise languages and people writing enterprise applications don't tend to write this type of software (but they do tend to have log4j vulnerabilities). The strengths of Java are its mature dependency management system(s), its comprehensive standard library and the vast ecosystem of third-party libraries. A better test of the language is whether you can write a complicated application in relatively fewer lines of code.

I spent much of my career writing Java code but have moved to Go - it's almost a return to my roots as an embedded systems engineer (without the memory management hassles of C) and it's vastly more economical to run Go applications in containers. I do find myself writing code that I used to pull in from a library though.

Re:Why I Like Java (2014) by kitd on Monday February 21, 2022 @09:19AM (#30416120)
A better test of the language is whether you can write a complicated application in relatively fewer lines of code.

To a point. In many situations, a better test is whether a coder unfamiliar with said complicated application can maintain it relatively easily.

Re:Why I Like Java (2014) by AtlasBarfed on Monday February 21, 2022 @11:38AM (#30417714)
Re:Why I Like Java (2014) by JavaOnlyGuy on Monday February 21, 2022 @08:57AM (#30415907)
No isNullOrEmptyString method, no Set operations, Java didn't have a good HTTP library until Java 11, no lazy file reading, unless you use InputStream which is a pain.

vast majority of mediocre libraries and one man libraries. We use Spring because it uses the best libraries, so the other ones are discarded.

Java being around for so long doesn't have a lot of convenience methods like others do languages do, like the ones I mentioned in the beginning.

So no, Java is a half assed programming language which C# and NET CORE should replace

Re:Why I Like Java (2014) by fesc on Monday February 21, 2022 @11:46AM (#30417817)
I think Kotlin has the utility methods you have in mind.

Im not saying C# is bad as I don‘t have experience with it, just that Kotlin is a more realistic replacement for most Java shops.

Re:Why I Like Java (2014) by ludovicianul on Monday February 21, 2022 @01:34PM (#30419058)
Java didn't have all these things, because there were a lot of very good libraries already doing that. Adding them inside a project is trivial. I think this approached encouraged creating alternatives to the standard APIs as well as extensions which in the end made the language even more rich.
Re:Why I Like Java (2014) by stepbeek on Monday February 21, 2022 @11:31AM (#30417639)
What’s C# and .Net really like on Linux now? I know Microsoft says it’s great but I’m once bitten twice shy after trusting that Azure would be good.

I am happy to try different languages but I will never again support a Windows Server over a Linux VM.

Re:Why I Like Java (2014) by binarynate on Monday February 21, 2022 @12:45PM (#30418494)
I use .NET 6 on Amazon ECS (Amazon Linux), and it's a pleasure to work with. The dotnet CLI makes running and building super easy. So, I just develop with VS Code and a terminal on macOS and deploy to AWS.
Re:Why I Like Java (2014) by tester756 on Monday February 21, 2022 @01:08PM (#30418752)
I have C# web apps hosted on Linux for something like 2-3 years and it works very fine
Re:Why I Like Java (2014) by DeathArrow on Tuesday February 22, 2022 @04:05AM (#30425604)
At last workplace we developed microservices running on Kubernetes using Redis and Postgres as databases. Integration with Elastic Search, Kibana, Datadog were a breeze.
Re:Why I Like Java (2014) by bombcar on Monday February 21, 2022 @08:47AM (#30415799)
Java is supportable in that I can get older code to build and run on Java8 still - may need a gradle update or some other minor stuff but it works.

So many other abandoned programs seem to become unbuildable pretty quickly.

Re:Why I Like Java (2014) by Un1corn on Monday February 21, 2022 @11:11AM (#30417404)
I'm really not sure I would call Java's standard library comprehensive. I've only worked with it for a few months but needed many Apache commons libraries.
Re:Why I Like Java (2014) by AtlasBarfed on Monday February 21, 2022 @11:44AM (#30417781)
By the standards of the day, when Java was released it's standard library was pretty comprehensive: in addition to covering most of the c-ish stdlib, it had networking and web-aware apis.

It did set a new standard in a way that was very beneficial for the languages that came after it: you're not an ACTUAL language if you don't have a "good" standard library, and I can argue that "good" was defined by Java more than C++ or anything else at the time.

I also don't see any new languages, while more modernized, that have substantially pushed the envelope further to be the new gold standard of a minimum batteries included stdlib. All I could probably say is various threading/concurrency apis, but Java has added a lot of that too over the years.

Re:Why I Like Java (2014) by lostcolony on Monday February 21, 2022 @12:58PM (#30418631)
HTTP as well. Added in Java 11 (2018), but that's still an insanely long time to rely on third parties.
Re:Why I Like Java (2014) by jalk on Monday February 21, 2022 @02:09PM (#30419436)
com.sun.net.httpserver was added in Java 1.6 (2006) - comparable to the Python httpserver
Re:Why I Like Java (2014) by lostcolony on Monday February 21, 2022 @06:36PM (#30422197)
Hence why I said "http", as in java.net.http, as in, everything around an HTTP client.
Re:Why I Like Java (2014) by jimbokun on Monday February 21, 2022 @11:43AM (#30417766)
Which falls under the heading of "mature dependency management system". Apache Commons (or Google Guava) is pretty much considered part of the standard library at this point, as they are so easy to include in projects.
Re:Why I Like Java (2014) by mqus on Monday February 21, 2022 @07:29PM (#30422658)
What you say is true but at the same time its one of the very few languages to include an entire cross-platform UI-Framework in the stl.
Re:Why I Like Java (2014) by sorokod on Monday February 21, 2022 @09:36AM (#30416308)
The domain and the developers that inhabit that domain should be separated from the language. Below is the repo of the companion Java code to Sedgewick's "Algorithms" - make of it what you will.

https://github.com/kevin-wayne/algs4/tree/master/src/main/ja...

Re:Why I Like Java (2014) by benjamir on Monday February 21, 2022 @01:37PM (#30419104)
Thanks, I have another "Sedgewick" and wasn't aware of the repo (not in immediate need of it, but nice anyway!)
Re:Why I Like Java (2014) by klysm on Monday February 21, 2022 @02:51PM (#30419816)
I cannot stand go almost solely because it’s error handling. We have the ability to do so much better.
Re:Why I Like Java (2014) by kingkongjaffa on Monday February 21, 2022 @08:42AM (#30415750)
People say this but where do you find libs for Java?

Python has pip,

JS/Node has NPM

Re:Why I Like Java (2014) by throwaway2037 on Monday February 21, 2022 @09:39AM (#30416337)
To compliment most other posters, they would use Maven Central: https://search.maven.org/

Here is an example library from Google called "Guava": https://search.maven.org/artifact/com.google.guava/guava/31....

You can find the source code on GitHub: https://github.com/google/guava

On the right side of the page, you can find eleven (!) different wants to include this dependency (and) all of its transitive dependencies with just a few lines of configuration.

Here is a list of the Top 10 downloads of open source Java libraries: https://mvnrepository.com/popular?p=1

Re:Why I Like Java (2014) by coldtea on Monday February 21, 2022 @08:46AM (#30415784)
>People say this but where do you find libs for Java?

Everywhere, on the lib website, on GitHub, on Apache, etc. (including centralized places like Maven Central). You then put a ferences in your Maven or Gradle file like you would in your package.json.

In fact, because for 99% of the libraries you just need to have a jar (or more) in your classpath, you don't have to have all the ceremony that Python has, and all the installation mess, venvs, and other such shite.

Re:Why I Like Java (2014) by Macha on Monday February 21, 2022 @09:55AM (#30416515)
Until you end up with dependencies transitively pulling in conflicting versions of Jackson or similar and you need to mess around with dependencyManagement or exclusions.
Re:Why I Like Java (2014) by dionian on Monday February 21, 2022 @01:45PM (#30419209)
Transitive dependency trees are a feature, not a bug
Re:Why I Like Java (2014) by smoyer on Monday February 21, 2022 @08:57AM (#30415903)
> JS/Node has NPM

If this isn't a joke, I'd suggest learning the Maven or Gradle build systems. NPM has such horrible dependency management that these Java systems will seem like magic!

Re:Why I Like Java (2014) by da39a3ee on Monday February 21, 2022 @10:27AM (#30416874)
OK, so I'm trying out maven central as people in this thread are recommending. As an example, I'm searching for a command line argument parser.

The first thing I'm noticing is that there seems to be no way to judge the popularity of the libaries (an often-used proxy for quality, e.g. number of downloads, GitHub stars, etc).

I enter "argparse" and the first hit isn't even Java! It seems to be a npm package?? https://search.maven.org/artifact/org.webjars.npm/argparse

I enter "argument parser" and there are two hits. One with zero stars on Github and one with 1 star.

https://search.maven.org/artifact/com.github.easy-develop/ar...

https://search.maven.org/artifact/com.github.raphcal/argumen...

"command line" brings up another 0 star option: https://github.com/AlmondBranch/command-line-parser

I suppose the Java package ecosystem must be good if everyone says it is, but so far it looks to me like I'd find Maven Central very inefficient to discover high quality packages.

Re:Why I Like Java (2014) by Katharsas on Monday February 21, 2022 @12:01PM (#30417967)
Maven Central is the place where the libraries are hosted, but not the place where they are found by users. Use Google/Stackoverflow/Reddit and simply search for what you want.

Searching for "command line argument parser java" immediately leads you to libraries and infact lists of libraries (see https://stackoverflow.com/a/7829772), of which most are going to be available on Maven Central.

Then you do your research that the library you are looking at looks valid and is trustable (!) by checking out the info available on it, maybe make another search to find opinions on it.

Then when you have decided to try it, look at its docs to find out where it s located on Maven Central and use it from there.

Re:Why I Like Java (2014) by kklisura on Monday February 21, 2022 @01:10PM (#30418786)
I think you're searching in the wrong place. The first search result for "argument parser maven" in google search yields this [1] - an ordered list of maven dependencies for "Command Line Parsers".

[1] https://mvnrepository.com/open-source/command-line-parsers

Re:Why I Like Java (2014) by zmmmmm on Monday February 21, 2022 @04:07PM (#30420637)
mvnrepository.com is good for what you are describing [1]. For example, searching for "command line" brings up the clear top favorite and tells you the number of usages:

https://mvnrepository.com/search?q=command+line

[1] https://mvnrepository.com/

Re:Why I Like Java (2014) by chakkepolja on Monday February 21, 2022 @10:25AM (#30416860)
IMO maven is much better than gradle these days. Indeed maven or go dependency management is refreshing after you run create-react-app or shit like that.
Re:Why I Like Java (2014) by the_af on Monday February 21, 2022 @08:55AM (#30415878)
The Java ecosystem of libraries is huge, it used to be one of the largest ones. I don't know how it competes today with Python and JS, but Java certainly doesn't lack libraries for almost anything you can think of.

Also: Maven Central.

Re:Why I Like Java (2014) by tannhaeuser on Monday February 21, 2022 @10:29AM (#30416899)
Err ... the npm authors (the CommonJS modules/packages spec writers for package.json) mention maven and CPAN in their design docs and discussions as reference. Many of the early Server-side JavaScript adopters (in the 2000's before Node.js but well after Netscape's server-side JavaScript) were, in fact, Java/J2EE dropouts longing for something simpler.

[1]: http://wiki.commonjs.org/wiki/Packages/1.0

Re:Why I Like Java (2014) by thrower123 on Monday February 21, 2022 @11:03AM (#30417326)
One of the nice things about Java and C# is that they tend to have "chunkier" dependencies, that aren't split out into an interlocking tree of dependencies deep and wide.

For the most part, anyway... Things are kind of gross if you are trying to use newer nuget packages on the old 4.8 .net framework...

Re:Why I Like Java (2014) by mindcrime on Monday February 21, 2022 @09:09AM (#30416022)
In Java-land most people build and do dependency management with Maven or Gradle. In either case, these tools can pull from repositories based on the Maven format. The vast majority of popular libraries are in repo "Maven Central" and "just work" if added to your dependency list. A number of smaller, more specialized repos also exist, and it's trivial to add additional repos to your Maven/Gradle config as well.

You can search for libraries on mvnrepository.com, or your IDE can search the index. Also most libraries will include a section in the documentation that shows the details of the blob you have to put in your pom.xml / build.gradle file.

Re:Why I Like Java (2014) by tlarkworthy on Monday February 21, 2022 @08:43AM (#30415757)
Maven central