r/AskComputerScience • • Jun 23 '21

Why do people like java? It just feels so en cumbersome to use, or am i just doing it wrong?

Just started learning java coming from python.

What is the best IDE for java?

46 Upvotes

67 comments sorted by

51

u/bonyicecream Jun 23 '21

People like java because it's been an os-independent standard in industry for 20+ years and thus has lots of support and industry usage. That said, it's quite verbose, but it's seen some improvements of late. IMO, you need a good IDE to code in java.

9

u/[deleted] Jun 23 '21

Which IDE would you recommend?

22

u/bonyicecream Jun 23 '21

Same as the other comment - IntelliJ or Eclipse.

12

u/chuby1tubby Jun 23 '21

Just stick with IntelliJ or Eclipse.

6

u/oxamide96 Jun 24 '21

Isn't the need for a dedicated IDE a weakness in a way? Many people run JavaScript or Python in vscode or pycharm respectively, but you could almost as easily do it in a plain text editor like sublime or even vim. You really can't do Java that way. I guess it could be seen as a strength, but to me it seems over complicated when I can use another language that achieves the same with much less.

6

u/DonaldPShimoda Jun 24 '21

I don't think anybody's arguing that it isn't a weakness, though. The parent comment definitely seemed to feel that the necessity of an IDE is a downside. But that doesn't mean Java doesn't have some advantages here and there.

3

u/gab800 Jun 24 '21

The IDEs and their excellent refactoring and templating/intellisense tools are part of the Java ecosystem, and they are big part of the reason why Java is still extremely common. You can say it is a weakness only when you are doing your exams and search engines and IDEs are forbidden. That will never happen in the real professional or hobbyist world.

1

u/GoodLifeWorkHard Jun 25 '21

Not really. You can compile Java code in a plain text editor too as long as you have the JVM(?) installed. Someone correct me if I'm wrong though lol

45

u/CrumblingAway Jun 23 '21

It's because you came from Python, i get the feeling. Having to create wrapper classes just to store different types of objects in a single array seems like an unnecessary barrier, until you realize what it protects you from.

Bottom line is that Java serves a different purpose and is OS (Operating System, like Windows and Linux) independent, which makes it appealing

And Intellij to me is a must.

8

u/[deleted] Jun 23 '21

What does it protect me from?

24

u/AmateurHero Jun 23 '21

Type issues. I don't write a lot of Python, but I do write a lot of JS. A lot of devs love that you can do nearly whatever with type coercion, because it allows rapid prototyping without a compiler complaining that a number isn't a string. This is a small victory for experienced devs. Inexperienced devs might find themselves looking for an unexpexted bug after a refactor. That's what GP means.

In Java, devs must be explicit about types. The compiler does its best to guarantee type safety, and that's by design. Python doesn't force devs to declare types for a variable. four = 4 followed by four = "4" is valid Python. That means a function can return "4" or 4 in Python to the same variable to be used elsewhere, but the Python dev has to be sure that the correct type of 4 is returned from the function. 4 + 4 and 4 + "4" evaluate to different outputs, and the interpreter will not make that check for the dev.

String four = "4"; followed by four = 4 is invalid Java and throws an error. The Java dev has to ensure a compatible type for "4" and a different compatible type for 4 or the compiler complains. That's what type safety guarantees.

5

u/[deleted] Jun 23 '21

Thank you. You explained it very well

20

u/midwayfair Jun 23 '21

Type issues. I don't write a lot of Python, but I do write a lot of JS. A lot of devs love that you can do nearly whatever with type coercion, because it allows rapid prototyping without a compiler complaining that a number isn't a string. This is a small victory for experienced devs. Inexperienced devs might find themselves looking for an unexpexted bug after a refactor. That's what GP means.

I do a majority of my work in Python, but an awful lot of my job is consumed with protecting python scripts from accepting a parameter the wrong type or avoiding odd return types. Most of the other work I do is in C. Sometimes Java is a nice middle ground.

6

u/AmateurHero Jun 23 '21

That was also an issue for me on a previous project. The worst is working with libraries in JS. The example in the docs is for happy path, picture perfect use-cases that aren't applicable. The API docs gives a vague sentence instead of technical knowledge.

Tangentially, I once submitted a PR to a very popular library to change a variable name from reserved word. We had a new requirement to move JS files to strict mode, and the minification step in the pipeline threw up. An author used byte, char, long, or one of those words as a variable name.

2

u/oxamide96 Jun 24 '21

Thank you for the explanation, but TypeScript is a typed superscript of JS that solves this problem too, yet it is still much less complicated. Golang also has a strongly typed system. Java remains much more complicated, and I don't understand what the benefits are.

2

u/AmateurHero Jun 24 '21

I mean you could say the same about Rust or Scala or Kotlin or C# depending on the definition complicated. OP asked about Java coming from a Python background, so I talked about Java.

To specifically answer your question, write in whatever feels most comfortable. The limiting factor for most projects is investment in the language. If you come from a Java background, you’ll likely be more inclined to write in Java. If you learned Golang and fell in love, then you’ll want to use Golang. Java has widespread use, because it remains entrenched as an enterprise language. Spring + a frontend like Thymeleaf (if you’re into templating engines), React or Angular has very widespread support, and it doesn’t take much to get a basic service running with Spring Boot.

Is Java the best? Probably not. It probably doesn’t take 1st place for any specific feature. However it’s good enough to get people where they need to go

1

u/DonaldPShimoda Jun 24 '21

Java remains much more complicated, and I don't understand what the benefits are.

TypeScript and Go are like 20 years newer than Java. The industry learned a lot about the design of type systems in that time.

That said, my favorite type system is Haskell's, which dates to the mid-90s.

The problem, I guess, is the specific set of type system features Java chose. They wanted it to be safer than C (so you get an error when you access null, you can't accidentally convert values from one type to another, etc), but also object-oriented (so extra syntax for accessing fields and methods, plus class declarations, plus access modifiers [public, private, etc]), plus an exception system (instead of just throwing errors and not catching them, or returning error values). It's kind of a complicated confluence of features, honestly.

Things could've been different if they'd maybe made some restrictions in their type system so they could implement type inference (so it'd be less verbose), or if they hadn't absolutely disregarded what object-oriented programming was "meant" to be and created the horrific "OO" monstrosity that they did. Sigh.

1

u/madmendude Jun 27 '21

Another thing that I feel is also a bit confusing is that they've overriden the plus operator to mean concatenation for strings, while not allowing overriding operators in general, which leads to expressions like a.add(b.mult(c.add(d))), which is extremely difficult to lead and has lead to a lot of mistakes I believe.

1

u/Kiroto50 Jun 24 '21

To add to this, Kotlin adds null safety on top of that, which I really really love and believe every strongly typed language needs

3

u/ClysmiC Jun 23 '21

just to store different types of objects in a single array

I mean, the whole point of an array is that you have contiguous memory and you can calculate an offset to index into it in constant time. If you can't guarantee that every value is the same size, then you don't have an array.

2

u/_HyDrAg_ Jun 23 '21

Python solves that by having arrays (lists) of pointers, since everything kinda is a pointer.

2

u/ClysmiC Jun 23 '21

You can do the same in Java for things with a common interface or super class (or just use Object[] if you want a completely heterogenous collection).

56

u/[deleted] Jun 23 '21

No, it just is extremely verbose.

IDE-wise IntelliJ and Eclipse are good bets.

6

u/r12h Jun 24 '21

What do you mean by verbose? Does that just mean it’s detailed? Currently in college, so I’m genuinely asking haha.

45

u/[deleted] Jun 24 '21

It take many word when in python few word do trick

2

u/r12h Jun 24 '21

Agreed. I’m programming in C right now and I just know I could do the same project in Python in 20 minutes

6

u/FlipskiZ Jun 24 '21 edited Sep 19 '25

Wanders river afternoon where day day net clean open clear today open!

1

u/r12h Jun 24 '21

Yeah that is pretty cool. I guess the reason python would be easier is because it’s just parsing strings in files and python has a ton of simple methods for that. I’m also more familiar with it so I do less googling for any functions I’ll need.

24

u/theobromus Jun 23 '21

The reason people like java is that it's very easy to read. There are very few "surprises" in the language (things that do something you wouldn't expect).

In my opinion this does two things:

- Makes it much harder for inexperienced software engineers to shoot themselves in the foot.

- Makes it much easier to pick up and understand a codebase someone else has written.

The language is certainly very verbose for lots of reasons (imports, long names of things, lack of operator overloading, requiring types to be written out). Most of these are only annoying to write and not to read though and most of that can be solved by having good autocomplete in your editor/ide.

4

u/Tai9ch Jun 23 '21

Most of these are only annoying to write and not to read though and most of that can be solved by having good autocomplete in your editor/ide.

One of the huge benefits of a concise language with minimal boilerplate is that it's easier to read. A language like Ruby, for example, can be drastically easier to read than Java because you don't need to spend as much time picking out design patterns to understand what's happening.

9

u/[deleted] Jun 23 '21

Exactly...

While in some places verbosity does make sence, it really doesn't add anything valuable in many cases.

As a (very mean) example consider this:

int max_value = anArray.toStream().max().getAsInt();

vs

int max_value = max(anArray)

7

u/funkinaround Jun 23 '21

I think this example confuses Java verbosity with proper abstractions.

If you have a bunch of toStream().max().getAsInt() code, Java will let you define a function max that takes an array and does that computation. It's not clear to me that having such a max function defined in the standard library is useful as an abstraction. E.g. what about an array of floats instead of ints?

In my experience, the historical Java verbosity complaints have been things like being unable to pass functions as arguments and the ceremony of declaring a class with equals and hashCode methods. These forms of verbosity are being worked on in Project Lambda and Project Amber.

4

u/[deleted] Jun 23 '21 edited Jun 23 '21

That is why the max function/method is defined generically on any container that contains a type that defines an ordering. Done. (You can also define an interface implemented by all containers, if you like that better*).

There is really no need to expose streams/iterators to the programmer there. - It is really just a matter of not overcomplicating basic functionality in the base language...

Things like .equals are obvious nitpicks. But I'd argue you shouldn't use out-of-language tooling for such things, but that's a whole 'nother discussion...

*Either way container-types like map, set or an orderedList implementation could easily just specialize .min, .max, etc. to be constant time.

5

u/funkinaround Jun 23 '21

Java has Collections.max() to do that for you, yea?

3

u/[deleted] Jun 23 '21 edited Jun 23 '21

Thanks for bringing that to my attention!

I wonder why that one didn't come up anywhere...

5

u/[deleted] Jun 23 '21

Python and Java are just tools that are both really good but for different things. You wouldn't use Java for scripting and glue-code. Similarly, you wouldn't use Python (I hope) for really complex, high performance services running business logic.

0

u/[deleted] Jun 24 '21

[deleted]

1

u/[deleted] Jun 24 '21

You can, but why would you?

4

u/M3tal_Shadowhunter Jun 24 '21

Java's incredibly structured and it's not concise, but it's amazing for OOP. I'd suggest Eclipse or Emacs

2

u/virtualmeta Jun 23 '21

I'm sure the same question could be asked about any unfamiliar language. Even in my own favorite language, if someone's style is different from mine, I have to fight through an annoyance curve until I am used to it. Fight through it, learn, and if you get to choose at some point, pick what you like. This is obvious, but the more you learn, the more capable you'll be.

2

u/deong Jun 24 '21

So I despise Java. I think I'd rather just do something else with my life than work in Java. Having said that...

Most of what you're encountering is just unfamiliarity. Java is towards the "pure object-oriented" end of the language spectrum. As such, it forces you to deal with things you probably aren't doing in Python, because you're probably not writing very large applications where having a strong organizing principle behind your code starts to make sense. And that's basically what OO is -- a strong organizing principle. It says "structure your code like this". When you haven't seen it before and you aren't doing anything where you'd see the benefits, it just becomes ceremony that looks complicated for no reason.

If you keep at it, you'll start to learn the way Java does things and it won't be confusing anymore. Then you can start hating it for all the better reasons that are out there.

2

u/HappyGoblin Jun 24 '21

List of good things about java:

Good documentation, tons of libraries and frameworks, huge community.

Also: it is really well paid.

2

u/PoneiGoesVroom Jun 24 '21

Java is a very powerful Object-oriented programming Language with great potential and support. It has been industry standard since the 90's, is OS-independent, and has good framework support (such as Spring, which allows for good backend API development + Database automatic generation through annotations). Java has great capabilites, inheritance, Generics, Reflection, etc.

It is a little more verbose than Python, such as creating Classes, packages, etc. However, these exist for a reason. Java was built to be Object-oriented development, unlike Python which is mostly used for scripting. Java does have the problem of having to type a bit more than most, however, Java is a cannon that can be used for whatever problem you have.

I Personally use Eclipse though I would say IntelliJ is the best one.

1

u/oxamide96 Jun 24 '21

I honestly am yet to understand the benefit of using Java over other languages. The verbosity leads to slower development time, and there are man my aspects about Java that seem overly complicated. I feel like that should be useful, but I am yet to find a use case Java fulfills that other languages don't with easier syntax.

1

u/[deleted] Jun 24 '21

This is the problem with learning python as a first language, everything else feels too much work.
Anyway, the reason I don't like java (or python for that matter) is that it abstracts away so much detail that it feels that you are programming a toy at the end, you don't feel any of the computer's idiosyncrasies.
The truth is almost all languages feel as cumbersome (if not more) than java if your reference is python. For example in C you don't even get a string data type of the box, you have to treat strings like character arrays, but this is what I like about C in the first place. It gives you full control of the environment tou are programming.

1

u/metaquine Jun 24 '21

Java is a general purpose language with more libraries than god, choices of garbage collectors, mature tooling, generics, a decent type system, functional support. People love to bash that version of it they used 10 years ago. I find it useful for when I have to build a large complex maintainable system in collaboration with hundreds of others. It is the right tool for that job.

1

u/S-S-R Jun 26 '21

I agree, Java is very much OOP and I don't particularly like OOP.

0

u/Poddster Jun 23 '21

Java was basically a garbage collected C. And like C it's very tedious and very literal. There are no hidden surprises*. Every line of code does something obvious with no hidden compiler magic. The standard library shared the same this too.

Eventually though it outgrew that ethos. But the core is still there. And that's important to the people that use it because they want a very simple, obvious language that can run anywhere and are willing to put up with the verbosity of that's what it takes .

Also, the tooling for Java is fantastic. IDE's like Intellij practically write all the code for you. Whereas this is very difficult in Python. The best IDE for python is made by the same people as Intellij, but it can't do half as much because of the dynamic typing in python.

* ignoring undefined behaviour etc in C

2

u/[deleted] Jun 24 '21

Don't you mean c++?

0

u/Poddster Jun 24 '21

No, I really don't :)

It was shipped as a contender to C++, but early Java very much a C vibe rather than C++.

1

u/oxamide96 Jun 24 '21

As a JS developer I had some experience with Java on intelliJ, but never got far enough to see it "write all the code" for me. Can you please explain how this works exactly?

2

u/Kiroto50 Jun 24 '21 edited Jun 24 '21

I code Kotlin in IntelliJ, used to code Java but feel in love.

IntelliJ's code completion is beautiful, and many of the verbosities of Java are written by the IDE once it knows what you're referring to, like class names for new variables, and even variable names.

It also comes equipped with some integration for tools and frameworks like spring which method names are usually very long, and it for sure helps with having those appropriately named.

Semi automatic documentation can be very easily set up too, iirc.

Not to mention automatic imports and import optimizations and quick, deep and easy access to inner workings of functions and classes. (ever wondered how file streams work? Some new thing you're working on never seen before? Ctrl click! I feel it's easier on IntelliJ than VSComm for C#)

And Maven/Gradle?! A different flavor of npm/yarn!

2

u/Poddster Jun 24 '21

Press ctrl+shift+r and look at the refactor menu, for instance. (I think that's the default keymap?) Most of that isn't available in python, C, C++. ( I've tried a lot of different C++ refactoring tools and they all suck and can barely cope with a simple 'make the 3 selected lines a function'.)

-7

u/uniform-convergence Jun 23 '21 edited Jun 23 '21

People like Java because they are afraid to admit that their favourite language where they coded first Application is just bad, having in mind new coding standards.

  1. It's verbose, basically Java = Verbose (these are synonyms :))

  2. Coding speed is very slow,

  3. Very often (altough not by design) it's slow in general.

The thing is that Java's most valuable feature has now become Java's worst enemy, and that is huge codebase. Java has huge number of libraries, packages and ready-to-use solutions for pretty much anything you need, but because of it, over the years, it has become so hard to use, follow, debug and implement.

It has become a standard in Java and Java's frameworks (Spring, Spring boot etc.) running into some shitty errors and bugs for which you need 3 hours of googling to fix, following some tutorials which are outdated even at the time of their making.

Java is not bad, the opposite in fact, Java was so good for our need, but we must agree that Java time has passed away.

I don't want to code in language for which i need to solve some random bugs in some random library which is a dependency of my dependency, it's just stupid.

EDIT: I am coding in Java actually, so I am not some C# fanboy.

1

u/[deleted] Jun 23 '21

Havent yet encountered these problems, but just starting out i could not understand how anyone can put upwith how goddamn slow and verbose it is. I admit python is stupidly easy, but goddamn is java not straight forward.

-3

u/uniform-convergence Jun 23 '21

You need to know Java. Period. It's a must.

But as soon as you are in position to choose from multiple programming stacks offering same benefits, you should avoid Java. It is that simple.

0

u/[deleted] Jun 23 '21

Thank you. This helped me reconfigure my perspective on the issue

0

u/Kiroto50 Jun 24 '21

Disagree. When you are in a position to choose, if java is a good tool for the task, and you like it, go for it.

If I want to make something multiplatform, I'll definitely think of Java/Kotlin, or web

1

u/uniform-convergence Jun 24 '21

Read my comment again. I said: "offering same benefits".

2

u/oxamide96 Jun 24 '21

He was downvoted because he spoke the truth

-6

u/stedgyson Jun 23 '21

Check out C# and .NET Core, personally I'd never use Java again unless I had to

1

u/[deleted] Jun 23 '21

I just started java. Its just so confusing to use, even with intellij.

Like, python is soooo fucking simple

1

u/yikes_42069 Jun 27 '21

That's kinda the point. It's intended for non-programmers to pick up and start scripting. Doesn't mean Java is worse per se.

0

u/stedgyson Jun 23 '21

It's just an old fashioned nightmare that keeps limping on

-1

u/[deleted] Jun 24 '21

To all the ‘typing’ comments, while you’re right, any company that’s not retarded will use some type checker for their Python code especially if it’s some server side code

0

u/[deleted] Jun 23 '21

[deleted]

2

u/Kiroto50 Jun 24 '21

.. yeah many people got into java (and programming as a hole (yes) ) because of this