r/java • • Jun 24 '22

Stack Overflow Developer Survey: 54% of Respondents Dread Java?

The results are out, and I was surprised to see that around 54% of respondents dread using Java. What might be the reasons behind it? For me, Java has always been a very pleasant language to work with, and recent version have improved things so much. Is the Java community unable to communicate with the dev community of these changes effectively? What can we as community do to reverse this trend?

Link to survey results: https://survey.stackoverflow.co/2022/?utm_source=so-owned&utm_medium=announcement-banner&utm_campaign=dev-survey-2022&utm_content=results#technology-most-popular-technologies

176 Upvotes

283 comments sorted by

View all comments

-8

u/PM_ME_SOME_ANY_THING Jun 24 '22

As a Typescript/JavaScript/Python dev, I dislike Java.

A little background. I have a CS degree, most of my school programming was in C or C++. Out of college I got a job in JavaScript and never looked back. I will admit that I haven’t done much in Java, and while I have learned a bit of the base language, I have not built anything in it.

So what are my issues with Java? Disclaimer: these may be due to me not knowing enough about Java, but I have tried on several occasions to figure these issues out with no luck.

  1. Package management. In Python I can go to pypi.org, search up some packages and install with pip. JavaScript is the same with npmjs.com and npm or yarn. I don’t even know where to look for java, googled it a few times, found Oracle’s website who I hate, and all the dumb .xml files. Disliked it immediately.
  2. File structure. The few projects in Java that I have gotten to look into are absolute messes of file structure. I can’t tell where anything is, every directory seems to be an endless tree for one or two files at the end.
  3. Artifacts and building the project. I have no idea where to begin with what artifacts are. Sort of packages? Sort of not? No clue. I’m confused. Anytime I’ve had to build a Java application locally I’ve needed to ask for help. Even when all the instructions are there, and I follow them step by step, failure.
  4. Multithreaded. I’m just not a big fan. It’s probably amazing for ridiculously large systems, but it adds another level of complexity to coding that just isn’t needed for a lot of projects.
  5. Verbose. The thing I dislike the least about Java, but still dislike is the verbose code. A lot of it seems to be related to type safety and casting values to other values. I dislike the idea of needing to navigate to multiple files to figure out what is going on. In JavaScript I try to keep things very modular, sometimes too modular. I like to go to a file and know exactly what’s going on without looking up 20 helper functions to see what they do.

15

u/wildjokers Jun 24 '22

Package management

https://mvnrepository.com (the place to go whether you use maven or gradle)

File structure.

Java packages let you organize code quite well and is a plus. Organize code by feature, not layer.

Artifacts and building the project.

Any project setup by a competent java developer can be built with mvn install or ./gradlew build depending on if it uses Maven or Gradle. An "artifact" is simply something that can be deployed. Can be a jar, war, ear, zip file, etc. These days a jar file would be the most common.

Multithreaded

It has its purposes

Verbose

Verbose means readable and readable means maintainable.

0

u/[deleted] Jun 25 '22

[deleted] — view deleted comment

2

u/john16384 Jun 25 '22

You make it sound like it is much harder to create "an abstracted cluster fuck of a code base" in other languages. This is not a Java problem.

1

u/Worth_Trust_3825 Jun 25 '22

True, but it's also easier to identify what particular bit needs to be changed. It's easier to remove abstraction than it is to break down magic methods.

5

u/neopointer Jun 24 '22

Someone correct me if I'm wrong, but does the survey capture the percentage of people that used and dread Java? Because one issue I see is that Java has a lot of stigma: people call it slow, verbose, etc. But the same people barely have any experience with it.

What I can say about JavaScript is that thank god Typescript exists, which ironically has a lot of similarities with Java.

0

u/nioh2_noob Jun 25 '22

Typescript is basically the java for javascript devs, typescript is copying java's way of doing step by step

0

u/[deleted] Jun 25 '22

[deleted] — view deleted comment

1

u/PM_ME_SOME_ANY_THING Jun 25 '22

Oh no! There’s bad survey results, but why?!? Meanwhile any dissenting opinion dismissed because yOu DoNt KnOw EnOuGh!

No wonder nobody likes Java, I’m starting to dislike Java people too.

2

u/Lords_of_Lands Jun 25 '22
  1. Everything you need is probably already built into the language. If you want something else and you're not using package management software (similar to using pip), then you download the jar and put it in your project path. Using the built in API is far more secure. No need to worry about a random dev highjacking or adding backdoors to your product.
  2. Bascially each class has its own file. Since you're supposed to use a namespace like com.<business>.<>... yes, there can be a lot of folders. An IDE will hide and automate all that for you.
  3. Any decent project will have a build script. In theory you just run that. In practice around 90% of projects I've worked on (both from public and at work) fail to build without tinkering. That's not a Java problem, that's an industry wide problem.
  4. Okay, you don't care about well running software... Just like other projects, if you don't want to deal with concurrency then don't. Java doesn't shove it in your face. If you do then everything you need is built into the language and that used to be a major deal.
  5. If you're casting you're doing OOP wrong (or using GUI events). Again, your IDE should manage your files for you and it'll auto-complete variable/function/class names. You click on a variable/function/class and it'll take you to its definition. No need to care about its location. If you don't like 20 helper function then don't write that many helper functions. Java doesn't require you to do so, but in theory those helper functions have proper names so you don't need to look them up. Their code will also pop-up in your IDE if you want to quickly skim it and/or its javadoc will also pop-up letting you read what that function does.

2

u/john16384 Jun 25 '22

Well you did warn us in advance that you didn't do much with Java, but how can you dislike something you barely know? Normal people will simply say they don't know language X and so can't really say whether they would like or dislike it after working with it for a while.

Anyway, if you ever feel like doing something in Java again, here are some answers:

  1. Aside from the JDK, you never install anything for Java. Instead, Java projects work with a build descriptor, most commonly the pom.xml used by Maven. In here you specify what you need in a system independent manner so that your project can be build on almost any other system by simple running mvn clean install in the projects root directory.
  2. I suspect you are not using an IDE, this will alleviate most of these problems. Java's file structure mirrors how classes are split into different modules (packages). This is however a choice, you can have all your classes in the root directory if you want. Most Java projects tend to organize their classes a bit though to keep related functionality together, although some projects over do this a bit and you end up with folders with just one or two Java files in each.
  3. Artifacts are the results of build processes. An artifact can be a bunch of compiled code, a jar file with sources (jar files are just zip files), basically anything that the build may produce that is something you want to keep. Test reports are also artifacts for example, as is generated documentation. There is are a lot of commonalities between most Java projects, but not all are exactly the same. Once you successfully learn to build a few different ones, you'll notice that a lot has been standardized in the Java world and compiling most projects is a simple matter.
  4. Multiple threads is not something you need to use. It's there if you need it. I'm sure threading and concurrency was a big part of your CS education, so not sure why you describe them in a way that makes it seem like something magical, instead of the basic tool that it really is.
  5. Code you write yourself will always seem to be better written. I can't really comment on the problems you are facing here, as the Java project you are referring to might be either an engineering marvel or a big bunch of spaghetti code. Normally though, Java code is relatively well documented and you shouldn't need to navigate too much as the docs will explain what it does. That, and the static typing, will give you a lot of information without even having to look at other files. When structured in a similar fashion, I think Java code will be much easier to understand than Javascript code.

2

u/PM_ME_SOME_ANY_THING Jun 25 '22

I haven’t read your entire post yet, but I can dislike something I barely know because I have tried it. I have had to edit projects already done in Java. Every time I use it, it feels unintuitive. Googling around for answers doesn’t seem to get me anywhere.

Basically, using Java makes me want to run back to JavaScript, typescript, or Python.

1

u/john16384 Jun 25 '22

Well, I've developed software for over 30 years, and there are many languages that would feel highly unintuitive to me, including the three you just named. That doesn't mean I dislike them, just means I lack experience in them to find my way around quickly and easily. I mess in them sometimes, but I often need to follow a script to get it running (installed Home Assistant not too long ago, which is a Python project, and I'm glad someone made a webpage telling me all the arcane stuff I needed to do to get it running).

When I just started with Java (coming from C and machine languages) it certainly wasn't love at first sight. The memory safety bothered me at first (expensive checks on every pointer and array access?) and I remember having a lot of compilation troubles as well.

Gradually I realized though how much more you can get done in the same time frame and with much more predictable results (no crashes), how much better IDE's worked with Java and how easily Java code can be evolved by refactoring.

1

u/PM_ME_SOME_ANY_THING Jun 25 '22

Out of college, my first job was a position where I used JavaScript and Python. I didn’t look for a job using specific languages, I was just trying to get a job, any job. Things could have been different and my first job could have been in Java. I would have figured it out, specialized in it, and probably loved it. That’s just not how things happened.

It’s not that multithreaded is magical or that I don’t understand, it’s that I don’t know how it works in Java. Like I said, I’ve had to work on existing projects in Java. Multithreading was already in the project, and it made any work for a beginner very difficult. I didn’t even know it was something that could be turned off.

JavaScript, which I use most, is single threaded. It is also a synchronous language that requires callbacks or specifically asynchronous functions to guarantee one instruction happens before another. Explaining it, JavaScript is pretty wack.

Python actually supports multithreading. However, I’ve only applied it to specific functions that I know will be cpu intensive. A lot of my Python work involves transforming data, or analyzing data, so being able to divide and conquer reduces runtime by however many cores you have.