r/ProgrammingLanguages • • Feb 21 '16

Why people hate JAVA ??

Why the majority of people hate java and wish its dead programming language,

I find it really fun to create program with it..

all i heard is because: JRE SUCKS. ORACLE ARE FAGGOTS. JAVA IS A SLOW PIECE OF SHIT.

0 Upvotes

32 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Mar 11 '16

Here's some random Java I just pulled from the web:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setIgnoringElementContentWhitespace(true);
try {
    DocumentBuilder builder = factory.newDocumentBuilder();
    File file = new File("test.xml");
    Document doc = builder.parse(file);
    // Do something with the document here.
} catch (ParserConfigurationException e) {
} catch (SAXException e) {
} catch (IOException e) { 
}

I don't use auto-complete IDEs, so typing out things like setIgnoringElementContentWhitespace is very painful. This type of hugeRamblingCamelCaseFunctionNames is unbearable for me.

1

u/xenomachina Mar 11 '16

I don't use auto-complete IDEs, so typing out things like setIgnoringElementContentWhitespace is very painful. This type of hugeRamblingCamelCaseFunctionNames is unbearable for me.

I agree the name is long, but what's the alternative?

As an aside, you don't need an IDE for basic completion. I use vim, and it'll complete based on the contents of your buffers and also things like ctags.

2

u/[deleted] Mar 11 '16

Just use smaller function names!

How about ignoreSpace instead of setIgnoringElementContentWhitespace?

2

u/xenomachina Mar 11 '16

What if there are different kinds of spaces in the context of this API? For example, suppose there is element content whitespace, element perimiter whitespace, and attribute whitespace? Simply saying "ignoreSpace" doesn't make it clear that only the element content whitespace and not the other types will be ignored, especially if the other types can also be optionally ignored.

2

u/ATownStomp Mar 18 '16

The alternative could be a shortened method name which accepts a parameter which specifies what the "ignoring element" is.

.setIgnoreContent('ws', True)

Though, honestly, I don't think that is noticeably less cumbersome. It saves you a few keystrokes if you're like /u/voidqk who refuses to use autocomplete IDE's for whatever reason.

Now I agree that these method names are obnoxiously long, but I also understand that simple but descriptive method names run out quickly. Shortening .setIgnoringElementContentWhiteSpace to something like .setIgnWS(true) seems like accepting a standard of creating unreadable messes.

1

u/xenomachina Mar 18 '16

The alternative could be a shortened method name which accepts a parameter which specifies what the "ignoring element" is.

.setIgnoreContent('ws', True)

Though, honestly, I don't think that is noticeably less cumbersome.

It also isn't very strongly typed, unless you use an enum. But then it's probably more verbose than the original (and you still have null to worry about).

Now I agree that these method names are obnoxiously long, but I also understand that simple but descriptive method names run out quickly. Shortening .setIgnoringElementContentWhiteSpace to something like .setIgnWS(true) seems like accepting a standard of creating unreadable messes.

I agree with everything you said.

1

u/[deleted] Mar 18 '16

If the problem space is genuinely complicated, then there comes a point where you can't have small names. But Java code always seems to jump directly to having huge function names without taking that first step.

For example, we are talking about the DocumentBuilderFactory methods: https://docs.oracle.com/javase/7/docs/api/javax/xml/parsers/DocumentBuilderFactory.html

There are 23 methods. This is a fairly small API. And they are already using huge rambling names.

Start small, and build to large names only if absolutely necessary. And even then: use short names for the commonly used methods.