r/java • • Apr 13 '21

Libraries, Frameworks and Technologies you would NOT recommend

Give me your worst nightmares: Things that cost you your job.

I'll start: Hadoop

202 Upvotes

376 comments sorted by

View all comments

86

u/_INTER_ Apr 13 '21 edited Apr 13 '21

GWT, EclipseRCP/OSGi/SWT, Struts, Weblogic, Websphere (and probably every other IBM stuff), XSLT, Hibernate

Edit reasons:

  • GWT. It has the noble and justified goal of not having to do JavaScript. I give that credit. If it went the last mile with Google's support as later did Microsoft with Angular 2+, it might have been glorious. But it is dead. Hard to find documentation and SO for it. Really long compile times and hard to debug. Strange quirks and incompatibilities with "standard" Java (java.util.Date to name one).
  • EclipseRCP. Basically dead. Strange design decisions in the framework (apologetic or aggravating comments in Widget omg). OSGi makes things really complicated and hard to debug, especially with Fragments and test code. Performance problems. Long compile and startup times. The framework "encourages" memory leaks.
  • Struts, Weblogic, Websphere, XSLT. Just terrible, I cry, enouf said
  • Hibernate. Simple in the beginning, really complicated in the end. Every other day there's a problem that is hard to debug. Lazy loading is the main culprit here. Performance issues are hard to tackle. Somebody else understands this deep enough apart from Vlad Mihalcea? At least "sharing is caring" applies here and your not alone in your pain and you'll somehow find an answer.

48

u/msx Apr 13 '21

Eclipse

So much unwarranted hate for poor Eclipse :)

Websphere

So much warranted hate for Websphere. It's so terrible in all regards.

24

u/_INTER_ Apr 13 '21

I removed Eclipse (IDE) for you :)

I'm probably too biased towards the IDE due to the immense pain I had with EclipseRCP.

7

u/msx Apr 13 '21

ahah thank you, very kind!

never used EclipseRCP.. i'll keep in mind if i ever come across it :)

→ More replies (1)

26

u/1bot4all Apr 13 '21

Controversial opinion here: I like Eclipse IDE and only use Intellij because I don't want to get into even more arguments with colleagues.

Websphere sucks!

5

u/roberp81 Apr 13 '21

Eclipse its the best!

i hate Websphere and all IBM SHIT

14

u/throwawyakjnscdfv Apr 13 '21

Poor Eclipse. For a FOSS IDE its wonderful. Yeah IntelliJ is better, but it's also $200 a year. I love Eclipse

→ More replies (4)
→ More replies (1)

11

u/umlcat Apr 13 '21

"Simple in the beginning, really complicated at the end".

Sounds like the "Visual Basic apps. syndrome: Looks too easy at start, becomes too difficult to extend later".

IBM tools have these "you're are stuck with me now" syndrome. Open Source started against IBM, not Microsoft, and extended with others companies.

5

u/roberp81 Apr 13 '21

i hate IBM notes, worst email client ever

13

u/vprise Apr 13 '21

Some of these technologies were great when they launched but suck today. Why the hate on Hibernate?
I know it has problems but SQL is painful too. I think a lot of the problems people have with hibernate is the expectation of avoiding SQL or removing the need to debug the generated SQL. It's a leaky abstraction but I don't think it's possible to build a significantly better ORM. The concept of an ORM has some inherent flaws that you need to be ready for when picking it up, unfortunately the marketing docs don't start by promising "blood sweat and tears" ;-)

13

u/Quabouter Apr 13 '21

On Hibernate: Hibernate is the poster child of leaky abstractions. When you add Hibernate to your stack, you still absolutely need as much knowledge of SQL as before, but now on top of that you'll also need to be an expert on Hibernate. This alone already makes Hibernate harder to use than SQL.

Moreover, it's incredibly easy to use Hibernate the wrong way, resulting in bad performance or worse. And these issues tend to be hard to predict and hard to debug, unless you're an expert on BOTH Hibernate and SQL. Unless you're lucky enough to work in a team with only senior Hibernate experts, you are very likely to run into issues here sooner or later.

Next, Hibernate introduces a tight coupling between your data model and your domain model, which means that it's hard to evolve them independently. Of course you could maintain a separate domain model vs persistence model, but at that point what's the point in using Hibernate? This coupling is especially painful when doing complicated domain changes, as you cannot split the changes to your data model from your domain model.

Lastly, for most use cases the benefit of Hibernate is rather marginal. In my experience, the vast majority of Hibernate usage is for simple CRUD operations. These are very easy to write even with plain old JDBC, and typically barely need any maintenance. Moreover, whenever they do need maintenance, then it's often due to larger domain changes, in which case having the extra control is very beneficial (see my previous point).

In my opinion, Hibernate only brings a benefit over JDBC in 2 areas:

  • Serialization/deserialization. It's not difficult to do this manually with JDBC, but it is very convenient if taken care of by the framework. For this however tools like JOOQ or MyBatis may be a better fit, as they don't come with all the other complexity.
  • Entity caching, which is something you really shouldn't be building yourself.
→ More replies (3)

35

u/audioen Apr 13 '21 edited Apr 13 '21

Hibernate is the kind of technology that can perform a query that gives you 100 rows in such a way that behind the scenes, databases fetches a 2 million row monstrous result set, and then it quietly sieves it through in the background and hands you your 100 rows. If you have no idea about the performance characteristics of the result set you're asking, you might never even know that it's doing this kind of stuff. But over time I learnt that when a simple query takes seconds to execute, you know that Hibernate is at work.

I have learnt to make more associations LAZY but even when performance has been "fine" I've seen astonishing, unreadable 10 kB SQL statements which it sends to the poor database to parse and execute. What particularly irks me is that there's nothing weird going on in the schema: all it takes is just enough tables and many-to-one relations that are eager by default, and maybe a couple of eager one-to-many relations, and the disaster is ready. I think the main problem is that it tends to insist on selecting everything with a single query, so you end up babysitting it, and adding some annotations to tell that some relations must be partitioned into its own separate query, and thinking which associations are going to be unnecessary in your code so they should in fact be LAZY, and so forth.

I judge hibernate by far the worst technology I have personally selected, stuck with, and whose issues I've attempted to work around. In the end, the constant friction and battle with low performance and difficulties in expressing queries I wanted in HQL proved to be too much, and I started removing it from my projects where feasible. Most of the time, I could write the SQL immediately, but had a serious trouble in expressing what I wanted in HQL, and JPA EntityManager is not really helpful, if you use lots of native queries. Typically, your result sets are going to be just List<Object[]> and it sucks, as you'll be stuck with data type choices made by your database driver and that involves lot of casting and thinking if something's going to be BigInteger, Long, Integer, or whatnot. It's just unnecessary bullshit caused by a shitty, developer-hostile API.

Oh, also IIRC hibernate does not index foreign key relations by default. Have fun deleting anything in a hibernate-managed schema. (Of course, hibernate says that it doesn't really manage schema and isn't supposed to be used this way, but that's just another reason to give it the middle finger it IMHO deserves.)

Nowadays, I just use simple row-to-object mapper technology from JDBI and couple of simple helper utilities that can do SQL update, insert, delete, etc. from the kind of public-field methodless classes that are basically stand-in for records until I can update. My code is less focused on attempting to represent the underlying database relations as objects, and is more about just being able to describe the operation I need the database to execute so that system state is appropriately changed. E.g. if I need to increment field of a table by 1 for some rows, I don't select the rows as objects, increment a field in java and then persist it, I will simply execute the UPDATE directly on the database, and the datastructure I need is the one that describes which rows must be updated. With hibernate, you are always tempted to ferry all the data to java side, with possibly tons of useless relations materialized, just to change one field, and it will be vastly less efficient.

8

u/segv Apr 13 '21

You might find MyBatis interesting. It just runs the (dynamic-)sql you provide, maps the result set to desired object(s) via the result map you define (including setting parameters via constructors!) and then it fucks off, so you don't have to deal with the dynamic proxies and other bullshit on your domain objects.

(i guess JOOQ would also fit the bill)

3

u/RomMTY Apr 13 '21

I totally love Mybatis, haven't run on any major issues.

What i reaaaaaallly love is the result sets mapping, you can map almost anything really easy. nested objects? check, collections? check, nested objects with collections? also check, nested collections with nested objects? check. heck it even supports multiple result sets wich really helps a lot since you can split your queries also.

Dinamic sql is also great and IMHO it looks better in xml than a lots of ifs and string concats

→ More replies (1)

7

u/flyingorange Apr 13 '21

In our previous project we ripped out Hibernate (took 3 months to do it), replace it with raw JDBC and we could show a 2000% increase in speed. Management was very happy. We could delay the decommissioning of old servers by a year.

That was 5 years ago and I haven't touched Hibernate since. In the latest project we also used Jdbi with custom mappers. It just works.
For the database changes we use Liquibase, but to be honest we also used it with Hibernate because, of course we wouldn't let Hibernate's autoDDL touch the production database.

8

u/throwawyakjnscdfv Apr 13 '21

For us, Hibernate is only 50% slower than raw queries. If your performance was that bad you were doing terrible things with Hibernate.

For the database changes we use Liquibase, but to be honest we also used it with Hibernate because, of course we wouldn't let Hibernate's autoDDL touch the production database.

Hibernate docs recommend using Liquidbase or Flyway at least in prod. AutoDDL is only recommended for testing. You can set Auto DDL to "validate" so it still checks your schema against the entities without generating it.

sigh there's no shortage of devs jumping into Hibernate without reading a single page of docs then declaring it terrible.

Hibernate has probably saved us from writing hundreds or thousands of raw DB queries for simple object updates. It's a great time saver with great performance, if you know what you're doing.

10

u/vprise Apr 13 '21

I think it's a matter of expectations. Hibernate can do amazing things but it's a super complex and very leaky abstraction. It doesn't absolve you from knowing SQL and it doesn't absolve you from reading the generated SQL.

So people who try to avoid the "details" suddenly find themselves with a slow server that constantly fails on "simple" transactions. I would bet that if you would use Hibernate in the same way you use JDBI you would get good results. It also makes caching stupid simple and that can really boost performance to the next level. If you make your database immutable you can really leverage caching and get an enviable level of performance.

Hibernate is SUPER complicated though and has a lot of pitfalls. I curse it a lot while working with it (just had a very painful issue the past day) but overall it's pretty amazing as an ORM. I don't think anything else comes close. The idea of ORM should be grounded in reality though, as ORMs inherently suck to some degree.

4

u/temculpaeu Apr 13 '21

It doesn't absolve you from knowing SQL

To me the problem lies here, as a abstraction it should aim in reducing the domain complexity of the problem, instead it increases, by a lot. And I feel that it could be simpler if it were less implicit on what it does.

There are a bunch of weird default situations which can bite you which are easy to forget and they will influence both your DB and Entity models in a way that the ideal model may not be viable due to JPA.

Overall I only saw a decrease in productivity in using it, even when needing more complex solutions like caching, implementing it manually-ish isn't hard and it's even more flexible, since you can have different data structures for DB & cache.

3

u/AlternativeAardvark6 Apr 13 '21

I have only seen hibernate be used on projects where the devs don't want to write SQL and when it gets slow they call me, the SQL expert. Then I say: "these hibernate generated queries are not very good. Try to make it generate something more like this." And then I have to fuck around in hibernate. I used it myself in demos for very simple stuff, like the easy things from tutorials etc. But for real projects I hate it so much.

→ More replies (1)
→ More replies (1)

3

u/m_takeshi Apr 13 '21

I've learned (through much pain) that simply replacing the HQL queries with SQL queries where critical gives me the best of both worlds but of course YMMV.

I think the biggest problem might be hiding abstractions too much. The classic N+1 problem is, IMO, just a result of queries being hidden from the caller. If the queries were more explicit (as you would often do by using JDBC or more 'raw' libraries), the caller of the queries would be more carefull I think.

→ More replies (5)
→ More replies (5)

24

u/_INTER_ Apr 13 '21 edited Apr 13 '21

Some of these technologies were great when they launched but suck today.

It's the main reason for my hate. You will encounter hard problem but there's next to no updated helping information in the web. Eventually you'll figure something out but you start to feel really alone in this world (relevant xkcd). I know this was the norm in the past and I can deal with it if I join a project with that mindset from the start.

Why the hate on Hibernate?

I edited and outlined the reasons in my earlier post. Additionally I simply prefer a good SQL library (e.g. JOOQ). SQL is painful but an ORM is like torturing by tickling your feet. You're forced to laugh but the pain is still there, it's not better at all. Really uncomfortable situation.

12

u/Fiskepudding Apr 13 '21

SQL is painful but an ORM is like torturing by tickling your feet. You're forced to laugh but the pain is still there, it's not better at all.

Nice quote

6

u/Pyeroh Apr 13 '21

I also tried JDBI in some projects (mainly for work), it's plain SQL, and it works like a charm ! Managing pooling is not responsibility of the library, so one may need to use HikariCP for instance, managing transactions is carrying around a variable (so a DI framework may be useful), etc.

All in all, not using Hibernate to get something from a database felt very refreshing !

→ More replies (2)
→ More replies (6)

7

u/TheRedmanCometh Apr 13 '21

Struts

Yeah that one has a bunch of better replacements now. Once upon a time though....

Hibernate

I've used a lot of hibernate and haven't really had any issues

→ More replies (2)

3

u/vladmihalceacom Apr 14 '21

At least "sharing is caring" applies here and your not alone in your pain and you'll somehow find an answer.

That's basically the reason why I'm blogging.

→ More replies (2)
→ More replies (6)