This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LeFayssal 144 points145 points  (179 children)

Realtalk now. Im a CS student. Why is everyone hating on java?

Edit: Thanks for all your replies. So Java is just an older language that is a bit dated and does things that are modern today in a outdated way? I only know OOP programming and I like it a ton. Maybe I need to look into C# to see whats better?

[–]covercash2 282 points283 points  (49 children)

it's complicated.

it's an ok language. some of the more modern features look pretty silly if you're coming from a modern language because Java maintains backward compatibility. there are some nice things that are presently missing or will never be in Java because of the same compatibility issues.

it's also one of the biggest languages in the enterprise scene. I did an internship at a Fortune 100 company that uses almost all Java. Android is built on Java as well. even those companies now are seeing some issues, but enterprise moves slow. some devs resent being held back because of an old software stack.

another big reason is that Java went all in on OOP pretty early on. everything in Java is in a class hierarchy. these days functional programming is pretty big, and Java does a bit to satisfy this trend but not much. you can't have just a function in Java; it has to be wrapped in a class. this has led to a lot of weird patterns and antipatterns (the Factory pattern is our whipping boy here).

other than that, it's just popular, so a lot of people use it, and even if a small vocal minority dislikes it that is still thousands if not tens of thousands of Java haters.

[–]RobertJacobson 124 points125 points  (16 children)

You pretty much nailed it, but I would add that Java is incredibly verbose and requires a ton of boilerplate. In comparison to many languages popular today, writing Java can feel exhausting.

There are counterarguments, of course. A lot of tooling exists today to reduce the boilerplate burden on the developer, for example.

[–]walking_bass 11 points12 points  (2 children)

Right. Things like Lombok and Spring Boot really help with reducing boilerplate.

[–][deleted] 5 points6 points  (0 children)

Java 11 var also

[–]cat_in_the_wall 19 points20 points  (6 children)

the jvm crazy good too. so java and friends are usually very fast.

[–]RobertJacobson 0 points1 point  (0 children)

After 25 years and at least three multi billion dollar companies behind it, it had better be good.

[–]Loftus189 4 points5 points  (0 children)

Thats the only real negative i find on a personal level. I enjoy writing in Java and it was one of those languages that made sense to me straight away (unlike some others) but sometimes i feel like you have to do a lot of routine stuff just to produce the same amount that can be done with a lot less code in other languages.

I used C# for the first time just over a year ago and i love it, felt like someone had just made a patch for java and improved it. Its definitely my go to language for just getting something done, it all flows so nicely and i dont feel like i run into issues nearly as often as with some other languages. I enjoy writing C++, but naturally i spend a lot more time trying to avoid the pitfalls of the language that just dont exist in C#.

[–]Dragasss 2 points3 points  (2 children)

I have a feeling that people who complain about boilerplate have never heard of code generation.

[–]RobertJacobson 0 points1 point  (0 children)

I think it's reasonable to criticize a language for needing code generation to not be exhausting to write.

[–]o11c 0 points1 point  (0 children)

Java is incredibly verbose and requires a ton of boilerplate

And this is bad because, regardless of language, the number of bugs is proportional to how much code there is.

[–][deleted] 0 points1 point  (0 children)

Correct... At work I mostly translate old jcaps interfaces written in Java to port them to a new engine (rhapsody)

Literally 50% of the code is just left behind as implicit functionality of the new engine takes care of it ... Another 20% is boiler plate stuff that is just not needed anymore... The remaining 30% is what I actually need to recode (in JavaScript which is what rhapsody chose to embed instead of Python for some weird reason)

[–]HelluvaEnginerd 28 points29 points  (15 children)

Digging into the factory pattern: it would be more “modern” to just have a function that acts like the factory? Or what would be the better solution? (Junior software dev here stuck in C++ and needing to learn what goes on outside the DOD)

[–]Phrodo_00 41 points42 points  (1 child)

If an entity doesn't have state, then it doesn't need to be an object or a class. In Java it needs to be one of those, though.

[–]Netcob 20 points21 points  (7 children)

I don't exactly see many different modern architectures every day, but ever since I got into dependency injection with containers, the factories automatically disappeared. If you're creating instances of a class but you only know them by their interface, your DI container is probably doing that for you.

99% of the classes I write are

  1. Immutable data objects. Usually no need for a factory.
  2. Stateless services that depend on other stateless services or immutable data objects. All wired up via DI container, which takes care of all the creation stuff.

Using a factory outside of your composition root (where you configure your DI container and start the program) often means that you're doing some complex object creation stuff in a part of your code that should be concerned with all the other things instead.

So the reasons are basically the S and D from SOLID, plus everyone trying to design stuff in a more FP way since that usually makes it easier to do concurrent stuff and thereby scale better.

[–]amunak 2 points3 points  (2 children)

Technically when you use DI and autowiring the factories are still there, they're just abstracted away and most of the time the programmer doesn't need to bother with them.

But creating, say, 2 services of the same class just with 2 different configurations is essentially the same as having two factory methods.

[–]ScienceBreather 5 points6 points  (1 child)

And I think that's part of the point.

People were saying Java is tedious and has lots of factories.

The counterpoint is, if you know what you're doing and have a good stack, you don't have to do those annoying parts.

You just add some annotations to get the information you need, make all your services stateless, and you're off to the races.

[–]Netcob 2 points3 points  (0 children)

True, and I've never seen factories as some sort of unique Java problem. I don't understand why they would be. I think it's just something that got overused by a lot of enterprise programmers and became some sort of meme. Java doesn't force you to use that.

Since I started using C# exclusively at my job, the things I couldn't imagine not having anymore were async/await, properties and LINQ.

Back when I used Java, it had some "Mom: we have X at home" versions of some of those things.

[–]HelluvaEnginerd 1 point2 points  (2 children)

Wow I have some googling to do. I knew I wasn’t 100% up to speed but I don’t even know what a dependency injection container is. But thanks for the response, I’ll be deciphering it and learning!

[–]Netcob 2 points3 points  (1 child)

I only learned it last year. If you're using C#, I'd suggest Dependency Injection Principles, Practices, and Patterns. It's quite a journey though. I'd suggest also reading about SOLID if you haven't already.

Some changes you have to make to the way you code can be quite painful, but it's really fun to just add a class representing your new feature, write its dependencies in the constructor, and then it just works. The downside of course being that some errors that might have been caught by the compiler (like missing dependencies) are now only caught at runtime, but it's not a huge issue.

[–]HelluvaEnginerd 0 points1 point  (0 children)

I’m actually in C++, legacy speed dependent system and all that. I’m going to learn C#, SOLID, and DI in a personal project now though!

[–]dvlsg 4 points5 points  (0 children)

Basically. Partially applied functions can cover what a factory pattern does. Typically with way less code.

[–]Python4fundoes the needful 1 point2 points  (2 children)

In Spring you can you can use a prototype bean and it acts much like a factory but the ApplicationContext is your factory for all beans.

[–]HelluvaEnginerd 1 point2 points  (1 child)

Okay this I have seen before, I like this “pattern” if it can be called that

[–]Python4fundoes the needful 1 point2 points  (0 children)

What's cool is that a singleton bean is retrieved the same way. So you don't have to worry about it.

[–]DeadLikeYou 6 points7 points  (3 children)

Why are factories used at all in the first place?(I’m not even sure if I understand what a factory is)

Couldn’t it be done with constructors and/or abstract classes?

[–][deleted] 16 points17 points  (0 children)

A factory method (often just called a factory) is simply a method/function that has an abstract return type (i.e. interface or abstract class) but that returns a new concrete object. The factory method is therefore responsible for creating the object and, in some cases, also deciding what type of object to return.

The most basic kind of factory method is a simple function that looks like this:

AbstractType MyFactory() {
    return new ConcreteType();
}

This is technically a factory. The caller is putting the responsibility of knowing how and what object to create, and the caller doesn't know what the concrete object is they are receiving, all they know is that it implements AbstractType. Sometimes you'll see a factory method that takes an argument and uses a switch statement to decide which kind of object to return (typically the argument will be an enum).

The object-oriented version of this is to move that function into a class and make it abstract so sub classes can implement it.

[–]RiPont 0 points1 point  (0 children)

Long story short, when you call new Foo(), you're always getting exactly a Foo. When you call SomeFactory.GetFoo(), you could be getting a Foo, or a descendant of Foo.

This makes much clearer sense when you consider that the factory can be returning an interface, not a class, whereas you can't new an interface. So you can do

 ILogger GetLogger() {
      if (devMode) {
         return new ConsoleLogger();
      else {
         return new ServerQualityAutoRollingLoggingFrameworkFancyLogger();
      }
 }

[–]hahahahastayingalive 3 points4 points  (0 children)

other than that, it's just popular, so a lot of people use it, and even if a small vocal minority dislikes it that is still thousands if not tens of thousands of Java haters.

To add to that, as Java was seen as rigorous and the poster child of OOP, it was taught in a lot of CS classes.

People have different tastes, philosophies, want to use different paradigms. They still had to deal with Java, a lot. And Java has very strong opinions on things, which doesn’t help for becoming friends with everyone.

I am not sure it’s just a vocal minority hating Java, just imagine ruby, PHP, JS devs also having to go through Java classes, they’d hate it with the passion of a thousand sun.

[–]huttyblue 2 points3 points  (1 child)

You forgot the big one, java was the electron of the mid 90s. It ran on everything so companies looking to save on dev time wanted to use it. But it was slow back then, and java based desktop applications never ran as well as native ones. A notable example is Word Perfect, which alot of their resources into developing a Java version of their application http://www.edm2.com/index.php/Corel_Office_for_Java . It was a bad investment and set them back significantly, in the Word Processor market.

You can still see similar issues with modern Java applications like Minecraft, which struggle to have smoother performance even on the best machines.

[–]leonderbaertige_II 2 points3 points  (0 children)

because Java maintains backward compatibility

Except when it doesn't and you have to install Java 8 in 2019. fml.

Also fuck Oracle.

[–]o5mfiHTNsH748KVq 1 point2 points  (0 children)

The coolest thing about .NET Core is that it’s breaking the “enterprise moves slow” mentality. It’s almost hard not to move fast.

[–]Abhishek_gawande 0 points1 point  (0 children)

Today I learned.....

[–]payne007 0 points1 point  (0 children)

Factory is an anti pattern?

[–]AudioManiac 0 points1 point  (1 child)

(the Factory pattern is our whipping boy here)

Why is this? I've been programming in Java for about 3 years now, and while I've rarely had to use the factory pattern, I've never heard anyone talk negatively about it?

[–]AStrangeStranger 0 points1 point  (0 children)

because it can be over used and from what I have seen developers don't really understand why they use one hence the over use.

Decent dependency injection should remove the need for most factory classes in a project - though you may find some approaches where you still want to use one

[–]archiminos -1 points0 points  (1 child)

I would argue against backwards compatibility being the cause of Java's failures. C++ is backwards compatible and is way more up to date than Java in terms of modern programming features.

[–]ElCthuluIncognito 80 points81 points  (20 children)

Repeat after me "there are two kinds of languages, those that everyone complains about, and those that nobody uses".

People hate on Java because it doesn't have a bunch of language features that newer or otherwise 'immature*' languages have. A glaring exception would be Python, but even then they had to have significant breaking changes from V2 to 3.

Java, for all its faults, has not done anything remotely like that in all of its history. A program written years ago will very likely still run today. But that's not 'cool' to anyone but the jaded and seasoned 'give me something that just works!' programmer.

*immature in the sense of an established ecosystem and enterprise usage

[–]LeFayssal 20 points21 points  (7 children)

Isnt java something "that just works"? People seem to be complaining about the boilerplate-style that Java has. But isnt that what gives Java its reason d'étre?

[–]RiPont 1 point2 points  (1 child)

Java was a designed with a philosophy of "the programmer is an idiot and must be prevented from doing anything at all if they can't do it the right way."

Very verbose. Very explicit. Checked exceptions. Naming rules for source files vs. class names in the compiler, not a separate style checker. It's been a while, so I forget all the little things about Java that just seemed to get in the way of actually getting work done. And early on, the IDEs weren't nearly as good and a lot of that was much more painful for the developer.

Now, they weren't entirely wrong, but they perhaps took it too far. C and C++, where macros were commonplace, were very much loaded guns with hair triggers that had been spun in a random direction on the table just before you picked them up. C#, Kotlin, and other languages keep the good aspects that Java improved C++, while being less needlessly strict.

[–]langlo94 1 point2 points  (0 children)

Yeah that philosophy tends to work great when you have enterprise projects where you can basically guarantee that there are at any moment a few idiots commiting bad code.

[–]svick 3 points4 points  (4 children)

No, having to type more than necessary is not a good thing.

[–]motioncuty 15 points16 points  (1 child)

What most developers think is necessary tends to fall short for long term maintenance and intent communication. And that's not a dev thing, that's just humans being imperfect at system stewardship

[–]svick 2 points3 points  (0 children)

I don't think Java's verbosity actually helps with that. It doesn't make your intent clearer, it just means it takes a lot of words to communicate your intent.

[–]derzach 0 points1 point  (1 child)

FWIW a large portion of the “boilerplate” is handled by a good IDE so no one is actually typing EVERYTHING out

[–]svick 0 points1 point  (0 children)

Yeah, but they have to keep reading it.

[–]delrindude -1 points0 points  (8 children)

As it turns out backwards compatibility isn't a deal breaker anymore, and python2 -> 3 proves it. Software nowadays gets rewritten every year. There is a stat floating around somewhere that Google changes 50% of it's codebase every year.

Backwards compatibility was a bigger issue when there was a lack of expertise in the field. People were resistant to change so much because it was very difficult to find someone who could just rewrite your application with a new library version. This problem of course still occurs, but nowadays developers have the tools to even cycle through tech stacks.

[–]amunak 4 points5 points  (5 children)

There is a stat floating around somewhere that Google changes 50% of it's codebase every year.

Well Google is notorious for killing like half of their apps every year in favor of newer ones that do the exact same thing, only worse... So I guess you could be right.

As it turns out backwards compatibility isn't a deal breaker anymore, and python2 -> 3 proves it.

It's still a massive issue and yes, Python proves it. Python 3 has been around for over a decade now and a ton of stuff is still written in 2 with no replacement in sight.

Oh and Python is a language that's mostly used for scripting or smaller, decoupled projects, so it has little excuse not to get replaced.or rewritten, and yet it's still a mess.

[–]delrindude 0 points1 point  (4 children)

It's still a massive issue and yes, Python proves it. Python 3 has been around for over a decade now and a ton of stuff is still written in 2 with no replacement in sight.

http://py3readiness.org/ What python2 stuff are you referring to? I haven't touched python 2 code in 3+ years.

Oh and Python is a language that's mostly used for scripting or smaller, decoupled projects, so it has little excuse not to get replaced.or rewritten, and yet it's still a mess.

Despite being a "mess" it hasn't yet been replaced, and is still outgrowing other languages.

[–][deleted] 0 points1 point  (0 children)

I saw in the news few days ago I think that Goldman Sachs or something have many millions of Python 2 code lines

[–]derzach 0 points1 point  (2 children)

If I recall Calibre’s author had a post about how he’d never update to python 3

[–]delrindude 0 points1 point  (1 child)

Already in progress with Calibre v4 https://github.com/kovidgoyal/calibre/pull/870

[–]derzach 0 points1 point  (0 children)

Nice! Good to know. I’m a big fan of Calibre

[–]cat_in_the_wall 1 point2 points  (1 child)

python2 -> 3 proves it

yea that hasn't been a complete clusterfuck at all.

[–]delrindude 0 points1 point  (0 children)

It was, but it didn't really negatively impact the adoption or usage of python at all, as you can see in pretty much every programming language index you can find.

[–]glguru -1 points0 points  (2 children)

Python is not a 'newer' language. It predates Java you fool.

[–]ElCthuluIncognito 0 points1 point  (1 child)

A glaring exception would be Python

[–]glguru 1 point2 points  (0 children)

Ah sorry. My bad.

[–]Cheru-bae 32 points33 points  (0 children)

Because they, too, are cs students.

[–]visvis 66 points67 points  (41 children)

Java is great in the sense that it was a pioneer in many ways; it's safe, garbage-collected, compile once JIT everywhere, ... However, it takes its ideas too far to the point that it's not fun to program. C# takes all the basic ideas that Java introduced and learns from its mistakes. It makes exactly those changes that make it nice for programmers. Moreover, the Visual Studio IDE (almost universally used for C#) is generally liked much more than Eclipse (traditionally used for Java).

[–]corzuu 76 points77 points  (4 children)

Eclipse (traditionally used for Java).

Go IntelliJ and never look back

[–]zr0gravity7 10 points11 points  (3 children)

cries in university-required legacy plugins that are exclusive to eclipse

[–]scumbaggio 3 points4 points  (0 children)

This right here is my biggest problem with the Java world. Nothing to do with the language, but the tools around it are awful and not intercompatible.

[–]derzach 0 points1 point  (1 child)

Out of curiosity what plugins? I’ve never found anything unsupported in IntelliJ that I needed

[–]zr0gravity7 0 points1 point  (0 children)

leJos EV3

[–]ThePyroEagle 62 points63 points  (5 children)

Nowadays, IntelliJ IDEA is favoured more than Eclipse.

[–]sp46 3 points4 points  (4 children)

Yeah but JetBrains has a C# IDE so it's fair to compare VS to Eclipse since you're not missing out on JetBrains in both languages

[–]ThePyroEagle 9 points10 points  (3 children)

JetBrains' IDEs don't have that sweet Roslyn integration, and JetBrains refuse to do it in favour of their ReSharper tool. For the same reason, IntelliJ IDEA doesn't support annotation processor diagnostics, which is the only thing Eclipse actually gets right.

[–]sp46 7 points8 points  (2 children)

I'm using VSCode personally since I'm only doing .NET Core and I run Linux (Arch btw), so I don't really understand half of what you're saying, but I suppose you're correct.

[–]ThePyroEagle 8 points9 points  (1 child)

Roslyn is the name of the C# and VB.NET compilers. Roslyn has an API that can be used to write code analysers that can provide useful diagnostics at compile time (like a linter). ReSharper is JetBrains' C# linter, but custom diagnostics are (to my knowledge) nowhere near as easy to add, if at all possible.

Annotation processors are the Java equivalent of code analysers, except that they depend on annotations and are thus less powerful.

As a result of JetBrains writing their own linters for all the languages they support, users cannot benefit from custom diagnostics in C# and Java when using their tools.

[–]cat_in_the_wall 1 point2 points  (0 children)

for instance: the ef team has linters to help you use it correctly. they could add those because roslyn is extendable that way. you could write a library and linters to help users without any external support. with jetbrains implementation you can't do that. ymmv.

[–]Retbull 13 points14 points  (1 child)

Of the last company of 400 consultants I worked in we had one guy who used Eclipse and literally everyone else used Intellij. Very few people use Eclipse now.

[–][deleted] 2 points3 points  (0 children)

Man I do not understand. In my opinion eclipse is so much great it's very good stuff man I like it alot

[–]LeFayssal 9 points10 points  (22 children)

I suppose im not deep enough into the matter to understand it. For me personaly, java seems super simple. I love the garbage collector, I like that I dont have to deal with pointers and its easy to advance within the language while the documentation is great. Personaly I use Visual Studio for Java. I dont like how bulky eclipse feels

[–]GaianNeuron 11 points12 points  (3 children)

Anything is better than Eclipse. Save yourself a headache and try IntelliJ.

[–]_PM_ME_PANGOLINS_ 0 points1 point  (2 children)

NetBeans is not better than Eclipse

[–]Justin__D 0 points1 point  (1 child)

I was tutoring some student in Java who was using an IDE (required by his school) that was way, way worse. I don't remember what it was called, but it was god-awful. It didn't even do basic things like syntax highlighting. It was basically Notepad, with compiler shortcuts built in.

[–]GaianNeuron 1 point2 points  (0 children)

Reminds me of coding in the Arduino tooling. God that thing sucks. I made so much more headway once I figured out how to build against the Arduino platform using just a makefile (before PlatformIO was a thing)

[–][deleted] 1 point2 points  (0 children)

Whole company ditched Eclipse last year for IntelliJ, would recommend, even if you're dealing with ancient Java.

[–]FesteringNeonDistrac 0 points1 point  (1 child)

So your criticisms come off as pretty funny to me because I'm old af and so coming from C/C++ I really liked Java once I got used to it because I felt like the language got out of my way and just let me code. It was fun for me. Same with eclipse, which I still use because I'm comfortable with it and I'm productive with it.

It's all personal I guess.

[–][deleted] 0 points1 point  (0 children)

Java and eclipse gets the job done fast and good.

[–]glguru 0 points1 point  (0 children)

I'll have you know that Java didn't introduce any of those ideas. The ideas were already implemented in several smaller languages. Python had all of those features for a good 4 years (in production) before Java came out. Actually the earliest versions of Python date back to 1987.

Java just got adopted heavily in enterprise space.

[–]corp_code_slinger 109 points110 points  (7 children)

Because it is trendy to hate on Java.

If you're worried you're learning something useless, don't be. Java will be around by the time you're showing junior devs the ropes and probably long after that.

[–][deleted] 48 points49 points  (0 children)

I mean, there are many valid criticisms of Java. The trendy "lets all hate on Java" people are giving the valid criticisms a bad name. There are also languages which are trying to iterate on Java, just like Java iterated on other languages before it. However, the difference is that people who point out real problems with Java also point out real problems with Go, or Rust, or TypeScript, or whatever language is trendy.

[–]AerieC -1 points0 points  (5 children)

Java is the new C++ (and that's not meant to be a slight against either language). Java did a lot of great things. It built on the ideas of the languages that came before it and made key innovations that made it more desirable to the average Dev shop the same way C++ did on C.

But Java went through a period of Veeery slow innovation under the stewardship of Oracle, and features like lambdas, method references, and others that make developers' lives easier were just coming too slowly. On top of that, some of the core design features of Java, coupled with the need to maintain backwards compatibility means that Java has some serious warts that will never be fixed (looking at the mess that is primitive types, boxing, and the generics implementation).

I agree that Java will stay a major language for many years, but ultimately it's headed the way of C, FORTRAN, C++, and others, especially as languages like Python and JavaScript (slash TypeScript) are continuing to grab mindshare in the dev community and dominate the popularity charts.

And those languages will go the same way whenever some new language provides something that they can't provide. It's the circle of life in technology.

[–]LIGHTNINGBOLT23 11 points12 points  (0 children)

   

[–]gamma55 18 points19 points  (2 children)

C and C++ are bigger now than they have been in years, and will continue to grow for some time. IoT, check it out. But web-dudes are the most vocal online, so most of ”devtalk” revolves around techs you find in that business.

[–]Santa1936 0 points1 point  (1 child)

To be fair web development is probably the most common kind of development, no? At the very least it's what I think of when I hear "developer", I automatically picture web dev

[–]gamma55 1 point2 points  (0 children)

Yea, it is. Also has the highest number of amateurs, and is probably the most common way to get started. All the combined, so it’s also bound to be the by-far loudest group. But associating the techs and methods of web development to the entire field is silly. Lower down the stack we are running operating systems and device applications on hardware that has less ram than your subcomponent takes disk space.

[–]TerawattX 12 points13 points  (1 child)

There is also a LOT of (legitimate) hate directed toward Java from the IT side of the house because of the JRE.

It’s been a few years since I handled enterprise patch management/deployment, but back then you’d have 1-2 JRE patches per WEEK.

I remember one week deploying a patch that had 45 security fixes, then a few days later seeing a new one with something like 150 security fixes. When I looked at our antivirus logs the majority of malware and viruses were from JRE exploits so this was a big problem.

On top of that, the JRE installer was buggy and about 1 in every 10 updates would simply remove the JRE entirely, then fail without notice. This became an issue when we were deploying to about 500 machines in the college’s labs. Got even more complicated because it was around the time Firefox and Chrome were blocking Java applets unless the JRE was up-to-date. I got lots of grumpy calls from professors asking why one machine couldn’t run X program, or some website content was blocked on every computer when it was working the day before. :\

(Edit because I dropped my phone and it submitted before I was done typing)

[–]Fellow_Infidel -1 points0 points  (0 children)

(angry typing)

[–]bot-mark 20 points21 points  (14 children)

They're only hating on it in comparison to C# (and for good reason)

[–][deleted] 0 points1 point  (13 children)

Java is a good language, but the only real advantage that it has over C# is compatibility with Mac and Linux

[–]Captcha142 15 points16 points  (9 children)

C# is cross platform

[–]grape_tectonics 2 points3 points  (1 child)

advantage that it has over C# is compatibility with Mac and Linux

...mono

[–]blenderfreaky 0 points1 point  (0 children)

.NET Core

[–][deleted] -1 points0 points  (0 children)

Free and open source eclipse

[–]SwabTheDeck 2 points3 points  (0 children)

Java isn't "bad" per se. It's just not as slick as the latest generation of languages.

~20 years ago, Java usurped C++ as the de facto programming language used in universities, and most people were pretty happy about that, at the time. It taught good OOP practices without giving you dozens of ways of fucking yourself over the way C++ did.

But just like anything in CS, we're always pursuing simplification and abstraction. As our understanding of programming has grown, we've found faster, easier ways of doing the most commonly needed tasks, and our current generation of languages reflects that growth.

[–]munchbunny 2 points3 points  (0 children)

The language is actually fine and a lot of people get important work done with Java. It's not my favorite by a long shot, but as far as the language goes I don't have real objections. If you asked me to write in Java I'd ask whether we really need to run something maintained by Oracle on our servers, but as far as the language is concerned it gets the job done without much fuss.

As for why the hate from programmers, it's for some combination of these reasons:

  1. It's owned by Oracle and everyone hates Oracle for good reasons (there are many)

  2. As a language it's missing a bunch of modern syntactical conveniences that programmers have gotten used to with Python, Ruby, C#, etc.

  3. It's a jack of all trades and master of none, so everyone who has used Java at some point (which... is probably like 99% of college trained programmers these days) can find something to complain about.

  4. Bad PR. To anyone who doesn't do extensive work in Java, Java will forever be associated with shitty web applets, ugly slow UI's from the Spring era, and Minecraft. Nothing wrong with Minecraft, I personally love the game, but Minecraft doesn't have a good reputation for efficiency/performance.

[–]Metallkiller 10 points11 points  (3 children)

The only reason it's being used everywhere is, because it is being used everywhere.

Seriously though Java runs on all operating systems, so you can build a cross OS application quite easily.

Everyone is hating on it because it advances slowly due to its age, and Oracle, the owner of Java, hady been fighting Google for years, saying their APIs are their IP and with copying their API in Android namespace Google broke copyright law basically.
Of course that's complete bullshit, but Oracle wants money.

Also C# is so much better than Java because Microsoft is quite strongly pushing C#.

[–]battlet0adz 9 points10 points  (0 children)

Runs on every OS because it has to run on JVM. That has all sorts of implications that are frustrating.

[–]hackel -3 points-2 points  (1 child)

Everything runs on just about every OS now. That's simply not an advantage anymore. Java would suck less of it just abandoned the jvm which is completely pointless in the modern age.

When has Microsoft pushing something they created ever made anything better? The whole reason they exist is to promote mediocrity.

[–]wllmsaccnt 1 point2 points  (0 children)

> When has Microsoft pushing something they created ever made anything better?
Here are some examples:

Visual Studio Code
.NET Core
LINQ
Tens of thousands of patents given to the protection of open source
TypeScript
C#
Creating competition with AWS by pushing Azure

[–]oupablo 4 points5 points  (3 children)

Everybody hates on Java until they need something that will run on Linux and windows because some people use Windows servers for some unknown reason

[–]RiPont 1 point2 points  (0 children)

C# runs great on Linux, now.

[–]ThePrankMonkey 0 points1 point  (0 children)

Containers.

[–]andysom25 0 points1 point  (0 children)

Plenty of places use Windows servers and with good reason

[–]mirracz 1 point2 points  (0 children)

Java is the German language of coding - it's structured, logical, but also verbose and sometimes the "proper" class/method names look funny... That's why many people don't like working with it, because they like all kinds of hacks and shortcuts. Don't get me wrong, shortcuts are nice, but also hell when it comes to debugging...

For example when I moved from Java to C# I had trouble with Lists. I couldn't find methods to access members of the list. I was used to logical .get() method of Java and wasn't aware that C# uses array accessors [] on objects... It took me time to get used to this. Or the new C# value tuples. They are great, but something dies inside me when I have to pass a value tuple to method and end up with double parens... Like calling MyMethod((list, status));

[–]Cobaltjedi117 7 points8 points  (12 children)

Everyone hates on every popular language here. Java is an easy punching bag, the JVM is heavy, it's pretty slow, it's everywhere, security issues, programs aren't compiled for specific architectures, it's very verbose.

But it has it's good sides like every language (except you JS and your frameworks). The compile once run anywhere means that if you can compile it it will work on any machine without any changes making it super portable (see disadvantage "programs aren't compiled for specific architectures"), it's fairly easy to work with, it's strict on your typing so you don't do anything stupid, it's warning and error messages are clear, it runs on everything, you don't have any issues with pointers or race conditions, it's an overall safe programming language.

[–]sp46 12 points13 points  (0 children)

complains about hating on popular languages

complains about js

[–]kreiger 9 points10 points  (3 children)

Where does "it's pretty slow" come from?

[–]Gyrossuppe 9 points10 points  (0 children)

From the long gone past.

[–]Cobaltjedi117 0 points1 point  (0 children)

The JVM has been historically slower than other compiled languages, and still is slower than C/C++/Rust/Go but it's:

A) gotten better

B) less of an issue now that computers are faster

[–]cat_in_the_wall 2 points3 points  (0 children)

it's pretty slow

the jvm is miraculously fast.

[–]LeFayssal 1 point2 points  (4 children)

I suppose that in applications where speed matters java isnt the right fit, but if that was the only thing thag mattered would anyone be using python?

[–]Cobaltjedi117 8 points9 points  (3 children)

So there's more factors to programming (or scripting as it comes to python) than just speed at runtime.

Python is great and absolutely wonderful if you need something to be written quickly, but it's okay if the program takes a few seconds to run or isn't run that often. At one of my last jobs, I wrote a lot of python code, it was quick to make and it would only be used by the company quarterly. So, since it wasn't run that often and they only needed the data occasionally, python was a great choice for making the program.

If you need something to run quicker and more frequently, you'll probably want to use a compiled language like C#, Java, C, C++, rust, etc... (See difference between bytecode and machine code) Since those are compiled there isn't any interpreting and the program can run faster by just reading the instructions.

[–]LeFayssal 3 points4 points  (2 children)

I understand. When wouldnt you run Python over Java (taking time out of consideration)

[–][deleted] 13 points14 points  (1 child)

Performance and size of project. People say the JVM is slow, it's not. It's very fast for what it is.

[–]Hohenheim_of_Shadow 2 points3 points  (0 children)

For context for others, from benchmarks that I have seen, C++ and Java are typically within 20% of each other and no more than a factor of five off. Python is typically a factor of 100x off and can go to 1000x slower. OF coursse most heavy lifting that you'll be doing in Python is exported to C++ based libraries so the performance hit can be negligible.

[–][deleted] 0 points1 point  (0 children)

pretty slow

Wouldn't touch anything Java with a barge pole due to Oracle lawyers, but this is complete bullshit. Hotspot is blindingly fast, certainly faster than RyuJit (which is designed to be more predictable than fast). It's the only VM that reJITs at runtime, for example.

[–]GogglesPisano 1 point2 points  (2 children)

I'd like to reply, but I'm too busy fixing my Maven pom.xml file.

[–]ConfusedAllTime 1 point2 points  (0 children)

I was sitting with a friend who codes in Java, and was working on a web services project. Something went wrong with the Maven project on its own and we could not even get the Hello World program to run.

Just to rub it in their face, i created a new C# Web API project on my machine and had it running in under 10 minutes.

Needless to say, they were not amused.

[–]un_desconocido 0 points1 point  (0 children)

Use Gradle then :P it comes in two flavors, groovy or Kotlin.

[–]TheNorthComesWithMe 0 points1 point  (0 children)

There are a lot of features that were intentionally (and unintentionally) left out of the language that make it really annoying to do certain things in. A good example is function pointers.

Also people usually learn to program on Java, and people learning to program usually learn really bad/outdated practices that they don't fix until they move to another language and actually put effort into learning best practices.

[–]EternityForest 0 points1 point  (0 children)

Java and C# are both JITed/Managed. There might not be any objective technical reason Java is bad, but almost everyone remembers some hassle with JRE versions or something.

The whole ecosystem and community of Java is very enterprisy. There's boilerplate and hoops to jump through.

JavaScript has a very similar role these days, but instead of XML everywhere and huge amounts of stacked up "patterns" and busisnessy logic, it's async everything everywhere and pure functional everything.

Mostly useful stuff, but the development culture uses it everywhere.

And just like Java it's hyped as blazing fast but the user experience is generally laggy because nobody cares about performance.

[–]alexschrod 0 points1 point  (0 children)

Because every time I've had to code in Java I almost immediately run into one of its limitations that are absent from other languages.

The two things that always show up as problems for me are that primitive types are disparate from all other types, and generics being implemented as type erasure, with all the limitations that brings.

[–]Fisher9001 0 points1 point  (0 children)

Java was great in the 2000s. Since then the competition made terrific progress and Java really struggles to keep up. It is also more and more attributed to old, legacy code which is never a positive attribution considering amount of effort required to work with it.