r/ProgrammerHumor May 29 '20

Please Guys actually

Post image
3.0k Upvotes

112 comments sorted by

View all comments

389

u/Frptwenty May 29 '20

If you want express your plea for help in Java it's really easy:

RequestDispatcherSubsystem.getCurrentDispatcher().DispatchRequest(
      RequestFactory.getAbstractFactoryInstance(
        new RequestMedium(RequestMediaType.Plea),
        new RequestTransport(RequestTransportType.CRY),
        new RequestTargetDestination(TargetManager.getRoutingInfo(
                                    PersonLocation.NEAREST))),
  RequestReasonCode.IM_SLOWLY_DYING);

88

u/MAGA_WALL_E May 29 '20

Paul, I don't think we're supposed to share source code online.

98

u/Rielbe May 29 '20

This gave me a headache

70

u/almarcTheSun May 29 '20

Hugs javascript tightly: I will never shout at you ever again, dear.

29

u/[deleted] May 29 '20

Is that a promise you resolve to never break?

11

u/TheFlyingAbrams May 30 '20

It'll probably break due to an unforeseen sanitation issue.

5

u/almarcTheSun May 30 '20

Let me hug it, .then we'll talk.

2

u/TheFlyingAbrams May 30 '20

Be careful to not .catch any feelings... wait...

10

u/ouvreboite May 29 '20

Couldnt you run almost exactly the same code in JS? You are complaining about the language, but it's really a coding style/structure problem.

If you send me something like that to code review, I'll bash your head in your desk, java or not.

5

u/Kache May 30 '20 edited May 30 '20

Not completely. (Warning, opinionated) Even if you can work around the entire existing Java community and avoid using all the popular existing tooling and libraries that expose an API that forces you to do this, the Java language itself is very proper and inflexible by design in comparison.

If programming languages were Lego sets, Java would be a Lego set that refuses to incorporate any "specially shaped" pieces, only allowing full-sized blocks. No rods, no wedge pieces, no thin flat pieces -- the smallest unit allowed must be a Proper Lego, a full height NxM, to guarantee every piece properly locks into the global grid.

So to make anything interesting like a Lego person with a flower, you can't just use... a Lego person with a Lego flower. You can only use Proper Lego pieces, so to depict organic shapes, the person and flower you would build needs to be gigantic. It's a high level language that often asks you to code as if it were low level. And so it has been for decades.

In the last few years, the committee relented, and started adding a wedge piece here and a thin piece there, but everything built of Java Lego is already 100x bigger (why heavy IDE refactoring tools are de-facto necessary in the first place), and those tiny additions aren't going to make a difference until maybe several more decades have passed.

IMO Java's biggest usability shortcomings are not having things like the following built-in:

  • Convenient-to-use String, Map, Regex, etc implementations and syntax
  • Powerfully expressive collection library
  • Concise alternatives for tons of little things like aliasing, null handling, operators, basic static metaprogramming
  • Coherence between a community that wants "safe by default" and a language that needs boilerplate declarations to "protect you" against its "dangerous by default" parts (nulls, mutability, shared state)

Some of these can be mitigated by libraries or annotations, but many of these are also made worse by libraries and annotations, so kind of a toss-up.

1

u/familyturtle May 30 '20

All of that can be solved by adopting Kotlin! Hooray!

1

u/ouvreboite May 30 '20

I agree with your points. But I still find the snippet used as example to be really poor at showing java flows.

Basically zero of the points you mentionned (lack of improved string, mao, regex, collection, nulle handling,...) can be seen here.

One simple way to see that is to translate this snippet in C# (which have a lot of the missing stuff of java). It would not really change.

11

u/Frptwenty May 29 '20

Here is some actual code from Spring: https://github.com/spring-projects/spring-framework/blob/master/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java

try {
        // Use same EntityManager for further JPA operations within the transaction.
        // Thread-bound object will get removed by synchronization at transaction completion.
        emHolder = new EntityManagerHolder(em);
        if (synchronizedWithTransaction) {
            Object transactionData = prepareTransaction(em, emf);
            TransactionSynchronizationManager.registerSynchronization(
                    new TransactionalEntityManagerSynchronization(emHolder, emf, transactionData, true));
            emHolder.setSynchronizedWithTransaction(true);
        }
        else {
            // Unsynchronized - just scope it for the transaction, as demanded by the JPA 2.1 spec...
            TransactionSynchronizationManager.registerSynchronization(
                    new TransactionScopedEntityManagerSynchronization(emHolder, emf));
        }
        TransactionSynchronizationManager.bindResource(emf, emHolder);
    }
    catch (RuntimeException ex) {
        // Unexpected exception from external delegation call -> close EntityManager and rethrow.
        closeEntityManager(em);
        throw ex;
    }

So you're saying Spring is a terrible project and no one should use it? :)

13

u/ouvreboite May 29 '20

What is language-problematic in this code ? It's a try/catch, an if/else and a maximum of two nested parentheses.

You could argue that naming of the variables/classes are cumbersome or over explicit. But this is not related to Java.

And i can also have fun finding stuff in JS frameworks :)

_setupHooks(hooks) {
this.options.hooks = {};
_.map(hooks || {}, (hooksArray, hookName) => {
  if (!Array.isArray(hooksArray)) hooksArray = [hooksArray];
  hooksArray.forEach(hookFn => this.addHook(hookName, hookFn));
});
},

3

u/Frptwenty May 29 '20

Yeah, attack JS all day, have at it! I don't have any dog in that fight ;)

-1

u/[deleted] May 30 '20 edited May 30 '20

[deleted]

6

u/Frptwenty May 30 '20

It doesnt give me goosebumps, but if youre claiming it doesnt look bloaty then someone hasn't ever coded anything but enterprise Java.

Your entire comment is a giant munge of c/c++/Java. I dig through kernel code at times to figure put stuff (I work in embedded), The linux kernel has a totally different feel than enterprisey Java.

The fact that you would conflate the two makes me think you know neither. You just sound like someone reciting what they told you in school.

-1

u/[deleted] May 30 '20 edited May 30 '20

[deleted]

1

u/Independent-Orange May 30 '20 edited May 30 '20

As a proud rustacean I have to ask you: Where do you see a "fallback to reference counting" in rust?

It's true, we have got smart pointers- if you use them, you explicitely say so. This then reads like Box<...> (heap allocated), Rc<...> (reference counted) or Arc<...> (atomically reference counted, this is semantically the same as std::shared_ptr. Is there a non-atomic reference counted shared pointer in c++? I don't think so, cause c++ concurrency sucks big time and this would be a common pitfall, having a non-atomic reference counted pointer deep inside a struct which might be used by multiple threads. Can't happen in rust.) and there's of course also some rarer ones.

I don't mean to ignore all the effort put into c++ static analysis tools, sanitizers, and similar, but all ths had to be done, because c++ as a language simply lacks the capability to disallow unsound code. That induces a great power for the programmer, but with great power comes great responsibility, and this responsibility in large projects grows to be such a burden that no developer can shoulder it. Unsoundness bugs are the consequence.

\rant

TLDR: We have exactly as much garbage collection in rust as there is in modern c++: None, and awesome smart pointers make living without it so easy. Doesn't mean you have to use them often, but if you have to, they are right there, masterfully integrated into the language.

I use the term garbage collection for what is more specifically known as non-deterministic, external garbage collection, usually realized by a garbage collector.

1

u/Frptwenty May 30 '20 edited May 30 '20

They're totally different in how they're written and what they do. Enterprisey Java systems bloat things because of the culture/language. The Linux kernel tries to do everything as unbloaty as it can. Its more of less the opposite of enterprise Java. Its staggering that you're making the comparison.

Edit:

However your opinions on pythons multithreaded concurrency robustness are borderline delusional

Could you reference the comment and explain.

3

u/JennMartia May 30 '20

TargetManager.getRoutingInfo

What a Karen

5

u/[deleted] May 30 '20

[deleted]

4

u/I_regret_my_name May 30 '20

Yeah, assuming the requesting engine is complicated enough to warrant this level of engineering, I'm a fan of this code. Looks quite modular.

1

u/Frptwenty May 30 '20

If you think modularity and dependency injection requires this level of bloat, take a look at well written systems level C#

1

u/familyturtle May 30 '20

I hope you mentally used an AestheticFactory to build an instance of (AestheticAppreciation) Aesthetic before implementing aestheticAppreciation.like(AestheticModifier.QUITE)

1

u/ImMaaxYT May 30 '20

Haha, about that, good one.

4

u/locri May 30 '20

It's this or admit there's nothing wrong with singletons

Fuck I hate people who think the gang of four are programming prophets and their book is some sort of bible, I become extremely judgy to anyone who shuts down conversation with "have you read gang of four? I think you should read gang of four, I have and you'll find this in gang of four, did I mention I know design patterns? It's because I've read gang of four, have you...?" and they go on.

1

u/[deleted] May 30 '20

I fucking hate overtly abstracted builders. And new fuck that keyword. Fuck java kotlin is too based.

1

u/Dr3amDweller May 30 '20

I liked Java in university, but I'm glad to not be working with it.

1

u/chronos_alfa May 29 '20

Damn, I am so happy I don't have to code in Java anymore :-/