- Portals
- The Current Year
- ED in the News
- Admins
- Help ED Rebuild
- Archive
- ED Bookmarklet
- Donate Bitcoin
Contact an admin on Discord or EDF if you want an account. Also fuck bots.
Java: Difference between revisions
imported>MrWombat |
imported>LiteralKa Reverted edits by MrWombat (talk) to last revision by APerson241 |
||
Line 350: | Line 350: | ||
[[16 Year Old Girls]]. What a demonstration of how retarded Java is. | [[16 Year Old Girls]]. What a demonstration of how retarded Java is. | ||
== See Also == | == See Also == |
Revision as of 15:50, 8 February 2013
Java is part of a series on Programming. [Enter the Matrix] | |
ADA • Assembly • C • C++ • COBOL • Debug • DOS • Erlang • Error • Fdisk • Fortran • Integer • Java • LOLCode • Machine Code • Matlab • MIRC Script • MUMPS • Open Source • Perl • PHP • Programming language • Python • QBASIC • Ruby on Rails • Scratch • SSH • Visual Basic
Firefox XPS IRC Attack • Safari XPS Attack • Sandworm
Bill Gates • Linus Torvalds • Weev • Goatse Security • Terry Davis • Theo de Raadt
Operating system • Warez • Notepad • Is not a bug, it's a feature • Database Error |
Fact Cat says: JavaScript is not Java. If you were looking for Javascript, you might want to look here, you ignorant fuck. |
Java is an interpreted language which is unique in that it includes a pretend compiler so that Java programmers can feel like they're using a grownup programming language. It is object oriented and has automatic garbage collection to make it as easy as possible to allocate memory.
Java is like Alzheimers; it starts slow and eventually, it takes away all of your memory. Something Java fans like to talk about is the JIT compiler which eventually does turn Java into native code but only after it's been interpreted 10,000 times. By that time the program has probably already crashed with an out of memory error. Programming in Java drives most hackers permanently insane. Evidence of this can easily be obtained by attempting to comprehend the content of this website.
Java is notable (along with Flash) for being one of the few technologies that allows Alan Turing to pwn your browser. Also of note is that Java is one of the most bloated languages with a minimum of twelve lines needed to do something as complex as print "Hello" on the screen.
Java is like C for people who are too pussy to do real programming. Instead of creating actual fucking programs anyone can run on any computer, one must have a separate interpreter installed on their computer in order to run the bytecode, which is what Java calls code that's been "compiled". Unfortunately, since no one has installed this since Flash came out, no one will be able to use your user-programmable Pokedex (only 500MB!)
Java GUI applications are dogshit slow to load and run, and never feel right. To deflect criticism and hide this shittiness from decent, honest folk who are just trying to get some work done quickly, Java developers:
- use splash screens to mask the load time (they call this a "time warp.")
- use external, non-Java splash screen software when even the previous item fails at fooling the user (srsly)
- blame the Virtual Machine vendor
- blame the user for not fiddling with his Virtual Machine settings
- blame the user for not already having the JVM cached in memory. "What are you, a fucking retard?"
- use third-party toolkits
- fool you with bullshit millisecond measurements. "Who are you going to believe, me, or your lying eyes?"
Any version of Java released in the past 10 years requires the user to download a 110 megabyte file (compared to the 70 meg download for Microsoft's .NET Framework). Java web applets run in a sandbox and unless your applet is signed, it can't even access your clipboard but nobody uses Java applets anyway.
Since Java is the all-ruling and most powerful language in the universe, one might think that was is easy to learn. He would be right. Even half-assed morons can learn how to do it. Java isn't about creating something from scratch, its just an intricate copy and paste program.
Developing a GUI in Java
Java has two GUI packages, which are AWT and Swing. Use Swing for...
- Making your app look like legitimate Java applications.
- Actually, you can change how it looks in code, but for those lazy Java programmers who don't want to, the programs end up looking like dump. But since you're using Java, what do you expect?
- When you use Swing, the poor user will see the same components in all platforms, which is great.
- If you, the programmer, like putting a "J" in front of EVERY. FREAKING. THING. No, seriously. When you have a nice regular "Frame" in AWT, you have a stinking "JFrame" in Swing. Where the heck did the "J" come from? This is proof that James Gosling, the creator of Java, really likes "J"s.
- Swing was originally made as an extension package. Not legit at all. This means that back in the old days, people had to go off and download something extra to make Swing run. That's why it has an "x" on the package name ("javax.swing") instead of just the "java".
Use AWT for...
- Making your app look like the OS default apps.
- So when you run it on a Mac, you make it look like Steve Job's thing, and when you run it on a Windows, it looks stupid.
- When you use this type of components, using the software on the OS you have not designed your software for, your program will look insanely stupid.
Since you, the hapless programmer, are using Java for OS independence, you, like all other Java developers, will use Swing components. After testing your software, you will see how slow Java works. Java itself might be stable, but the difficulty of programming makes the programmer ignore all exception handling (too time consuming), so the software will eventually be buggy in some way. Unless, of course, you spend over 9000 years debugging your code. Which is exactly what James Gosling intended. Use C# instead!
Why Use Java?
Java is platform independent, like all its competitors C#, PHP, ASP.NET, ASP, C, C++, Python, etc... The only logical use of Java is building browser games which use Java applets today and to get on Larry's good side since they fucked MySQL. Period.
Hello World! I'm a program that is useless!
This is the layout of a basic "Hello World" in Java:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World! I'm a useless program!"); } }
Lets look at this a little deeper(eww). The first line is the class heading. This program is "public", which means it is avaliable to other programs for their use. This heading creates a "class" called helloWorld. "helloWorld" is an identifier, which means the programmer names it, so it doesn't matter what it is, as long as it doesn't contain numbers or spaces.
The bracket on line 2 contains the class.
The next line contains the method, called "main". Again, public means the same as above, but for the method, instead of the class. void means that it doesn't return a value, and main is the name of the method. (Just take my word for it, you have to write it this way until you become more advanced in Java).
The next line calls the "System.out.println" method, which prints the text in the double quotes to the console. You have a ";" at the of a statement to tell the compiler to stop for that statement.
Then you end with two brackets.
Of course, any java weenie will tell you that this is totally wrong. Static methods are bad. As are using the "no-name" package. Also, putting opening braces on a new line is completely retarded, as any non-retarded person knows. What you really need is something like:
package com.mydomain.sampleprograms; public class HelloWorld { public static void main(String[] args) { new HelloWorld().helloWorld(); } protected void helloWorld() { System.out.println("Hello World! I'm a useless program!"); } }
Instead of using static methods they might even go further and create so called singleton classes which do the EXACT samething but instead they don't have the static declaration.
If you use static methods the java weenie will "blame" you of having a C programer's mind. (As if it is something to be ashamed of)
The only case they let you to use static methods is the mathematical functions such as sin,cos,sqrt. The reason they let you do is, that they forgot to make the Math class singleton during the development of java. It is rumored that Math class would be a singleton either but some of the java developers said: "OK guys.. Object Oriented.. nice.. but.. what the f*ck are we doing here?? aren't we going too stupid?" Than they used static methods. Later those developers quited java and Math class became one of the few classes that used static methods.
An example of a stupid "singleton" helloworld:
package com.mydomain.sampleprograms; public class HelloWorld { private static HelloWorld hw; public static void main(String[] args) { System.out.println(HelloWorld.getInstance()); } public static HelloWorld getInstance(){ if(hw == null){ hw = new HelloWorld(); } return hw; } private HelloWorld() { //constructor became entirely useless //but whatever static methods are "bad" } public String toString(){ return "Hello World! I'm a useless program!"; } }
The Reflection API
NOTE: This section is under construction. Come back later for more lulz.
The Reflection API is one of the few elements of Java that was not jacked from another language and passed off as an original feature. It is Java's method of introspection, which means that while your program is running, it can check all sorts of fun stuff about your program. In short, it is the programming equivalent of licking your own balls. Using the Reflection API, you can do all sorts of fun stuff like getting the code for the statement you're running! What fun! This virus conveniently takes the form of a method found in every object in Java (getClass()
), so you can stare at your own ugly code any time you want.
TL;DR: Don't use introspection. You'll crash physics.
Trolling Java Fanboys
Much like Apple, Java has a user base who would die defending it. These people like to say "it's just as fast as C" and "it's not slow it only starts slow". These people are ridiculously easy to troll because almost anything you can say about their sorry excuse for a programming language will make them butthurt. Here are a few ways to get lulz from Java "programmers":
- Say interpreter. They hate this word, they like virtual machine since it sounds cool and futuristic while interpreter is just a program that evaluates script.
- Ask why in such a fast language, nobody ever wrote a video player or a game.
- Point out that everyone else uses php for web apps.
- Point out that everyone else uses C for desktop apps.
- Ask where to find affordable Java hosting.
- Mention that Eclipse IDE is now using GCJ to convert their Java into machine code so it will run faster.
- Join a Java IRC chan and ask for help with GCJ, tell people it's faster.
- Write a java interpreter that is not slow. OMG if it's not a resource hog
SunOracle won't be able to sell the new SparkXXXIV Genitalia 800 core processor. - Create another programming language and give it the same name.
—Marc Andreessen on doing it right (sauce) |
Restarting the VM
If you use Java shared hosting and you can't be bothered to open a ticket just to get the server restarted (who has time for that anyway?) You can restart the virtual machine any time you want using this slick little piece of java code:
Object[] o = null; for(;;) { o = new Object[] {o}; }
The admins will admire your cleverness and appreciate you for not opening tickets every time you need a restart. Disclamer: I didn't discover this
Lack of Unsigned Numbers
There is no such thing as unsigned numeric values in Java because Sun thought they would be too difficult for programmers to grasp. This is the intelligence level that Java is built around.
Commenting
Fuck commenting.
Type Bullshit
Java implements strict typing yet hypocritically has loose type casting, so adding two bytes with a value of 1 will result in an int, not a short, which is the next storage type above byte. If you want to store an unsigned byte, you better use an int and do some magic operator overloading add/sub/mul/div function gymnastics for the math to work.
Boolean literals - true and false
The two values are written with the reserved words true and false. codded as:
boolean butthurt;
butthurt = true;
or all at once:
boolean butthurt = true;
Loops
if loop- if (condition) = true, do code.
int i = 0; if (i<5){ System.out.println(i); }
This code checks to see if variable i is less than 5, if it is print out i's value.
This code will print: 0
for loop- for (A;B;C){ statements; } A-initialization B-termination C-increment Example:
for (int i=0;i<5;i++){ System.out.println(i); }
This code sets variable i to start at 0, check if its less then 5, if it is run statements and increment i by one. This will print:
0 1 2 3 4
while loop- while (condition) do statements
This one is pretty straight forward, if the condition is true, do the statements. Example:
int i=0; while(i<5){ System.out.println(i++); }
This will print:
0 1 2 3 4
do while loop- do statements while (condition)
Very similar to the while loop, but the do while loop always executes once since it evaluates the condition after the statement. A while will never run if the condition is false.
do { Statements; } while(condition);
Do the statement until the condition equals true.
Example:
int i=0; do { System.out.println(i); } while (i>5);
Note that the condition is false and will never be true from this code. So the statement will only run once. This will print: 0
Comparison operators
Comparison operators are used to compare two primitive values (rarely objects). The comparison operators are:
< less than
<= less than or equal to
== equal to
> greater than
>= greater than or equal to
!= not equal to
6 < 24 is true
6 <= 24 is true.
OP == fag is ture
6 == 24 is false.
10 >= 10 is true.
10 > 10 is false.
6 != 24 is true.
Logical operators
Logical operators are like an extension of comparison operators. The logical operators are:
&& and
|| or
Example: a && b and The result is true only if both a and b are true.
a || b or The result is true if either a or b is true.
You can also use the not operator. !a not true if a is false and false if a is true.
int i=0; int j=4; if (i>3||j<=4){ System.out.println("hfsdkjhs"); }
This will print the statement because the or operator only requires one of the conditions to be true.
if (i>3&&j<=4){ System.out.println("hfsdkjhs"); }
This wont print since the and operator requires all the conditions to be true.
if (!(i>3)&&j<=4){ System.out.println("hfsdkjhs"); }
This will print the statement since !(i>3) is actually true, so both conditions are now true.
Memory allocation and garbage collection
What? You are too lazy to tediously free() all your mallocs()?
State of Java
As the use of this useless language is dying, many people often use it to make shitty ass websites. Example: [1]
Things Programmed Using Java
16 Year Old Girls. What a demonstration of how retarded Java is.
See Also
- Python a superior object-oriented language
- CamelCase TheAnnoyingWayJavaProgrammersUseAbsurdlyLongFunctionNamesWithoutUsingTheUnderscoreCharacter