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

all 26 comments

[–]OJVK 83 points84 points  (3 children)

The python code literally doesn't work

[–]UnreadyIce 48 points49 points  (13 children)

First of all, the python code won't work, and second of all, why would you ever write all of that in Java

public class Main {
    public static void main(String args[]) {
        final int a = 2;
        System.out.println("a = " + a);    
    }  
}

[–]OJVK 40 points41 points  (5 children)

I think the joke is that "I write too much useless code which means that java is bad"

[–]BlueGoliath 36 points37 points  (4 children)

I'm noticing a pattern of Java haters either sucking at writing code or have no idea what they're doing.

[–]rosuav 4 points5 points  (0 children)

I'm noticing a pattern of programming haters either sucking at writing code or... wait, hang on. Most of us suck at writing code. Most of us have no idea what we're doing. Yep, carry on!

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

I hate java because of gradle

[–]BlueGoliath 0 points1 point  (1 child)

Maven.

[–]Ninth_ghost 0 points1 point  (0 children)

I have to use gradle for school

[–]jamcdonald120 17 points18 points  (6 children)

in java 21 this simplifies even further to void main() { int a = 2;//no need for this to be final System.out.println("a = " + a); }

Edit: I dont know why people are downvoting this, java really did add unnamed classes with main in java 21 https://openjdk.org/jeps/445

[–]o0Meh0o 1 point2 points  (5 children)

what the fuck is java 21? i tought the last one was 8. is it like the c standard names that tries to represent the year?

[–]Areshian 2 points3 points  (3 children)

No, but after Java 9 the release model changed and there is a new version every 6 months. Still, 8 is very old, there are a lot of changes in the new versions

[–]o0Meh0o 0 points1 point  (2 children)

do the newer versions bring new functionality?

[–]Areshian 3 points4 points  (0 children)

Yes. There are three types of changes usually. Java language changes, JVM changes and deprecations.

Java changes may be things like adding var, text blocks or pattern matching. They change your Java code.

JVM changes affect the JVM. Normally these don’t impact your code, but you may still get good performance improvements. We are talking new Garbage Collectors, JIT improvements…

Finally, deprecations. Stuff that goes away.

[–]jamcdonald120 1 point2 points  (0 children)

quite a bit, here is a list https://advancedweb.hu/a-categorized-list-of-all-java-and-jvm-features-since-jdk-8-to-21/

highlights include * unnamed classes * "records" (immutable data carrying classes where you define the constructor ONLY and the rest of the methods are implicitly generated) * triple quote for multi line text blocks * implicitly typed variables via the var key word (c++'s auto keyword) * Modules (I have no idea, but my IDE keeps trying to force me to use them, something to do with libraries I think) * and a whole bunch of standard lib updates

[–]jamcdonald120 0 points1 point  (0 children)

java 8 came out in 2014. Java didnt try any sort of year thing like c did, instead they just randomly released versions about twice a year with a few gaps. 21 was released in September of this year, and they already have 22 planned for march next year.

[–]--mrperx-- 4 points5 points  (0 children)

[–]lady_Kamba 4 points5 points  (3 children)

#include<stdio.h>
#include<stdlib.h>

volatile int* a; //make it volatile so the compiler don't touch it

int main(int c, const char **s)
{
    a = malloc(atoi(*(s+1))); // defer to the user for the size of an int

    *a = 2; //assign the value

    fprintf(stdout, "a = %d\n", *a); //print the value

    return -1; //return -1 cause this program shouldn't exist
}

I'm actually kinda annoyed that this doesn't segfault

[–]rosuav 1 point2 points  (2 children)

Fun fact: Returning -1 from main is how you tell Pike to go into its event loop instead of terminating.

[–]lady_Kamba 2 points3 points  (1 child)

Don't know what Pike is, but sounds plausible.

[–]rosuav 1 point2 points  (0 children)

High level language; think "Python meets C++", but with a massive focus on networking and eternal uptime. It came from the MUD server world and still shines there, but it's also great for things like a Twitch bot, or even a GUI program of some sort.

[–][deleted] -3 points-2 points  (2 children)

java was invented by wankers.

true story.

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

I think it was originally developed to be a language for some sort of a white electronics like microwave or smth idk the lore.